Skip to main content
POST
/
anthropic
/
v1
/
messages
Create Anthropic-compatible message
curl --request POST \
  --url https://api.myrouter.example/anthropic/v1/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'anthropic-version: <anthropic-version>' \
  --data '
{
  "model": "<string>",
  "messages": [
    {
      "content": "<string>"
    }
  ],
  "max_tokens": 2,
  "stream": true,
  "system": "<string>",
  "stop_sequences": [
    "<string>"
  ],
  "temperature": 123,
  "top_p": 123,
  "top_k": 123,
  "tools": [
    {}
  ],
  "tool_choice": "<string>",
  "metadata": {}
}
'
{
  "id": "<string>",
  "type": "<string>",
  "role": "<string>",
  "content": [
    {}
  ],
  "model": "<string>",
  "stop_reason": "<string>",
  "usage": {
    "input_tokens": 1,
    "output_tokens": 1,
    "total_tokens": 1,
    "cache_read_tokens": 1,
    "cache_write_tokens": 1,
    "reasoning_tokens": 1
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

x-request-id
string

Optional caller request id.

anthropic-version
string
required

Anthropic API version.

x-api-key
string

Anthropic SDK-compatible API key header. Prefer Authorization: Bearer for MyRouter.

Body

application/json
model
string
required

Public MyRouter model id exposed through Anthropic-compatible API.

messages
object[]
required

Anthropic-style input messages.

Minimum array length: 1
max_tokens
integer
required

Maximum output tokens.

Required range: x >= 1
stream
boolean

Whether to stream SSE events.

system

System prompt content.

stop_sequences
string[]

Stop sequences.

temperature
number

Sampling temperature.

top_p
number

Nucleus sampling value.

top_k
integer

Top-k sampling value.

tools
object[]

Anthropic tool definitions.

tool_choice

Tool choice.

metadata
object

Customer metadata.

Response

Create Anthropic-compatible message response.

id
string
required

Message id.

type
string
required

Anthropic response type.

role
string
required

Assistant role.

content
object[]
required

Output content blocks.

model
string
required

Public MyRouter model id.

stop_reason
string

Why generation stopped.

usage
object

Runtime usage facts, not invoice-grade charge evidence.