← All docs

Endpoints

Create a message

POST/v1/messages

Anthropic Messages compatible — anthropic-native clients such as Claude Code connect as-is. Internally it runs through the same chat pipeline and supports stream.

Body

modelstringYes
Model ID
messagesarrayYes
role is user / assistant. content is a string or an array of blocks (text, image, tool_use, tool_result, thinking, document)
max_tokensintegerYes
1–200000 (required by the Anthropic spec)
systemstring | arrayNo
A string or an array of text blocks
temperaturenumberNo
0–1
top_pnumberNo
0–1
top_kintegerNo
Positive integer
stop_sequencesstring[]No
Up to 8
streambooleanNo
Defaults to false
toolsarrayNo
{name, description, input_schema}
tool_choiceobjectNo
{"type":"auto"|"any"|"none"} or {"type":"tool","name":"..."}
metadataobjectNo
{"user_id": "..."}
thinkingobjectNo
{"type":"enabled","budget_tokens":N} (N < max_tokens) · {"type":"adaptive"} · {"type":"disabled"}
everyaisobjectNo
Gateway caching options

If you attach cache_control directly to a block, it is passed through as-is (see prompt caching).

Model-specific thinking and tools

Check capabilities and limits in GET /v1/models. Omitted fields mean unverified support; unsupported options and combinations return 400. See the model table under Chat options.

  • Latest models such as Claude Opus 5 use thinking: {"type":"adaptive"}. Manual thinking: {"type":"enabled","budget_tokens":N} is not universal. Opus/Sonnet 4.6 support both modes.
  • Manual budgets require 1024 ≤ budget_tokens < max_tokens. Unsupported manual budgets are not resized or converted to adaptive thinking. Fable/Mythos reject thinking: {"type":"disabled"} with 400.
  • Latest Claude on Bedrock rejects explicit temperature, top_p, and top_k with 400. Check capabilities.sampling before setting sampling options.
  • tool_choice.disable_parallel_tool_use: true disables parallel calls. Claude native strict tools require capabilities.structured_outputs: true; for other models, see the strict function-tool restrictions in the Chat documentation; unsupported strict: true returns 400.
  • Web search is exclusive to /v1/chat/completions. Messages tools are client-executed function tools.

POST /v1/messages/count_tokens

Estimates the input token count before you send a request. Claude Code calls this endpoint automatically.

  • Free — no credit is deducted.
  • Returns a heuristic estimate without calling the upstream provider (it may differ from the exact tokenizer result).
  • The request body takes the same shape as /v1/messages.
json
{
  "input_tokens": 1234
}

Current model options

Loading…