Anthropic Messages
POST /v1/messagesUse the model name shown on the Pricing page.
Authentication
Section titled “Authentication”x-api-key: OMROUTER_API_KEYanthropic-version: 2023-06-01content-type: application/jsonRequest body
Section titled “Request body”| Field | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Model name shown on the Pricing page. |
messages |
array | Yes | Conversation turns. |
max_tokens |
integer | Yes | Maximum output tokens for the Messages request. |
system |
string or array | No | System instructions. |
stream |
boolean | No | Return Anthropic-style streaming events. |
temperature |
number | No | Sampling control where supported. |
tools |
array | No | Tool definitions where supported. |
tool_choice |
object | No | Tool selection control where supported. |
thinking |
object | No | Thinking configuration where supported. |
Example
Section titled “Example”curl --silent --show-error \ 'https://omrouter.com/v1/messages' \ --header "x-api-key: $OMROUTER_API_KEY" \ --header 'anthropic-version: 2023-06-01' \ --header 'content-type: application/json' \ --data "{ \"model\": \"$OMROUTER_MODEL_ID\", \"max_tokens\": 256, \"messages\": [ {\"role\": \"user\", \"content\": \"Reply with one short sentence.\"} ] }"Response
Section titled “Response”{ "id": "msg_...", "type": "message", "role": "assistant", "model": "model-id", "content": [ {"type": "text", "text": "..."} ], "stop_reason": "end_turn", "usage": { "input_tokens": 0, "output_tokens": 0 }}See Anthropic SDKs for Python and JavaScript configuration.
Optional features
Section titled “Optional features”Basic messages, streaming, and tools can be tested directly. Anthropic beta features, prompt caching, and thinking depend on the selected model. If the API reports an unsupported parameter, remove that optional field and try again.