Messages (Anthropic)
POST /v1/messages takes a request in Anthropic’s Messages format. It works for every chat model in the catalog, not only Claude, so a tool built for Anthropic’s API can use any model. Write the model as an indoRouter model ID, such as anthropic/claude-sonnet-5 or openai/gpt-4o-mini. Anthropic’s own names, such as claude-sonnet-4-5, are not recognised.
curl https://api.indorouter.ai/v1/messages \ -H "x-api-key: $INDOROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "openai/gpt-4o-mini", "max_tokens": 200, "messages": [{"role": "user", "content": "hello"}]}'The key goes in x-api-key or in Authorization: Bearer. The anthropic-version and anthropic-beta headers are accepted and ignored. To point Claude Code at indoRouter, see Claude Code.
Fields
Section titled “Fields”We read these fields and ignore the rest of Anthropic’s fields, such as top_k, service_tier and mcp_servers:
| Field | Notes |
|---|---|
model |
Required. |
messages |
Required, at least one message. |
system |
A string or text blocks. |
max_tokens |
Optional here. Without it, the model’s default cap is used. |
stream |
Streams Anthropic’s events. |
temperature, top_p |
Passed on, except to Anthropic models, which ignore them. |
stop_sequences |
Passed on as stop sequences. |
tools, tool_choice, disable_parallel_tool_use |
Function tools only. |
thinking |
Turned into a reasoning level: budget_tokens up to 2,048 is low, up to 8,192 is medium, more is high. enabled without a budget and adaptive are medium. disabled, or no thinking, means no thinking. The number itself is not sent on. |
metadata.user_id |
Removed. |
Content blocks can be text, image (base64 or URL), document (base64 PDF), tool_use and tool_result. A document given as a URL is refused: send its bytes. thinking blocks in earlier assistant turns are dropped. cache_control markers on blocks are passed on to models that write a cache on request, sent to OpenAI models from gpt-5.6 on as prompt_cache_breakpoint, and dropped on other models; the request is served either way. The x-indorouter-cache response header says which: kept (passed on), shortened (passed on with the default 5-minute TTL, because that model has no 1-hour one) or dropped. See prompt caching.
Server tools such as web_search, computer, bash and text_editor, and blocks with a file source, are refused with a 400 error. The output cap and the low-balance cap work as on Chat Completions.
Response
Section titled “Response”A response has Anthropic’s format: id is msg_ followed by the request ID, and model is the model ID you sent. stop_reason is end_turn, max_tokens, tool_use or refusal. usage has input_tokens, output_tokens, cache_read_input_tokens and cache_creation_input_tokens. Thinking appears as thinking blocks.
A streamed reply uses Anthropic’s events (message_start, content_block_delta, message_delta, message_stop and the rest), with usage on message_delta. The request-id and x-request-id headers both carry the request ID. Pass it to GET /v1/generation to see what the request cost.
Errors
Section titled “Errors”Errors on this endpoint use Anthropic’s format:
{"type": "error", "error": {"type": "billing_error", "message": "..."}, "request_id": "req_..."}| HTTP status | error.type |
|---|---|
| 401 | authentication_error |
| 402 | billing_error |
| 403 | permission_error |
| 404 | not_found_error |
| 429 | rate_limit_error |
| 503 | overloaded_error |
| Other 5xx | api_error |
| 400, 409 and the rest | invalid_request_error |
This format does not include an indoRouter code. The HTTP status and the message tell you which error it is; the full list is on Errors. A 429 keeps its retry-after header.
Counting tokens
Section titled “Counting tokens”POST /v1/messages/count_tokens takes the same body and returns {"input_tokens": N}. The number is our own estimate, not Anthropic’s count, and it does not include images, PDF pages or tool definitions. Counting is free and needs a valid key.