Messages

The Anthropic-compatible endpoint. Every model on xKiro is reachable here, not only Claude.

POST/v1/messages

Base URL has no /v1

The Anthropic SDKs append /v1/messages themselves, so set baseURL: "https://api.xkiro.com". Adding /v1 yourself produces /v1/v1/messages and a 404.

curl https://api.xkiro.com/v1/messages \
  -H "x-api-key: $XKIRO_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-5",
    "max_tokens": 1024,
    "system": "You are a concise assistant.",
    "messages": [
      { "role": "user", "content": "Name three uses for a paperclip." }
    ]
  }'

Request body#

Core fields
FieldTypeDescription
modelrequiredstringFull model ID including the vendor prefix.
max_tokensrequiredintegerRequired by this dialect, unlike Chat Completions. Upper bound on generated tokens.
messagesrequiredarrayAlternating user and assistant turns. System instructions go in the top-level system field, not in this array.
systemstring | arraySystem prompt. A string, or an array of text blocks that xKiro joins in order.
streambooleanEmit server-sent events. See Streaming.
temperaturenumberRandomness, 0–1 in this dialect.
top_pnumberNucleus sampling.
top_kintegerSample from the K most likely tokens.
stop_sequencesstring[]Sequences that end generation.
toolsarrayTool definitions using Anthropic's input_schema shape. See Tool calling.
tool_choiceobject{ "type": "auto" | "any" | "none" } or { "type": "tool", "name": "..." }.
thinkingobjectExtended thinking. See Reasoning for the exact shapes and how they map to non-Anthropic models.

Response#

200 OK
{
  "id": "msg_01ABCdefGHIjklMNO",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-opus-5",
  "content": [
    { "type": "text", "text": "..." }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 24,
    "output_tokens": 88
  }
}

stop_reason

FieldTypeDescription
end_turnstringThe model finished naturally.
max_tokensstringHit the max_tokens ceiling; the answer is truncated.
stop_sequencestringOne of your stop sequences matched.
tool_usestringThe model is calling a tool; run it and reply with a tool_result block.

Content blocks#

Responses are an array of blocks rather than a single string. Handle each type you care about and ignore the rest — new block types can appear over time.

  • text — visible output.
  • thinking— the model's reasoning, present when thinking is enabled.
  • tool_use — a tool call with id, name and input.

Counting tokens#

POST/v1/messages/count_tokens

Estimate the input size of a request before sending it — useful for staying inside a context window or predicting cost.

curl https://api.xkiro.com/v1/messages/count_tokens \
  -H "x-api-key: $XKIRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-5",
    "messages": [{ "role": "user", "content": "Hello there" }]
  }'
200 OK
{ "input_tokens": 11 }

Differences from Chat Completions#

Same capability, different spelling
FieldTypeDescription
system promptTop-level system field here; a system role message in Chat Completions.
max_tokensRequired here, optional in Chat Completions.
responsecontent block array here; choices[].message in Chat Completions.
usageinput_tokens/output_tokens here; prompt_tokens/completion_tokens in Chat Completions.
reasoningthinking object here; reasoning_effort string in Chat Completions. Both reach the same control.