Claude Messages

Anthropic-compatible Messages API for Claude-native clients and tools.

POSThttps://onerouter.com/v1/messages

Troubleshooting

Errors follow the Anthropic error shape with an HTTP status. See Errors & Retries for the full list and retry guidance.

Supported models

Use any Claude model ID, e.g. anthropic/claude-opus-4.8 or anthropic/claude-sonnet-4.6. Browse the Text & Chat Models page for the current lineup.

Overview

The Messages endpoint is compatible with Anthropic's Messages API. Point any Anthropic SDK or Claude-native tool at OneRouter's base URL and call /v1/messages. Unlike Chat Completions, the system prompt is a top-level system field (not a message), and max_tokens is required.

Request headers

ParameterTypeRequiredDescription
Authorizationstring · requiredrequiredBearer token, formatted as `Bearer YOUR_API_KEY`. The `x-api-key` header is also accepted.
anthropic-versionstringoptionalAnthropic API version, e.g. `2023-06-01`. Forwarded upstream.
Content-Typestring · requiredrequiredMust be `application/json`.

Supported paths

ParameterTypeRequiredDescription
/v1/messagesPOSTrequiredRecommended Claude-native path.
/api/v1/messagesPOSToptionalCompatibility path for clients expecting an `/api` prefix.
/claude/v1/messagesPOSToptionalCompatibility path for Claude-prefixed clients.
/v1/messages/count_tokensPOSToptionalToken counting path when supported by the upstream provider.

Request body

ParameterTypeRequiredDescription
modelstringrequiredClaude model ID.
max_tokensintegerrequiredMaximum output tokens.
messagesarrayrequiredConversation turns with `user` and `assistant` roles.
systemstring | arrayoptionalSystem instruction.
toolsarrayoptionalTool definitions for Claude tool use.
thinkingobjectoptionalExtended thinking configuration for models that support it.
streambooleanoptionalStream Claude message events.

Content blocks

Claude messages use typed content blocks rather than plain strings. A user turn can mix text and image blocks; an assistant turn that calls a tool returns tool_use blocks; you reply with tool_result blocks. Extended-thinking models can emit thinking blocks before the final text.

Response fields

A successful call returns a message object (see the panel on the right). Key fields:

ParameterTypeRequiredDescription
contentarrayoptionalArray of content blocks. Text is in `content[].text` of `type: text` blocks.
stop_reasonstringoptionalWhy generation stopped: `end_turn`, `max_tokens`, `stop_sequence`, or `tool_use`.
usageobjectoptionalToken accounting: `input_tokens` and `output_tokens`.