curl --request POST \
--url https://api.example.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--header 'anthropic-version: <anthropic-version>' \
--data '
{
"max_tokens": 123,
"model": "<string>",
"messages": [
{
"content": {}
}
],
"top_p": 123,
"top_k": 123,
"stop_sequences": [
"<string>"
],
"tool_choice": {},
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"inference_geo": "<string>",
"output_config": {
"effort": "<string>",
"format": {
"schema": [
[
[
{}
]
]
],
"type": "<string>"
}
},
"service_tier": "<string>",
"system": {},
"temperature": 123,
"stream": true,
"thinking": {
"budget_tokens": 123,
"type": "<string>",
"display": "<string>"
},
"tools": [
{
"input_schema": [
[
[
{}
]
]
],
"allowed_callers": [
"<string>"
],
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"defer_loading": true,
"eager_input_streaming": true,
"input_examples": [
{
"key": {}
}
],
"name": "<string>",
"description": "<string>",
"type": "<string>",
"strict": true
}
],
"metadata": {
"user_id": "<string>"
},
"container": "<string>"
}
'import requests
url = "https://api.example.com/v1/messages"
payload = {
"max_tokens": 123,
"model": "<string>",
"messages": [{ "content": {} }],
"top_p": 123,
"top_k": 123,
"stop_sequences": ["<string>"],
"tool_choice": {},
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"inference_geo": "<string>",
"output_config": {
"effort": "<string>",
"format": {
"schema": [[[{}]]],
"type": "<string>"
}
},
"service_tier": "<string>",
"system": {},
"temperature": 123,
"stream": True,
"thinking": {
"budget_tokens": 123,
"type": "<string>",
"display": "<string>"
},
"tools": [
{
"input_schema": [[[{}]]],
"allowed_callers": ["<string>"],
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"defer_loading": True,
"eager_input_streaming": True,
"input_examples": [{ "key": {} }],
"name": "<string>",
"description": "<string>",
"type": "<string>",
"strict": True
}
],
"metadata": { "user_id": "<string>" },
"container": "<string>"
}
headers = {
"anthropic-version": "<anthropic-version>",
"X-Api-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'anthropic-version': '<anthropic-version>',
'X-Api-Key': '<x-api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
max_tokens: 123,
model: '<string>',
messages: [{content: {}}],
top_p: 123,
top_k: 123,
stop_sequences: ['<string>'],
tool_choice: {},
cache_control: {type: '<string>', ttl: '<string>'},
inference_geo: '<string>',
output_config: {effort: '<string>', format: {schema: [[[{}]]], type: '<string>'}},
service_tier: '<string>',
system: {},
temperature: 123,
stream: true,
thinking: {budget_tokens: 123, type: '<string>', display: '<string>'},
tools: [
{
input_schema: [[[{}]]],
allowed_callers: ['<string>'],
cache_control: {type: '<string>', ttl: '<string>'},
defer_loading: true,
eager_input_streaming: true,
input_examples: [{key: {}}],
name: '<string>',
description: '<string>',
type: '<string>',
strict: true
}
],
metadata: {user_id: '<string>'},
container: '<string>'
})
};
fetch('https://api.example.com/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'max_tokens' => 123,
'model' => '<string>',
'messages' => [
[
'content' => [
]
]
],
'top_p' => 123,
'top_k' => 123,
'stop_sequences' => [
'<string>'
],
'tool_choice' => [
],
'cache_control' => [
'type' => '<string>',
'ttl' => '<string>'
],
'inference_geo' => '<string>',
'output_config' => [
'effort' => '<string>',
'format' => [
'schema' => [
[
[
[
]
]
]
],
'type' => '<string>'
]
],
'service_tier' => '<string>',
'system' => [
],
'temperature' => 123,
'stream' => true,
'thinking' => [
'budget_tokens' => 123,
'type' => '<string>',
'display' => '<string>'
],
'tools' => [
[
'input_schema' => [
[
[
[
]
]
]
],
'allowed_callers' => [
'<string>'
],
'cache_control' => [
'type' => '<string>',
'ttl' => '<string>'
],
'defer_loading' => true,
'eager_input_streaming' => true,
'input_examples' => [
[
'key' => [
]
]
],
'name' => '<string>',
'description' => '<string>',
'type' => '<string>',
'strict' => true
]
],
'metadata' => [
'user_id' => '<string>'
],
'container' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <x-api-key>",
"anthropic-version: <anthropic-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/messages"
payload := strings.NewReader("{\n \"max_tokens\": 123,\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {}\n }\n ],\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tool_choice\": {},\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"inference_geo\": \"<string>\",\n \"output_config\": {\n \"effort\": \"<string>\",\n \"format\": {\n \"schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"type\": \"<string>\"\n }\n },\n \"service_tier\": \"<string>\",\n \"system\": {},\n \"temperature\": 123,\n \"stream\": true,\n \"thinking\": {\n \"budget_tokens\": 123,\n \"type\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"tools\": [\n {\n \"input_schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"allowed_callers\": [\n \"<string>\"\n ],\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"defer_loading\": true,\n \"eager_input_streaming\": true,\n \"input_examples\": [\n {\n \"key\": {}\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"strict\": true\n }\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"container\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("anthropic-version", "<anthropic-version>")
req.Header.Add("X-Api-Key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/messages")
.header("anthropic-version", "<anthropic-version>")
.header("X-Api-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"max_tokens\": 123,\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {}\n }\n ],\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tool_choice\": {},\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"inference_geo\": \"<string>\",\n \"output_config\": {\n \"effort\": \"<string>\",\n \"format\": {\n \"schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"type\": \"<string>\"\n }\n },\n \"service_tier\": \"<string>\",\n \"system\": {},\n \"temperature\": 123,\n \"stream\": true,\n \"thinking\": {\n \"budget_tokens\": 123,\n \"type\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"tools\": [\n {\n \"input_schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"allowed_callers\": [\n \"<string>\"\n ],\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"defer_loading\": true,\n \"eager_input_streaming\": true,\n \"input_examples\": [\n {\n \"key\": {}\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"strict\": true\n }\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"container\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["anthropic-version"] = '<anthropic-version>'
request["X-Api-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"max_tokens\": 123,\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {}\n }\n ],\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tool_choice\": {},\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"inference_geo\": \"<string>\",\n \"output_config\": {\n \"effort\": \"<string>\",\n \"format\": {\n \"schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"type\": \"<string>\"\n }\n },\n \"service_tier\": \"<string>\",\n \"system\": {},\n \"temperature\": 123,\n \"stream\": true,\n \"thinking\": {\n \"budget_tokens\": 123,\n \"type\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"tools\": [\n {\n \"input_schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"allowed_callers\": [\n \"<string>\"\n ],\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"defer_loading\": true,\n \"eager_input_streaming\": true,\n \"input_examples\": [\n {\n \"key\": {}\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"strict\": true\n }\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"container\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"stop_reason": "<string>",
"stop_sequence": "<string>",
"stop_details": {
"type": "<string>",
"category": "<string>",
"explanation": "<string>"
},
"id": "<string>",
"type": "<string>",
"role": "<string>",
"content": [
{}
],
"model": "<string>",
"container": {
"expires_at": "<string>",
"id": "<string>"
},
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123,
"cache_creation": {
"ephemeral_5m_input_tokens": 123,
"ephemeral_1h_input_tokens": 123
},
"inference_geo": "<string>",
"output_tokens_details": {
"thinking_tokens": 123
},
"server_tool_use": {
"web_search_requests": 123,
"web_fetch_requests": 123
},
"service_tier": "<string>"
}
}Claude format
Create Claude messages compatible with the Anthropic Messages protocol, supporting streaming and non-streaming responses
curl --request POST \
--url https://api.example.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--header 'anthropic-version: <anthropic-version>' \
--data '
{
"max_tokens": 123,
"model": "<string>",
"messages": [
{
"content": {}
}
],
"top_p": 123,
"top_k": 123,
"stop_sequences": [
"<string>"
],
"tool_choice": {},
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"inference_geo": "<string>",
"output_config": {
"effort": "<string>",
"format": {
"schema": [
[
[
{}
]
]
],
"type": "<string>"
}
},
"service_tier": "<string>",
"system": {},
"temperature": 123,
"stream": true,
"thinking": {
"budget_tokens": 123,
"type": "<string>",
"display": "<string>"
},
"tools": [
{
"input_schema": [
[
[
{}
]
]
],
"allowed_callers": [
"<string>"
],
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"defer_loading": true,
"eager_input_streaming": true,
"input_examples": [
{
"key": {}
}
],
"name": "<string>",
"description": "<string>",
"type": "<string>",
"strict": true
}
],
"metadata": {
"user_id": "<string>"
},
"container": "<string>"
}
'import requests
url = "https://api.example.com/v1/messages"
payload = {
"max_tokens": 123,
"model": "<string>",
"messages": [{ "content": {} }],
"top_p": 123,
"top_k": 123,
"stop_sequences": ["<string>"],
"tool_choice": {},
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"inference_geo": "<string>",
"output_config": {
"effort": "<string>",
"format": {
"schema": [[[{}]]],
"type": "<string>"
}
},
"service_tier": "<string>",
"system": {},
"temperature": 123,
"stream": True,
"thinking": {
"budget_tokens": 123,
"type": "<string>",
"display": "<string>"
},
"tools": [
{
"input_schema": [[[{}]]],
"allowed_callers": ["<string>"],
"cache_control": {
"type": "<string>",
"ttl": "<string>"
},
"defer_loading": True,
"eager_input_streaming": True,
"input_examples": [{ "key": {} }],
"name": "<string>",
"description": "<string>",
"type": "<string>",
"strict": True
}
],
"metadata": { "user_id": "<string>" },
"container": "<string>"
}
headers = {
"anthropic-version": "<anthropic-version>",
"X-Api-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'anthropic-version': '<anthropic-version>',
'X-Api-Key': '<x-api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
max_tokens: 123,
model: '<string>',
messages: [{content: {}}],
top_p: 123,
top_k: 123,
stop_sequences: ['<string>'],
tool_choice: {},
cache_control: {type: '<string>', ttl: '<string>'},
inference_geo: '<string>',
output_config: {effort: '<string>', format: {schema: [[[{}]]], type: '<string>'}},
service_tier: '<string>',
system: {},
temperature: 123,
stream: true,
thinking: {budget_tokens: 123, type: '<string>', display: '<string>'},
tools: [
{
input_schema: [[[{}]]],
allowed_callers: ['<string>'],
cache_control: {type: '<string>', ttl: '<string>'},
defer_loading: true,
eager_input_streaming: true,
input_examples: [{key: {}}],
name: '<string>',
description: '<string>',
type: '<string>',
strict: true
}
],
metadata: {user_id: '<string>'},
container: '<string>'
})
};
fetch('https://api.example.com/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'max_tokens' => 123,
'model' => '<string>',
'messages' => [
[
'content' => [
]
]
],
'top_p' => 123,
'top_k' => 123,
'stop_sequences' => [
'<string>'
],
'tool_choice' => [
],
'cache_control' => [
'type' => '<string>',
'ttl' => '<string>'
],
'inference_geo' => '<string>',
'output_config' => [
'effort' => '<string>',
'format' => [
'schema' => [
[
[
[
]
]
]
],
'type' => '<string>'
]
],
'service_tier' => '<string>',
'system' => [
],
'temperature' => 123,
'stream' => true,
'thinking' => [
'budget_tokens' => 123,
'type' => '<string>',
'display' => '<string>'
],
'tools' => [
[
'input_schema' => [
[
[
[
]
]
]
],
'allowed_callers' => [
'<string>'
],
'cache_control' => [
'type' => '<string>',
'ttl' => '<string>'
],
'defer_loading' => true,
'eager_input_streaming' => true,
'input_examples' => [
[
'key' => [
]
]
],
'name' => '<string>',
'description' => '<string>',
'type' => '<string>',
'strict' => true
]
],
'metadata' => [
'user_id' => '<string>'
],
'container' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <x-api-key>",
"anthropic-version: <anthropic-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/messages"
payload := strings.NewReader("{\n \"max_tokens\": 123,\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {}\n }\n ],\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tool_choice\": {},\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"inference_geo\": \"<string>\",\n \"output_config\": {\n \"effort\": \"<string>\",\n \"format\": {\n \"schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"type\": \"<string>\"\n }\n },\n \"service_tier\": \"<string>\",\n \"system\": {},\n \"temperature\": 123,\n \"stream\": true,\n \"thinking\": {\n \"budget_tokens\": 123,\n \"type\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"tools\": [\n {\n \"input_schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"allowed_callers\": [\n \"<string>\"\n ],\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"defer_loading\": true,\n \"eager_input_streaming\": true,\n \"input_examples\": [\n {\n \"key\": {}\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"strict\": true\n }\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"container\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("anthropic-version", "<anthropic-version>")
req.Header.Add("X-Api-Key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/messages")
.header("anthropic-version", "<anthropic-version>")
.header("X-Api-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"max_tokens\": 123,\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {}\n }\n ],\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tool_choice\": {},\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"inference_geo\": \"<string>\",\n \"output_config\": {\n \"effort\": \"<string>\",\n \"format\": {\n \"schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"type\": \"<string>\"\n }\n },\n \"service_tier\": \"<string>\",\n \"system\": {},\n \"temperature\": 123,\n \"stream\": true,\n \"thinking\": {\n \"budget_tokens\": 123,\n \"type\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"tools\": [\n {\n \"input_schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"allowed_callers\": [\n \"<string>\"\n ],\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"defer_loading\": true,\n \"eager_input_streaming\": true,\n \"input_examples\": [\n {\n \"key\": {}\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"strict\": true\n }\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"container\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["anthropic-version"] = '<anthropic-version>'
request["X-Api-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"max_tokens\": 123,\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {}\n }\n ],\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tool_choice\": {},\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"inference_geo\": \"<string>\",\n \"output_config\": {\n \"effort\": \"<string>\",\n \"format\": {\n \"schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"type\": \"<string>\"\n }\n },\n \"service_tier\": \"<string>\",\n \"system\": {},\n \"temperature\": 123,\n \"stream\": true,\n \"thinking\": {\n \"budget_tokens\": 123,\n \"type\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"tools\": [\n {\n \"input_schema\": [\n [\n [\n {}\n ]\n ]\n ],\n \"allowed_callers\": [\n \"<string>\"\n ],\n \"cache_control\": {\n \"type\": \"<string>\",\n \"ttl\": \"<string>\"\n },\n \"defer_loading\": true,\n \"eager_input_streaming\": true,\n \"input_examples\": [\n {\n \"key\": {}\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"strict\": true\n }\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"container\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"stop_reason": "<string>",
"stop_sequence": "<string>",
"stop_details": {
"type": "<string>",
"category": "<string>",
"explanation": "<string>"
},
"id": "<string>",
"type": "<string>",
"role": "<string>",
"content": [
{}
],
"model": "<string>",
"container": {
"expires_at": "<string>",
"id": "<string>"
},
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123,
"cache_creation": {
"ephemeral_5m_input_tokens": 123,
"ephemeral_1h_input_tokens": 123
},
"inference_geo": "<string>",
"output_tokens_details": {
"thinking_tokens": 123
},
"server_tool_use": {
"web_search_requests": 123,
"web_fetch_requests": 123
},
"service_tier": "<string>"
}
}Features
- Supports both streaming (SSE) and non-streaming response modes
- Supports multimodal content (text, images, etc.)
- Supports tool use
- Supports thinking/reasoning mode configuration
- Supports cache control optimization
Use cases
Suitable for scenarios requiring interaction with Claude models, including:- Single-turn or multi-turn conversations
- Structured output (JSON Schema)
- Tool calling and function execution
- Code execution and container reuse
Authentication
Include theAuthorization header in the format Bearer YOUR_API_KEY.
anthropic-version header, e.g. 2023-06-01.Quick example
import requests
url = "https://api.haitoken.ai/v1/messages"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"anthropic-version": "2023-06-01"
}
data = {
"model": "claude-sonnet-4-0",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, please introduce yourself"}
]
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
const response = await fetch('https://api.haitoken.ai/v1/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
'anthropic-version': '2023-06-01'
},
body: JSON.stringify({
model: 'claude-sonnet-4-0',
max_tokens: 1024,
messages: [
{ role: 'user', content: 'Hello, please introduce yourself' }
]
})
});
const data = await response.json();
console.log(data);
curl -X POST 'https://api.haitoken.ai/v1/messages' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
-d '{
"model": "claude-sonnet-4-0",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, please introduce yourself"}
]
}'
Headers
"2023-06-01"
"YOUR_API_KEY"
Body
Maximum number of output tokens (required)
Model name, e.g. claude-sonnet-4-0, claude-opus-4-0, etc.
List of messages
Show child attributes
Show child attributes
Nucleus sampling, 0-1
Top-K sampling
Stop sequences
Tool choice configuration, can be a String or ClaudeToolChoice object
Top-level cache control configuration Automatically applies a cache_control marker to the last cacheable block in the request
Show child attributes
Show child attributes
Inference geographic region Specifies the geographic region for inference processing. If not specified, uses the workspace's default_inference_geo
Output configuration Configures model output format options, such as effort level and structured output format
Show child attributes
Show child attributes
Service tier Determines whether to use priority capacity (if available) or standard capacity Possible values: "auto" / "standard_only"
System instruction, can be a String or List
Sampling temperature, 0.0-1.0
Whether to enable streaming output
Thinking/reasoning mode configuration
Show child attributes
Show child attributes
List of tool definitions
Show child attributes
Show child attributes
Metadata
Show child attributes
Show child attributes
Container identifier, used for cross-request container reuse (code execution tool)
Response
Claude Messages API non-streaming response Reference: https://platform.claude.com/docs/en/api/messages/create
Stop reason: end_turn / max_tokens / stop_sequence / tool_use / pause_turn / refusal Always output in the message_start event (even when null)
Stop sequence that was matched (can be null) Always output in the message_start event (even when null)
Refusal stop details Structured information returned when the model refuses due to safety policy
Show child attributes
Show child attributes
Message ID (msg_ prefix)
Object type, always "message"
Role, always "assistant"
List of response content blocks
Model name (the actual model that completed the task)
Container information Container identifier for the code execution tool, used for cross-request reuse
Show child attributes
Show child attributes
Usage statistics
Show child attributes
Show child attributes