Skip to content

Anthropic Messages

POST /v1/messages

Use the model name shown on the Pricing page.

x-api-key: OMROUTER_API_KEY
anthropic-version: 2023-06-01
content-type: application/json
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.
Terminal window
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.\"}
]
}"
{
"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.

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.