BeeRoute logoBeeRoute.

Home / Docs / Claude Native API (Anthropic Messages)

Claude Native API (Anthropic Messages)

Official docs: Create a Message | Streaming | Thinking | Prompt caching | Errors

๐Ÿ“ Introduction

The Messages API is Anthropic's official conversation endpoint: you send a structured list of input messages (text, images, PDFs, tool results, and so on), and the model generates the next message in the conversation. The API is stateless, so multi-turn conversations must resend the full history on every request. BeeRoute relays this endpoint in Anthropic's native format, so the official SDKs and tools such as Claude Code work by simply pointing their base URL at BeeRoute.

This page covers the most common fields and usage. For the exhaustive field list, see the official reference.

Quick Notes

ItemDetails
EndpointPOST https://beeroute.ai/v1/messages
Base URLhttps://beeroute.ai (the Anthropic base URL to enter in SDKs, Claude Code and similar tools; do not append /v1)
Authenticationx-api-key: $API_KEY or Authorization: Bearer $API_KEY (either one)
Version headeranthropic-version: 2023-06-01 (required; see the version notes below)
Content typecontent-type: application/json
Get a keyhttps://beeroute.ai/keys
Models and priceshttps://beeroute.ai/modellist/

All curl examples below read the key from the $API_KEY environment variable. Set it first:

export API_KEY=sk-xxx

For direct API calls, use a key in the default group. Keys in the ClaudeCode group are meant for the Claude Code client only.

BeeRoute does not offer the token counting endpoint (POST /v1/messages/count_tokens returns 404), the Files API, or the Message Batches API.

About API versions: Anthropic's newest API version is 2026-10-21; the earlier 2023-06-01 is still widely used. BeeRoute forwards your anthropic-version header unchanged. The examples on this page use 2023-06-01, which has the broadest compatibility (it is also what Claude Code sends). Whether 2026-10-21 works depends on the upstream channel; if you get an error, switch back to 2023-06-01. Breaking changes in 2026-10-21 compared with 2023-06-01 (migration guide):

  • temperature, top_p, and top_k are removed: sending any of them returns a 400 on every model, even at the default value;
  • a document block placed directly in an assistant message returns a 400;
  • a text block with a non-empty citations array in a user message (including inside a search_result block) returns a 400.

Also note that the new major versions of the official SDKs (Python anthropic 2.0.0 and later, TypeScript @anthropic-ai/sdk 1.0.0 and later) send 2026-10-21 by default and send the key as Authorization: Bearer. See the "Python SDK" section below.

Available Models

Claude models currently available on BeeRoute:

claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5, claude-fable-5-2, claude-opus-5, claude-sonnet-5

Older versions (claude-fable-5-1, claude-fable-5, claude-opus-4-8, claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5-20251001) can still be called for existing integrations. New projects should use the models above.

The examples on this page use claude-sonnet-5-5. Models differ in their support for thinking, sampling parameters, prefill, forced tool use, and so on; each difference is noted below.

๐Ÿ’ก Request Examples

Basic Text Conversation โœ…

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, please introduce yourself in one sentence."}
    ]
  }'

Response example:

{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5-5",
  "content": [
    {
      "type": "text",
      "text": "Hi! I'm Claude, an AI assistant made by Anthropic that can help with writing, coding, analysis, and answering all kinds of questions."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 19,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
    "output_tokens": 32,
    "service_tier": "standard"
  }
}

Authorization: Bearer $API_KEY works the same as x-api-key: $API_KEY; the remaining examples do not repeat this. Response fields may be added as the upstream API evolves, so read fields by name and do not rely on their order.

System Prompt โœ…

Put the system prompt in the top-level system field. It can be a string or an array of text blocks (the array form is required if you want to put cache_control on the system prompt).

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "system": "You are a senior technical editor. Answer concisely and accurately.",
    "messages": [
      {"role": "user", "content": "Explain what idempotency means."}
    ]
  }'

Multi-turn Conversation โœ…

The API is stateless: every request must include the full history, with user and assistant turns alternating and the last message from user.

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello there."},
      {"role": "assistant", "content": "Hi! How can I help you today?"},
      {"role": "user", "content": "Can you explain large language models in plain English?"}
    ]
  }'

Ending the conversation with an assistant message (prefill, which pre-writes the start of the reply) returns a 400 on Claude 4.6 and later models. Among BeeRoute models, only claude-haiku-4-5-20251001 supports prefill. On other models, constrain the format with the system prompt or with structured outputs (see "Structured Output" below).

Image Understanding โœ…

Images are sent as image content blocks with either a base64 or a url source. Supported formats: image/jpeg, image/png, image/gif, image/webp. Anthropic recommends placing images before the text.

Base64 image:

IMG_B64=$(base64 < image.jpg | tr -d '\n')

cat > request.json <<EOF
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image",
          "source": {"type": "base64", "media_type": "image/jpeg", "data": "$IMG_B64"}
        },
        {"type": "text", "text": "What is in this image?"}
      ]
    }
  ]
}
EOF

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  --data @request.json

URL image:

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {"type": "url", "url": "https://platform.claude.com/docs/images/vision-example.jpg"}
          },
          {"type": "text", "text": "Describe this image."}
        ]
      }
    ]
  }'

Base64 data must not contain line breaks and must not include a data:image/jpeg;base64, prefix. Official limits: at most 8000x8000 px and 10 MB (base64-encoded) per image; a request with more than 20 images applies a stricter per-image dimension limit. URL sources must be publicly reachable. Some upstream channels accept only base64 sources, so switch to base64 if a URL source is rejected.

PDF Documents โœ…

PDFs are sent as document content blocks with a url or base64 source (media_type is application/pdf). Official limits: at most 600 pages per request (100 pages for models with a context window under 1M tokens); the first-party Anthropic API caps the request body at 128 MB, and other platforms and upstream channels may be lower.

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 2048,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "url",
              "url": "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
            }
          },
          {"type": "text", "text": "Summarize the main points of this document in three bullets."}
        ]
      }
    ]
  }'

The base64 form (use it the same way as the image heredoc example above):

{
  "type": "document",
  "source": {
    "type": "base64",
    "media_type": "application/pdf",
    "data": "JVBERi0xLjQK..."
  },
  "title": "Quarterly report",
  "citations": {"enabled": true}
}

title, context, and citations are optional. With citations enabled, the answer is split into multiple text blocks that carry citation locations. citations cannot be combined with output_config.format.

Tool Use โœ…

Step 1: send a request with tool definitions

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get the current weather for a given city",
        "input_schema": {
          "type": "object",
          "properties": {
            "location": {"type": "string", "description": "City name, e.g. San Francisco"}
          },
          "required": ["location"]
        }
      }
    ],
    "messages": [
      {"role": "user", "content": "What is the weather like in San Francisco today?"}
    ]
  }'

Response example: when the model decides to call a tool, stop_reason is tool_use. claude-sonnet-5-5 has adaptive thinking on by default, so the response may contain a thinking block (thinking text is hidden by default: the thinking field is an empty string, but a signature is present).

{
  "id": "msg_01Aq9w938a90dw8q",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5-5",
  "content": [
    {"type": "thinking", "thinking": "", "signature": "EqQBCgIYAhIM1gbcDa9GJwZA2b3hGgxBdjrkzLoky3dl1pkiMOYds..."},
    {"type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_weather", "input": {"location": "San Francisco"}}
  ],
  "stop_reason": "tool_use",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 598,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 84
  }
}

Step 2: run the tool and send the result back as tool_result

Append the previous assistant content to the history unchanged (including the thinking block), then append a user message containing the tool_result, whose tool_use_id matches the tool_use.id from the previous step:

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "tools": [
      {"name": "get_weather", "description": "Get the current weather for a given city", "input_schema": {"type": "object", "properties": {"location": {"type": "string", "description": "City name, e.g. San Francisco"}}, "required": ["location"]}}
    ],
    "messages": [
      {"role": "user", "content": "What is the weather like in San Francisco today?"},
      {
        "role": "assistant",
        "content": [
          {"type": "thinking", "thinking": "", "signature": "EqQBCgIYAhIM1gbcDa9GJwZA2b3hGgxBdjrkzLoky3dl1pkiMOYds..."},
          {"type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_weather", "input": {"location": "San Francisco"}}
        ]
      },
      {
        "role": "user",
        "content": [
          {"type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "San Francisco: sunny, 18ยฐC, light westerly wind"}
        ]
      }
    ]
  }'

The model then returns the final answer (stop_reason is end_turn), for example "It is sunny in San Francisco today, around 18ยฐC with a light westerly wind.".

The signature in this example is a placeholder. A real request must send back the thinking / redacted_thinking blocks from the previous response exactly as received; modifying or reordering them returns a 400.

Tool use rules: the user message with the tool_result must come right after the matching tool_use; tool_result blocks go first in the content array, with any text after them; when the model returns several tool_use blocks at once, put all the tool_result blocks in a single user message; when a tool fails, return "is_error": true and describe the failure in content.

Streaming โœ…

With "stream": true, the API returns the response incrementally as SSE (Server-Sent Events).

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'

Response example:

event: message_start
data: {"type": "message_start", "message": {"id": "msg_01DsBEzYqFX4Xk3jvP4aSVGm", "type": "message", "role": "assistant", "content": [], "model": "claude-sonnet-5-5", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 8, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 1}}}

event: content_block_start
data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}

event: ping
data: {"type": "ping"}

event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello!"}}

event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": " How can I help you today?"}}

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": 12}}

event: message_stop
data: {"type": "message_stop"}

For the event order and delta types, see "Streaming Events" below. The usage in message_delta is cumulative, not incremental.

Thinking (Adaptive Thinking) โœ…

Claude 5 family models have adaptive thinking on by default: the model decides whether and how deeply to think, and output_config.effort controls the overall effort. These models hide the thinking text by default (display defaults to "omitted"); set "display": "summarized" to receive a thinking summary.

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 16000,
    "thinking": {"type": "adaptive", "display": "summarized"},
    "output_config": {"effort": "high"},
    "messages": [
      {"role": "user", "content": "What is the greatest common divisor of 1071 and 462?"}
    ]
  }'

Response example:

{
  "id": "msg_01QmTqXkV8sJZ3nF4b2yR9cH",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5-5",
  "content": [
    {
      "type": "thinking",
      "thinking": "Use the Euclidean algorithm: 1071 = 2 * 462 + 147; 462 = 3 * 147 + 21; 147 = 7 * 21. GCD = 21.",
      "signature": "WaUjzkypQ2mUEVM36O2Txu..."
    },
    {
      "type": "text",
      "text": "The greatest common divisor of 1071 and 462 is **21**."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 24,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 398,
    "output_tokens_details": {"thinking_tokens": 345}
  }
}
  • Thinking tokens are billed as output tokens and count toward max_tokens, even when the thinking text is not returned;
  • the returned thinking text is a summary, not the raw reasoning;
  • for each model's support of the thinking values, see the thinking table in the "Request" section below. The older claude-haiku-4-5-20251001 does not support adaptive and needs {"type": "enabled", "budget_tokens": 2048} (budget_tokens is at least 1024 and less than max_tokens); on Claude 4.7 and later models, enabled returns a 400.

Prompt Caching โœ…

Add cache_control to a content block, and the prefix up to and including that block (in the order tools โ†’ system โ†’ messages) is cached. Later requests that hit the cache are billed at the lower cache-read price; see the pricing page.

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "system": [
      {"type": "text", "text": "You are an assistant that analyzes legal documents."},
      {
        "type": "text",
        "text": "(Put the long text you reuse across requests here, for example the full text of a contract...)",
        "cache_control": {"type": "ephemeral"}
      }
    ],
    "messages": [
      {"role": "user", "content": "What are the breach-of-contract clauses in this contract?"}
    ]
  }'

The first request writes the cache, so usage.cache_creation_input_tokens is greater than 0. A request with the same prefix sent within 5 minutes reads the cache, so usage.cache_read_input_tokens is greater than 0:

{
  "usage": {
    "input_tokens": 16,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 3842,
    "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
    "output_tokens": 287
  }
}

Automatic caching: you can also add a single top-level cache_control, and the system places the cache breakpoint on the last cacheable block automatically. This suits multi-turn conversations:

{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "cache_control": {"type": "ephemeral", "ttl": "1h"},
  "system": "You are a helpful assistant.",
  "messages": [
    {"role": "user", "content": "Let us continue where we left off."}
  ]
}
  • ttl is "5m" (default) or "1h"; 1-hour cache writes cost more;
  • a request can have at most 4 cache breakpoints (top-level automatic caching uses one of them);
  • prefixes shorter than the minimum length are not cached, and no error is returned: 512 tokens for claude-opus-5-5, claude-opus-5, claude-sonnet-5-5, claude-haiku-5-5, and the Fable models; 1024 for claude-opus-4-8, claude-sonnet-5, claude-sonnet-4-6; 2048 for claude-opus-4-7; 4096 for claude-opus-4-6 and claude-haiku-4-5-20251001;
  • any byte change in the prefix (including changes to the tool list, the thinking configuration, or effort) invalidates the cache after that point.

Structured Output โœ…

Pass a JSON Schema in output_config.format, and the text block in the response is guaranteed to be JSON that matches the schema. The official supported-model list covers every Claude model on BeeRoute.

curl https://beeroute.ai/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Extract the key information from this email: John Smith (john@example.com) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."}
    ],
    "output_config": {
      "format": {
        "type": "json_schema",
        "schema": {
          "type": "object",
          "properties": {
            "name": {"type": "string"},
            "email": {"type": "string"},
            "plan_interest": {"type": "string"},
            "demo_requested": {"type": "boolean"}
          },
          "required": ["name", "email", "plan_interest", "demo_requested"],
          "additionalProperties": false
        }
      }
    }
  }'

content in the response:

[
  {
    "type": "text",
    "text": "{\"name\": \"John Smith\", \"email\": \"john@example.com\", \"plan_interest\": \"Enterprise\", \"demo_requested\": true}"
  }
]

Objects in the schema must set "additionalProperties": false. Recursive schemas, oneOf, and numeric and string-length constraints are not supported, among others. When stop_reason is refusal or max_tokens, the output may not match the schema. See Structured outputs for the full limits. The old top-level output_format parameter is deprecated.

Python SDK โœ…

pip install anthropic
import anthropic

client = anthropic.Anthropic(
    api_key="sk-xxx",                 # your BeeRoute key
    base_url="https://beeroute.ai",   # do not append /v1
)

message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude"}],
)
for block in message.content:  # with thinking on, a thinking block may come first
    if block.type == "text":
        print(block.text)

# Streaming
with client.messages.stream(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a short poem about autumn"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
  • Instead of passing arguments in code, you can set the environment variables ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL=https://beeroute.ai;
  • anthropic 2.0.0 and later send anthropic-version: 2026-10-21 by default and no longer offer the temperature / top_p / top_k parameters. If the upstream channel does not accept 2026-10-21, add default_headers={"anthropic-version": "2023-06-01"} when constructing the client;
  • the SDK requires streaming when max_tokens is large (above roughly 21,333). This is a client-side check; use client.messages.stream(...) with stream.get_final_message() to get the complete message.

๐Ÿ“ฎ Request

Endpoint

POST https://beeroute.ai/v1/messages

Headers

HeaderRequiredDescription
x-api-keyOne of the twoYour BeeRoute key. Anthropic now lists it as a legacy fallback for Authorization; it still works
AuthorizationOne of the twoBearer $API_KEY, the form Anthropic currently lists first
anthropic-versionYesAPI version. 2023-06-01 is recommended; whether the newest version 2026-10-21 works depends on the upstream channel
content-typeYesapplication/json
anthropic-betaNoEnables beta features. Put multiple betas in a single header, separated by commas, for example anthropic-beta: beta1,beta2; do not send the header more than once. Whether a beta takes effect depends on the upstream channel

Body Parameters

ParameterTypeRequiredDescription
modelstringYesModel name; see "Available Models" above
max_tokensintegerYesMaximum number of tokens to generate; minimum 0, maximum varies by model
messagesarrayYesInput messages, up to 100,000 per request
systemstring or arrayNoSystem prompt
thinkingobjectNoThinking configuration
output_configobjectNoOutput configuration: effort, format
toolsarrayNoTool definitions
tool_choiceobjectNoHow the model should use tools
cache_controlobjectNoTop-level automatic caching
stop_sequencesarray of stringNoCustom stop sequences
streambooleanNoWhether to stream the response as SSE
metadataobjectNoRequest metadata
temperature / top_p / top_knumber / number / integerNoSampling parameters, strictly limited on newer models; see below

model

The model ID, for example claude-sonnet-5-5. A model name that BeeRoute does not offer returns an error.

max_tokens

The maximum number of tokens to generate; the model may stop naturally before reaching it. The official minimum is 0: max_tokens: 0 writes the prompt cache without generating anything (cache pre-warming).

The maximum varies by model: 64K for claude-haiku-4-5-20251001 and 128K for the other BeeRoute models. When thinking is on, thinking tokens also count toward max_tokens.

BeeRoute replaces a missing or zero max_tokens with a per-model default, so cache pre-warming with max_tokens: 0 is not guaranteed to work here. Always set max_tokens explicitly to a value greater than 0.

messages

An array of input messages, each with a role and content.

role values:

  • user: user messages, also used to send tool_result blocks back;
  • assistant: earlier replies from the model. Consecutive messages with the same role are merged into one turn. Ending with an assistant message is prefill, which only claude-haiku-4-5-20251001 supports; other models return a 400;
  • system: a system instruction added partway through the conversation (it does not invalidate the cached prefix above it). Only some models support it: claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5, the Fable models, claude-opus-5, and claude-opus-4-8; on claude-sonnet-5 and the other models, use the top-level system field. Constraints: it cannot be the first message; it must come right after a user message (or an assistant message that ends in a server tool result) and before an assistant message, or be the last message; it cannot sit between a tool_use and its tool_result. Do not put untrusted text such as tool output or web content in a system message.

content is either a string or an array of content blocks. A string is shorthand for a single text block, so these two are equivalent:

{"role": "user", "content": "Hello, Claude"}
{"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}

For the available content blocks, see "Content Block Types" below.

system

The system prompt, which sets Claude's role, context, and rules. It can be a string or an array of text blocks:

{
  "system": [
    {
      "type": "text",
      "text": "You are a customer support assistant.",
      "cache_control": {"type": "ephemeral"}
    }
  ]
}

thinking

Controls the model's thinking. Available types:

ValueDescription
{"type": "adaptive"}Adaptive thinking: the model decides when and how much to think. Recommended. Optional display: "summarized" (returns a thinking summary) or "omitted" (the thinking field is an empty string; only the signature is kept)
{"type": "enabled", "budget_tokens": 2048}Manual extended thinking. budget_tokens is at least 1024 and less than max_tokens; display can be set too. Returns a 400 on Claude 4.7 and later models
{"type": "disabled"}Turns thinking off; some models reject it
{"type": "between_tools"}claude-sonnet-5-5 only: turns off up-front thinking, leaving only progress updates between tool calls. Only allowed at effort high or below, and accepts no other field

Support on BeeRoute models (from the official Thinking docs; "โ‰คhigh" means it works at effort low/medium/high and returns a 400 at xhigh/max):

ModelNo thinking fieldadaptiveenableddisabled
claude-opus-5-5, Fable modelsAdaptive thinkingSupported400400
claude-sonnet-5-5Adaptive thinkingSupported400400 (use between_tools, โ‰คhigh)
claude-haiku-5-5, claude-opus-5Adaptive thinkingSupported400Thinking off (โ‰คhigh)
claude-sonnet-5Adaptive thinkingSupported400Thinking off
claude-opus-4-8, claude-opus-4-7No thinkingSupported400Thinking off
claude-opus-4-6, claude-sonnet-4-6No thinkingSupportedSupported (deprecated)Thinking off
claude-haiku-4-5-20251001No thinking400SupportedThinking off

display defaults: "summarized" on claude-opus-4-6, claude-sonnet-4-6, and claude-haiku-4-5-20251001; "omitted" on the other models. display only controls whether thinking text is returned; it does not affect billing.

In multi-turn conversations and tool use, send the thinking / redacted_thinking blocks from responses back exactly as received (including signature); do not modify, drop, or reorder them. Also note:

  • keep sending them back when you switch models; thinking blocks the target model cannot read are ignored automatically and not billed;
  • claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5, claude-fable-5-2, and claude-fable-5-1 check the conversation prefix before each thinking block: if you change system, tools, or an earlier message, the thinking blocks after the change can cause a 400, so maintain the history append-only;
  • thinking blocks from claude-fable-5-2, claude-sonnet-5-5, and claude-haiku-5-5 only work in the upstream account that produced them. If a later request in the same conversation is handled by a different upstream account, those blocks are dropped silently (no error, but the model no longer sees its earlier reasoning).

output_config

FieldDescription
effortEffort level: low, medium, high, xhigh, max. Applies to all output tokens (text, tool calls, and thinking). Defaults to high; claude-opus-5-5 and claude-haiku-5-5 default to medium. xhigh is not supported on claude-opus-4-6 or claude-sonnet-4-6; claude-haiku-4-5-20251001 does not support effort
formatStructured output: {"type": "json_schema", "schema": {...}}; see the "Structured Output" example above

tools

An array of tool definitions. Fields of a custom tool:

FieldRequiredDescription
nameYesTool name, 1 to 128 characters, must match ^[a-zA-Z0-9_-]{1,128}$
descriptionNoTool description; strongly recommended, explaining what the tool does and what each parameter means
input_schemaYesJSON Schema for the tool input, with type set to object
strictNoWhen true, guarantees that the tool name and input generated by the model strictly match the schema
cache_controlNoSets a cache breakpoint at this tool
typeNo"custom" for custom tools, or omit it

Anthropic-defined tools (web search, web fetch, code execution, computer use, bash, text editor, and so on) change versions frequently, and their availability depends on the upstream channel, so this page does not list them. See the official Tool use docs.

tool_choice

ValueDescription
{"type": "auto"}Default. The model decides whether to call a tool
{"type": "any"}The model must call one of the tools
{"type": "tool", "name": "get_weather"}The model must call the named tool
{"type": "none"}The model may not call tools

auto, any, and tool accept "disable_parallel_tool_use": true: with auto, the model calls at most one tool; with any / tool, exactly one.

claude-opus-5-5, claude-sonnet-5-5, claude-fable-5-2, and claude-fable-5-1 do not support forced tool use: any and tool return a 400. Use auto with prompt instructions, strict: true, or structured outputs instead. With manual extended thinking (thinking.type is enabled), only auto and none are allowed.

cache_control

A cache breakpoint. It can be set at the top level of the request (automatic caching) or on a specific content block in tools, system, or messages:

{"type": "ephemeral", "ttl": "5m"}

type must be ephemeral; ttl is "5m" (default) or "1h". For usage and limits, see the "Prompt Caching" example above. Thinking blocks cannot carry cache_control directly.

stop_sequences

Custom stop sequences (an array of strings). When the model generates one of them, it stops, the response stop_reason is stop_sequence, and the stop_sequence field holds the matched sequence.

stream

When true, the response is streamed as SSE; see "Streaming Events" below. Streaming is recommended for long-running requests (large max_tokens, thinking on) to avoid timeouts.

metadata

FieldDescription
user_idExternal identifier of the end user, up to 512 characters. Use an opaque identifier such as a UUID or hash; do not include names, email addresses, phone numbers, or other personal information

temperature / top_p / top_k

Sampling parameters. temperature defaults to 1.0 and ranges from 0.0 to 1.0 (lower is more deterministic, higher is more varied); top_p is the nucleus sampling threshold; top_k samples only from the K most likely tokens.

On claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5, the Fable models, claude-opus-5, claude-sonnet-5, claude-opus-4-8, and claude-opus-4-7, any non-default value returns a 400; sending both temperature and top_p also returns a 400 (even at their defaults); and since the top_p default on these models is 0.99, top_p: 1 fails too. Do not send these three parameters to these models at all.

claude-opus-4-6, claude-sonnet-4-6, and claude-haiku-4-5-20251001 still accept sampling adjustments with version 2023-06-01, but with thinking on, temperature and top_k cannot be used and top_p must be between 0.95 and 1. With anthropic-version: 2026-10-21, sending any of the three parameters returns a 400 on every model.

Other Parameters

The official API also supports container, diagnostics, service_tier, speed, inference_geo, and other parameters, plus features that require the anthropic-beta header. BeeRoute does not forward service_tier, speed, or inference_geo by default; whether the others take effect depends on the upstream channel, so do not rely on them.

Content Block Types

The main content blocks available in messages[].content:

typePurposeMain fields
textTexttext (at least 1 character), cache_control, citations
imageImagesource: {"type": "base64", "media_type": "image/jpeg", "data": "..."} or {"type": "url", "url": "..."}; cache_control
documentDocumentsource: PDF as base64 (media_type is application/pdf) or url, plain text {"type": "text", "media_type": "text/plain", "data": "..."}, or custom content {"type": "content", "content": [...]}; optional title, context, citations, cache_control
search_resultSearch result (for citations)source, title, content (array of text blocks), citations
tool_useA tool call made by the model, sent back as historyid, name, input
tool_resultTool output, placed in a user messagetool_use_id (required), content (optional: a string or an array of text / image / search_result / document blocks), is_error
thinkingA thinking block, sent back as historythinking, signature; must be sent back unchanged
redacted_thinkingAn encrypted thinking block, sent back as historydata; must be sent back unchanged

image and document also accept a {"type": "file", "file_id": "..."} source, but it requires the Files API, which BeeRoute does not offer.

๐Ÿ“ฅ Response

Message Object

A successful non-streaming request returns a message object:

FieldTypeDescription
idstringUnique message ID; the format may change
typestringAlways message
rolestringAlways assistant
modelstringThe model that handled the request
contentarrayContent blocks generated by the model
stop_reasonstring or nullWhy generation stopped; see below
stop_sequencestring or nullThe matched custom stop sequence, otherwise null
stop_detailsobject or nullSet only when stop_reason is refusal: type (refusal), category (such as cyber, bio, frontier_llm, reasoning_extraction, general_harms, or null), explanation
usageobjectToken usage; see below

Common block types in content:

  • text: text in the text field; carries a citations array when citations are enabled;
  • thinking: a thinking block; thinking holds the summary (an empty string when display is omitted), and signature is used to verify the block when it is sent back;
  • redacted_thinking: a thinking block encrypted by the safety system; the data field is not readable and must be sent back unchanged;
  • tool_use: a tool call with id, name, and input (an object); parse input with a JSON parser rather than matching strings;
  • server_tool_use, web_search_tool_result, and similar: appear when Anthropic server tools are used.

stop_reason

ValueMeaning
end_turnThe model reached a natural stopping point
max_tokensHit max_tokens or the model maximum; the output may be truncated
stop_sequenceOne of the stop_sequences was generated
tool_useThe model called one or more tools; run them and send back tool_result blocks
pause_turnA long-running turn was paused (common with server tools); send the response back as-is as an assistant message to let the model continue
refusalA safety classifier declined the request (the HTTP status is still 200); see stop_details. content may be incomplete
model_context_window_exceededThe model context window was exceeded

In non-streaming responses, stop_reason is always non-null; in streaming responses, it is null in message_start, and the final value arrives in message_delta.

usage

FieldDescription
input_tokensInput tokens that were neither read from nor written to the cache (the part after the last cache breakpoint)
cache_creation_input_tokensInput tokens written to the cache by this request
cache_read_input_tokensInput tokens read from the cache by this request
cache_creation.ephemeral_5m_input_tokensTokens written to the 5-minute cache
cache_creation.ephemeral_1h_input_tokensTokens written to the 1-hour cache
output_tokensOutput tokens, including thinking tokens (what Anthropic bills)
output_tokens_details.thinking_tokensThe portion spent on thinking (for observability only)
server_tool_useServer tool request counts, such as web_search_requests and web_fetch_requests
service_tierThe service tier used: standard, priority, or batch

Total input tokens = input_tokens + cache_creation_input_tokens + cache_read_input_tokens. Because the API transforms requests internally, token counts do not map one-to-one to the visible content; for example, output_tokens is non-zero even for an empty string response.

Streaming Events

With stream enabled, every SSE event has an event name (event: ...) and matching JSON data (data: {...}, whose type equals the event name). Event order:

  1. message_start: a message object with an empty content array and a null stop_reason, plus the initial usage;
  2. each content block in turn: content_block_start โ†’ any number of content_block_delta โ†’ content_block_stop; index is the block's position in the final content array;
  3. one or more message_delta events: delta carries stop_reason and stop_sequence, and the usage next to delta holds cumulative token counts;
  4. message_stop: end of the stream.

ping events may appear anywhere in the stream, and new event types may be added in the future, so clients should ignore events they do not recognize.

delta types in content_block_delta:

delta.typeBlockFieldDescription
text_deltatexttextText increment
input_json_deltatool_usepartial_jsonPartial JSON string of the tool input; concatenate the pieces and parse at content_block_stop
thinking_deltathinkingthinkingThinking text increment; a single empty string when display is omitted
signature_deltathinkingsignatureSignature of the thinking block, sent just before the block's content_block_stop
citations_deltatextcitationCitation information

redacted_thinking blocks and server tool result blocks arrive whole in content_block_start, with no deltas.

If an error occurs after the stream has started (the HTTP status is already 200), it arrives as an error event:

event: error
data: {"type": "error", "error": {"type": "overloaded_error", "message": "Overloaded"}}

Error Responses

Failed requests return a 4XX / 5XX status. Errors from the Anthropic upstream use this shape:

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "This model does not support assistant message prefill. The conversation must end with a user message."
  },
  "request_id": "req_011CSHoEeqs5C35K2UUqR7Fy"
}

Some errors also carry a more specific code in error.details.error_code.

HTTP statuserror.typeMeaning
400invalid_request_errorProblem with the request format or content (invalid parameter, feature not supported by the model, and so on)
401authentication_errorProblem with the API key
402billing_errorBilling or payment problem
403permission_errorThe key lacks permission for the resource
404not_found_errorResource not found
409conflict_errorThe request conflicts with the current state of a resource
413request_too_largeThe request body exceeds the size limit
429rate_limit_errorRate limit reached
500api_errorInternal upstream error
504timeout_errorProcessing timed out; use streaming for long requests
529overloaded_errorThe upstream is temporarily overloaded

Gateway-level errors from BeeRoute (such as an invalid key, insufficient balance, or no available channel) may come back in OpenAI style, for example {"error": {"code": "", "message": "error description", "type": "new_api_error"}}. Handle both shapes when parsing errors: read error.message first, then act on the HTTP status.

Common 400 errors and fixes:

Error message (excerpt)Cause and fix
This model does not support assistant message prefillThe model does not support prefill; remove the trailing assistant message
"thinking.type.enabled" is not supported for this modelOn Claude 4.7 and later models, use {"type": "adaptive"} with output_config.effort instead
"thinking.type.disabled" is not supported for this modelThinking cannot be turned off on this model; remove the thinking field or lower the effort
tool_choice: type "tool" and "any" are not supported for this modelUse tool_choice: {"type": "auto"} instead
`thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modifiedA thinking block was modified; send it back unchanged

Last updated 2026-11-29 ยท Markdown source ยท llms.txt