Anthropic Messages API reference for every model
The Anthropic Messages reference: native for Claude models, usable with GPT and Gemini, with every parameter, thinking, caching and errors.
On this page
The Anthropic format. With Claude models your request is passed on in its own format, without conversion. GPT and Gemini models work here too, with the differences shown in the parameters table.
https:/ / api.5abeer.ai/ v1/ messagesAuthentication#
Send your key in the x-api-key header, with anthropic-version: 2023-06-01. The base URL has no /v1: the libraries add the path themselves. With the official Anthropic library, set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY; see Base URLs. Tools such as Claude Code send the key as Authorization: Bearer, and that works too.
Quick example#
curl --request POST "https://api.5abeer.ai/v1/messages" \
--header "x-api-key: $KHABEER_API_KEY" \
--header "Content-Type: application/json" \
--header "anthropic-version: 2023-06-01" \
--data '{"model":"claude-sonnet-5.5","max_tokens":512,"messages":[{"role":"user","content":"Write a product idea in one sentence."}]}'{
"id": "msg_01Xh7",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5.5",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 21,
"output_tokens": 12
}
}The key is read from KHABEER_API_KEY, so it never appears in your code.
Parameters#
Each row shows what happens to the parameter for each model family: supported means we pass it to the model; ignored means the request is accepted but the parameter has no effect, so don't rely on it; rejected means the request fails. We measured these against the gateway itself.
messagesarrayrequiredThe conversation with the roles user and assistant; content is text or blocks, images and tool results included.ClaudeSupportedGPTSupportedGeminiSupportedmax_tokensintegerrequiredThe maximum number of output tokens.ClaudeSupportedGPTIgnoredGeminiSupportedsystemstring | arraySystem instructions, as text or blocks.ClaudeSupportedGPTSupportedGeminiSupportedtemperaturenumberHow random the reply is.ClaudeSupportedGPTIgnoredGeminiSupportedtop_pnumberSample only from the most likely tokens.ClaudeSupportedGPTIgnoredGeminiSupportedtop_kintegerSample only from a fixed number of top options.ClaudeSupportedGPTIgnoredGeminiIgnoredstop_sequencesarrayText that ends the reply.ClaudeSupportedGPTIgnoredGeminiSupportedstreambooleanSend the reply as a series of events. See Streaming.ClaudeSupportedGPTSupportedGeminiSupportedtool_choiceobjectauto, any, none or one named tool.ClaudeSupportedGPTSupportedGeminiIgnoredthinkingobjectTurns on extended thinking with a budget_tokens budget.ClaudeSupportedGPTIgnoredGeminiIgnoredoutput_configobjecteffort sets how hard the model thinks: low, medium or high.ClaudeSupportedGPTSupportedGeminiIgnoredcache_controlobjectOn a content block: the cache marker. See Prompt caching.ClaudeSupportedGPTIgnoredGeminiIgnoredmetadataobjectuser_id for the end user's id in your system.ClaudeSupportedGPTIgnoredGeminiIgnoredCount tokens#
POST /v1/messages/count_tokens takes the same body without max_tokens and returns input_tokens without calling the model. When counting isn't available for the model you get 404 with not_found_error, so treat the count as optional in your code.
Images in the request#
Add an image block to the content of a user message, with source of type base64 and its media_type, next to a text block, as in the image example.
Streaming#
With "stream": true the reply arrives as named events: message_start, then for each block content_block_start, content_block_delta and content_block_stop, then message_delta with the stop reason and the output usage, and message_stop. A failure mid-way arrives as an error event with the code. Details in Streaming.
Examples#
Streaming#
curl -N https://api.5abeer.ai/v1/messages \
-H "x-api-key: $KHABEER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Write a product idea in one sentence."
}
],
"stream": true
}'event: message_start
data: {"type":"message_start","message":{"id":"msg_p8a01","type":"message","role":"assistant","model":"claude-opus-5","content":[],"stop_reason":null,"usage":{"input_tokens":21,"output_tokens":1}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Lumen Notes: "}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"a notebook that turns voice memos "}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"into tidy to-do lists."}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":18}}
event: message_stop
data: {"type":"message_stop"}Calling a tool#
curl https://api.5abeer.ai/v1/messages \
-H "x-api-key: $KHABEER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get the weather for a city",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
],
"tool_choice": {
"type": "auto"
},
"messages": [
{
"role": "user",
"content": "What is the weather in Cairo?"
}
]
}'{
"id": "msg_p8a01",
"type": "message",
"role": "assistant",
"model": "claude-opus-5",
"content": [
{
"type": "tool_use",
"id": "toolu_p8a01",
"name": "get_weather",
"input": {
"city": "Cairo"
}
}
],
"stop_reason": "tool_use",
"stop_sequence": null,
"usage": {
"input_tokens": 21,
"output_tokens": 18
}
}Extended thinking#
curl https://api.5abeer.ai/v1/messages \
-H "x-api-key: $KHABEER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5",
"max_tokens": 4096,
"thinking": {
"type": "enabled",
"budget_tokens": 2048
},
"messages": [
{
"role": "user",
"content": "Plan a three-step launch for a note-taking app."
}
]
}'{
"id": "msg_p8a01",
"type": "message",
"role": "assistant",
"model": "claude-opus-5",
"content": [
{
"type": "thinking",
"thinking": "Three steps: audience, channel, timing.",
"signature": "sig_p8a"
},
{
"type": "text",
"text": "Lumen Notes: a notebook that turns voice memos into tidy to-do lists."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 21,
"output_tokens": 18
}
}Reasoning effort with a GPT model#
curl https://api.5abeer.ai/v1/messages \
-H "x-api-key: $KHABEER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"max_tokens": 1024,
"output_config": {
"effort": "low"
},
"messages": [
{
"role": "user",
"content": "Write a product idea in one sentence."
}
]
}'{
"id": "msg_p8a01",
"type": "message",
"role": "assistant",
"model": "gpt-5.6-sol",
"content": [
{
"type": "text",
"text": "Lumen Notes: a notebook that turns voice memos into tidy to-do lists."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 21,
"output_tokens": 18
}
}Caching long instructions#
curl https://api.5abeer.ai/v1/messages \
-H "x-api-key: $KHABEER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5",
"max_tokens": 512,
"system": [
{
"type": "text",
"text": "You are the support assistant for Lumen Notes. Product manual: ...",
"cache_control": {
"type": "ephemeral"
}
}
],
"messages": [
{
"role": "user",
"content": "How do I export a note?"
}
]
}'{
"id": "msg_p8a01",
"type": "message",
"role": "assistant",
"model": "claude-opus-5",
"content": [
{
"type": "text",
"text": "Lumen Notes: a notebook that turns voice memos into tidy to-do lists."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 21,
"output_tokens": 18
}
}An image with the question#
curl https://api.5abeer.ai/v1/messages \
-H "x-api-key: $KHABEER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
}
},
{
"type": "text",
"text": "What is in this image?"
}
]
}
]
}'{
"id": "msg_p8a01",
"type": "message",
"role": "assistant",
"model": "claude-opus-5",
"content": [
{
"type": "text",
"text": "Lumen Notes: a notebook that turns voice memos into tidy to-do lists."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 21,
"output_tokens": 18
}
}Sampling settings#
curl https://api.5abeer.ai/v1/messages \
-H "x-api-key: $KHABEER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-pro",
"max_tokens": 300,
"system": "Answer in one sentence.",
"temperature": 0.4,
"top_p": 0.9,
"top_k": 40,
"stop_sequences": [
"END"
],
"metadata": {
"user_id": "user-123"
},
"messages": [
{
"role": "user",
"content": "Write a product idea."
}
]
}'{
"id": "msg_p8a01",
"type": "message",
"role": "assistant",
"model": "gemini-3.1-pro",
"content": [
{
"type": "text",
"text": "Lumen Notes: a notebook that turns voice memos into tidy to-do lists."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 21,
"output_tokens": 18
}
}The request above was run on the local test stack on 2026-10-02; the reply shows the shape, and its text is an example.
Errors#
Errors come in Anthropic's shape, "type": "error" with the details in error, except the key, balance and limit checks, which answer {"code", "message"}. The common codes are the same as for Chat Completions; the shapes and the codes raised while serving the request are in Limits and error codes.
Models for this format#
Claude Sonnet 5.5DefaultInput$0.60Output$3Context1M
Claude Opus 5.5Input$1.20Output$6Context1M
Claude Fable 5.1Input$3Output$15Context—
Claude Fable 5Input$3Output$15Context1M
Claude Opus 4.6Input$1.50Output$7.50Context1M
Claude Opus 4.7Input$1.50Output$7.50Context1M
Official price from the provider's page, checked October 19, 2026.
All models and pricesGPT and Gemini models work here too; see the models list.
Was this page helpful?