Messages API
Send a request to POST /messages and read the response in this API’s format.
Request
curl
curl https://api.closerouter.dev/v1/messages \
-H "Authorization: Bearer $CLOSEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-haiku-4.5",
"max_tokens": 16,
"messages": [
{ "role": "user", "content": "Reply with exactly: ok" }
]
}'Response
Abbreviated response example.
JSON
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "ok"
}
]
}Main parameters
| Field | Purpose |
|---|---|
model | Model ID from the catalog. Parameter support depends on the provider and API. |
messages | Messages in this API’s format. |
max_tokens | Output token limit. Required for Messages. |
Authentication
Compatible Anthropic clients may use x-api-key instead of Bearer authentication.