Create a message (Claude native)

Use the native Anthropic Claude Messages format with the official SDK and tools.

POST /v1/messages

Auth: {'type': 'bearer', 'prefix': 'sk-', 'description': 'Pass your API key in the `Authorization: Bearer sk-xxx` header.'}

Native Claude Messages API. If your code is already using the Anthropic official SDK, simply point `base_url` to this platform and the rest of the code remains unchanged. - Supports `stream: true` SSE streaming - Supports tool calls / image input - Difference from OpenAI endpoints: `system` is the top-level field, not a messages element

Request body

modelstringrequiredThe model name to be called, fill in the name from the model gallery.
messagesarrayrequiredArray of conversation messages, each containing role and content. The role can only be user or assistant; system prompts are handled via a separate system field and not included here.
    rolestringrequiredAlways `assistant`
    contentstringrequiredString, or multimodal array
max_tokensintegerrequiredMaximum number of tokens to generate in this response. This is a required field under this protocol.
systemstringSystem prompt. Can be passed as a string or as an array to set different segments individually.
streambooleanWhether to stream the response. Set to true for incremental SSE streaming.
temperaturenumberSampling temperature; higher values result in more diverse outputs, lower values result in more stable outputs.
toolsarrayList of available tools for the model to use. The model will return a tool_use content block when needed, which you will then execute and refill with tool_result.
tool_choiceobjectControl over tool usage: whether to let the model decide, force usage, or specify a particular tool. Must be used in conjunction with tools.
stop_sequencesarrayStop generation upon encountering any of the following strings.
top_pnumberNucleus sampling, selecting candidates from the top top_p cumulative probabilities. Only one of temperature and nucleus sampling should be used.
top_kintegerOnly select from the top k candidates with highest probability.
thinkingobjectEnable extended thinking: the model will perform reasoning before generating a response. The reasoning process will be returned as a separate content block and counted toward output usage. Only available for models that support this capability.
metadataobjectCustom metadata for your own categorization and retrieval.

Responses

Example

curl https://api.router.ai/v1/messages \
  -H "Authorization: Bearer sk-xxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 512,
    "system": "用简洁中文回答",
    "messages": [{"role": "user", "content": "你好"}]
  }'

## Other fields This endpoint uses Anthropic native request format. Any fields outside the table above can be passed as per Anthropic's official specifications without additional adaptation.

API reference