Create a Claude message

Request in Anthropic Claude Messages API format. The anthropic-version header is required.

POST /v1/messages

Service root: https://getrouter.ai

Protocol: Anthropic Messages

Authentication: x-api-key: YOUR_API_KEY

Parameters

ParameterLocationTypeRequiredDescription
anthropic-versionheaderstringYesAnthropic API version
x-api-keyheaderstringNoAnthropic API key (optional; a Bearer Token may also be used)

Request body

The request body is optional. Media type: application/json

Request fields

FieldTypeRequiredDescription
modelstringYes
messagesarray<object>Yes
systemstring or array<object>No
cache_controlobjectNo
inference_geostringNo
max_tokensintegerYesRange: 1–∞
temperaturenumberNoRange: 0–1
top_pnumberNo
top_kintegerNo
streambooleanNo
stop_sequencesarray<string>No
toolsarray<object>No
tool_choiceobjectNo
thinkingobjectNo
context_managementobjectNo
output_configobjectNo
output_formatobjectNo
containerstring or objectNo
mcp_serversarray<object>No
metadataobjectNo
speedstringNoAllowed values: standard, fast
service_tierstringNoAllowed values: auto, standard_only

Example request

curl --request POST \
  --url https://getrouter.ai/v1/messages \
  --header "x-api-key: YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Hello, introduce yourself."
    }
  ],
  "max_tokens": 1,
  "stream": false,
  "temperature": 0
}'

Responses

StatusDescription
200Response created successfully

Success response fields

FieldTypeRequiredDescription
idstringNo
typestringNo
rolestringNo
contentarray<object>No
modelstringNo
stop_reasonstringNoAllowed values: end_turn, max_tokens, stop_sequence, tool_use
usageobjectNo

Example response

{
  "id": "string",
  "type": "string",
  "role": "user",
  "content": [
    {
      "type": "string",
      "text": "string"
    }
  ],
  "model": "MODEL_ID",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 1,
    "output_tokens": 1,
    "cache_creation_input_tokens": 1,
    "cache_read_input_tokens": 1
  }
}

For complete workflows and examples, read the Claude Messages API Guide.


This page is generated from the public Relay OpenAPI specification. Browse the complete specification in the API Explorer.