Anthropic Messages

Anthropic Messages

Use the Anthropic POST /v1/messages API against the gateway root URL (not the /v1 OpenAI prefix).

Recommended for Claude models only. Other models on OctaRouter should use the OpenAI Chat Completions endpoint unless you have a specific reason to use Messages.

Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
anthropic-version: 2023-06-01

Example

curl "$GATEWAY_URL/v1/messages" \
  -H "Authorization: Bearer sk-or-..." \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-3-5-sonnet-latest",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Streaming follows Anthropic SSE conventions when "stream": true.