curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, tell me about yourself"
}
]
}'
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"system": "You are a professional coding assistant specializing in Python and Go.",
"messages": [
{
"role": "user",
"content": "Write a quicksort in Python"
}
]
}'
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"stream": true,
"messages": [
{
"role": "user",
"content": "Explain what recursion is"
}
]
}'
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, tell me about yourself"}
]
)
print(message.content[0].text)
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="You are a professional coding assistant specializing in Python and Go.",
messages=[
{"role": "user", "content": "Write a quicksort in Python"}
]
)
print(message.content[0].text)
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain what recursion is"}
]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "your-ToAPIs-key",
baseURL: "https://toapis.com",
});
const message = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, tell me about yourself" }],
});
console.log(message.content[0].text);
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "your-ToAPIs-key",
baseURL: "https://toapis.com",
});
const stream = await client.messages.stream({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain what recursion is" }],
});
for await (const chunk of stream) {
if (
chunk.type === "content_block_delta" &&
chunk.delta.type === "text_delta"
) {
process.stdout.write(chunk.delta.text);
}
}
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm Claude, an AI assistant made by Anthropic. I can help with questions, analysis, coding, writing, and more. How can I help you today?"
}
],
"model": "claude-sonnet-4-6",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 12,
"output_tokens": 35
}
}
data: {"type":"message_start","message":{"id":"msg_01abc","type":"message","role":"assistant","content":[],"model":"claude-sonnet-4-6","stop_reason":null,"usage":{"input_tokens":12,"output_tokens":0}}}
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"! I'm Claude"}}
data: {"type":"content_block_stop","index":0}
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":35}}
data: {"type":"message_stop"}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "messages: field required"
}
}
{
"type": "error",
"error": {
"type": "authentication_error",
"message": "Invalid API key"
}
}
{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "Rate limit exceeded"
}
}
Anthropic Format
Anthropic Messages API
Chat with Claude models using the native Anthropic Messages API format
POST
/
v1
/
messages
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, tell me about yourself"
}
]
}'
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"system": "You are a professional coding assistant specializing in Python and Go.",
"messages": [
{
"role": "user",
"content": "Write a quicksort in Python"
}
]
}'
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"stream": true,
"messages": [
{
"role": "user",
"content": "Explain what recursion is"
}
]
}'
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, tell me about yourself"}
]
)
print(message.content[0].text)
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="You are a professional coding assistant specializing in Python and Go.",
messages=[
{"role": "user", "content": "Write a quicksort in Python"}
]
)
print(message.content[0].text)
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain what recursion is"}
]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "your-ToAPIs-key",
baseURL: "https://toapis.com",
});
const message = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, tell me about yourself" }],
});
console.log(message.content[0].text);
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "your-ToAPIs-key",
baseURL: "https://toapis.com",
});
const stream = await client.messages.stream({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain what recursion is" }],
});
for await (const chunk of stream) {
if (
chunk.type === "content_block_delta" &&
chunk.delta.type === "text_delta"
) {
process.stdout.write(chunk.delta.text);
}
}
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm Claude, an AI assistant made by Anthropic. I can help with questions, analysis, coding, writing, and more. How can I help you today?"
}
],
"model": "claude-sonnet-4-6",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 12,
"output_tokens": 35
}
}
data: {"type":"message_start","message":{"id":"msg_01abc","type":"message","role":"assistant","content":[],"model":"claude-sonnet-4-6","stop_reason":null,"usage":{"input_tokens":12,"output_tokens":0}}}
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"! I'm Claude"}}
data: {"type":"content_block_stop","index":0}
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":35}}
data: {"type":"message_stop"}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "messages: field required"
}
}
{
"type": "error",
"error": {
"type": "authentication_error",
"message": "Invalid API key"
}
}
{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "Rate limit exceeded"
}
}
- Native Anthropic Messages API format
- Drop-in compatible with the official Anthropic SDK (Python / JavaScript) — just change
base_url - Supports streaming (SSE)
- Supports multi-turn conversations, system prompts, vision input, and tool use
If you are already using the OpenAI SDK, use the OpenAI-compatible endpoint instead.
If you are using the Anthropic SDK or Claude Code, this endpoint is recommended.
Authorizations
string
Bearer token authentication for direct HTTP calls
Authorization: Bearer YOUR_API_KEY
string
API key authentication, compatible with the Anthropic SDK
x-api-key: YOUR_API_KEY
string
default:"2023-06-01"
Anthropic API version. The Anthropic SDK sets this automatically.Recommended:
2023-06-01Body
string
required
Model nameAll Claude models are supported, for example:
claude-opus-4-6claude-sonnet-4-6claude-haiku-4-5
object[]
required
Conversation messages in chronological order. Only
user and assistant roles are allowed here — use the top-level system field for system prompts.Show messages[n]
Show messages[n]
string
required
Message role:
user or assistantstring | object[]
required
Message content as a string or an array of content blocks
Show Content block
Show Content block
string
required
Content type:
text or imagestring
Text content. Required when
type is text.integer
required
Maximum number of tokens to generate
- Claude Sonnet 4-6: up to
64000 - Claude Opus 4-6: up to
32000
string | object[]
System prompt, set at the top level (not inside
messages)Accepts a plain string or an array of content blocks.boolean
default:false
Enable streaming output (Server-Sent Events)
true: tokens streamed incrementally following the Anthropic SSE event formatfalse: full response returned at once
number
default:1
Sampling temperature controlling output randomnessRange:
0 – 1number
Nucleus sampling thresholdRange:
0 – 1. Avoid setting both temperature and top_p simultaneously.string[]
Stop sequences — generation stops when any of these strings is produced
Response
string
Unique identifier for the request, prefixed with
msg_string
Object type, always
messagestring
Response role, always
assistantobject[]
List of generated content blocks
content[].type: content type, typicallytextcontent[].text: generated text
string
The model that handled the request
string
Reason generation stopped
end_turn: model finished naturallymax_tokens:max_tokenslimit reachedstop_sequence: a stop sequence was triggered
object
Token usage for this request
usage.input_tokens: input token countusage.output_tokens: output token count
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, tell me about yourself"
}
]
}'
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"system": "You are a professional coding assistant specializing in Python and Go.",
"messages": [
{
"role": "user",
"content": "Write a quicksort in Python"
}
]
}'
curl --request POST \
--url https://toapis.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"stream": true,
"messages": [
{
"role": "user",
"content": "Explain what recursion is"
}
]
}'
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, tell me about yourself"}
]
)
print(message.content[0].text)
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="You are a professional coding assistant specializing in Python and Go.",
messages=[
{"role": "user", "content": "Write a quicksort in Python"}
]
)
print(message.content[0].text)
import anthropic
client = anthropic.Anthropic(
api_key="your-ToAPIs-key",
base_url="https://toapis.com"
)
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain what recursion is"}
]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "your-ToAPIs-key",
baseURL: "https://toapis.com",
});
const message = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, tell me about yourself" }],
});
console.log(message.content[0].text);
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "your-ToAPIs-key",
baseURL: "https://toapis.com",
});
const stream = await client.messages.stream({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain what recursion is" }],
});
for await (const chunk of stream) {
if (
chunk.type === "content_block_delta" &&
chunk.delta.type === "text_delta"
) {
process.stdout.write(chunk.delta.text);
}
}
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm Claude, an AI assistant made by Anthropic. I can help with questions, analysis, coding, writing, and more. How can I help you today?"
}
],
"model": "claude-sonnet-4-6",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 12,
"output_tokens": 35
}
}
data: {"type":"message_start","message":{"id":"msg_01abc","type":"message","role":"assistant","content":[],"model":"claude-sonnet-4-6","stop_reason":null,"usage":{"input_tokens":12,"output_tokens":0}}}
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"! I'm Claude"}}
data: {"type":"content_block_stop","index":0}
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":35}}
data: {"type":"message_stop"}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "messages: field required"
}
}
{
"type": "error",
"error": {
"type": "authentication_error",
"message": "Invalid API key"
}
}
{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "Rate limit exceeded"
}
}
⌘I