DocsAPI referenceMessages API

Messages API

The Anthropic-compatible Messages endpoint and count_tokens.

POST/v1/messages

A 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

FieldTypeRequiredDescription
modelstringYesModel id — see Models.
max_tokensintegerYesOutput token cap (required in the Anthropic format).
messagesarrayYesConversation messages; role is user/assistant, content is a string or an array of content blocks (images allowed).
systemstring | arrayNoSystem prompt.
streambooleanNoWhen true, the response streams over SSE — see Streaming.
temperature / tools / …NoOther official fields are forwarded as-is; support depends on the target model.
request.sh
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

response.json
{
  "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_tokens

Estimate 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.

count_tokens.sh
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 }