DocsAPI referenceMessages API
Messages API
The Anthropic-compatible Messages endpoint and count_tokens.
POST
/v1/messagesA chat endpoint compatible with the Anthropic Messages API request body. Authenticate with x-api-key (or Authorization: Bearer); headers the SDK adds automatically, such as anthropic-version, are forwarded as-is.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model id — see Models. |
max_tokens | integer | Yes | Output token cap (required in the Anthropic format). |
messages | array | Yes | Conversation messages; role is user/assistant, content is a string or an array of content blocks (images allowed). |
system | string | array | No | System prompt. |
stream | boolean | No | When true, the response streams over SSE — see Streaming. |
temperature / tools / … | — | No | Other official fields are forwarded as-is; support depends on the target model. |
curl https://api.soleapi.com/v1/messages \
-H "x-api-key: $SOLEAPI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Write a haiku about the sea"}]
}'Response
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"model": "claude-fable-5",
"content": [
{ "type": "text", "text": "Waves fold into foam..." }
],
"stop_reason": "end_turn",
"usage": { "input_tokens": 14, "output_tokens": 23 }
}Count tokens
POST
/v1/messages/count_tokensEstimate the input token count of a message payload before sending; the request body matches Messages (no max_tokens needed). Counting itself does not incur model charges.
curl https://api.soleapi.com/v1/messages/count_tokens \
-H "x-api-key: $SOLEAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5",
"messages": [{"role": "user", "content": "Write a haiku about the sea"}]
}'
# => { "input_tokens": 14 }