Skip to main content
Documentation

Documentation menu

Messages (Anthropic-compatible)

POST /v1/messages - request fields, response shape, stop reasons, usage and the Anthropic-style error body.

Last updated 2026-11-04

POST https://api.ticonai.com/v1/messages follows the Anthropic Messages format, so Anthropic SDKs work after you change the base URL and key. The model catalog and wallet are the same as for chat completions.

bash
curl -sS https://api.ticonai.com/v1/messages \
  -H "x-api-key: $AIP_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "max_tokens": 80,
    "system": "You answer in one short sentence.",
    "messages": [{ "role": "user", "content": "What is a prepaid wallet?" }]
  }'

Send the key as x-api-key or as Authorization: Bearer. The anthropic-version header is optional; if present it must be a date like 2023-06-01. See Authentication.

Request fields

FieldTypeNotes
modelstring, requiredA model id from GET /v1/models.
max_tokensinteger, requiredUpper bound on generated tokens. A value above the model's maximum output is lowered to that maximum.
messagesarray, requiredAt least one message with role user or assistant. content is a string or an array of blocks.
systemstring or array of text blocksThe system prompt.
temperaturenumber, 0 to 1
top_pnumber, 0 to 1
stop_sequencesarray of up to 16 strings
streambooleantrue returns server-sent events. See Streaming.
tools, tool_choiceanyAccepted and forwarded to the model.

Other fields are accepted and ignored in this release. The request body limit and content type rules are the same as for chat completions.

Response

json
{
  "id": "msg_0123456789abcdef",
  "type": "message",
  "role": "assistant",
  "model": "your-model-id",
  "content": [{ "type": "text", "text": "A prepaid wallet holds money you add before you spend it." }],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": { "input_tokens": 31, "output_tokens": 14, "cache_read_input_tokens": 0 }
}
  • stop_reason is end_turn, max_tokens, tool_use or refusal.
  • usage.input_tokens does not include cached tokens; cached tokens are reported separately in cache_read_input_tokens. Both are billed.
  • The content array contains text blocks only.

Errors use the Anthropic envelope

On this endpoint an error body looks like this, and the HTTP status is the reliable signal:

json
{
  "type": "error",
  "error": { "type": "billing_error", "message": "Insufficient wallet balance for this request. Top up your wallet and retry." },
  "request_id": "req_0123456789abcdef"
}

error.type follows the HTTP status: invalid_request_error (400, 405, 409), authentication_error (401), billing_error (402), permission_error (403), not_found_error (404), request_too_large (413), rate_limit_error (429), timeout_error (504), and api_error for everything else. The stable machine code values of the Errors page appear in the OpenAI-style body used by every other endpoint.

bash
curl -sS -o /dev/null -w "%{http_code}" https://api.ticonai.com/v1/messages \
  -H "x-api-key: $AIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "no-such-model", "max_tokens": 8, "messages": [{ "role": "user", "content": "hi" }] }'