Claude Messages
Anthropic-compatible Messages API for Claude-native clients and tools.
https://onerouter.com/v1/messagesTroubleshooting
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
| Parameter | Type | Required | Description |
|---|---|---|---|
| Authorization | string · required | required | Bearer token, formatted as `Bearer YOUR_API_KEY`. The `x-api-key` header is also accepted. |
| anthropic-version | string | optional | Anthropic API version, e.g. `2023-06-01`. Forwarded upstream. |
| Content-Type | string · required | required | Must be `application/json`. |
Supported paths
| Parameter | Type | Required | Description |
|---|---|---|---|
| /v1/messages | POST | required | Recommended Claude-native path. |
| /api/v1/messages | POST | optional | Compatibility path for clients expecting an `/api` prefix. |
| /claude/v1/messages | POST | optional | Compatibility path for Claude-prefixed clients. |
| /v1/messages/count_tokens | POST | optional | Token counting path when supported by the upstream provider. |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | required | Claude model ID. |
| max_tokens | integer | required | Maximum output tokens. |
| messages | array | required | Conversation turns with `user` and `assistant` roles. |
| system | string | array | optional | System instruction. |
| tools | array | optional | Tool definitions for Claude tool use. |
| thinking | object | optional | Extended thinking configuration for models that support it. |
| stream | boolean | optional | Stream 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| content | array | optional | Array of content blocks. Text is in `content[].text` of `type: text` blocks. |
| stop_reason | string | optional | Why generation stopped: `end_turn`, `max_tokens`, `stop_sequence`, or `tool_use`. |
| usage | object | optional | Token accounting: `input_tokens` and `output_tokens`. |