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
model | string | required | The model name to be called, fill in the name from the model gallery. |
messages | array | required | Array 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. |
role | string | required | Always `assistant` |
content | string | required | String, or multimodal array |
max_tokens | integer | required | Maximum number of tokens to generate in this response. This is a required field under this protocol. |
system | string | System prompt. Can be passed as a string or as an array to set different segments individually. | |
stream | boolean | Whether to stream the response. Set to true for incremental SSE streaming. | |
temperature | number | Sampling temperature; higher values result in more diverse outputs, lower values result in more stable outputs. | |
tools | array | List 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_choice | object | Control over tool usage: whether to let the model decide, force usage, or specify a particular tool. Must be used in conjunction with tools. | |
stop_sequences | array | Stop generation upon encountering any of the following strings. | |
top_p | number | Nucleus sampling, selecting candidates from the top top_p cumulative probabilities. Only one of temperature and nucleus sampling should be used. | |
top_k | integer | Only select from the top k candidates with highest probability. | |
thinking | object | Enable 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. | |
metadata | object | Custom metadata for your own categorization and retrieval. |
200 — Return response in native Claude Messages formatcurl 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.