Messages
The Anthropic-compatible endpoint. Every model on xKiro is reachable here, not only Claude.
POST
/v1/messagesBase 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
| Field | Type | Description |
|---|---|---|
modelrequired | string | Full model ID including the vendor prefix. |
max_tokensrequired | integer | Required by this dialect, unlike Chat Completions. Upper bound on generated tokens. |
messagesrequired | array | Alternating user and assistant turns. System instructions go in the top-level system field, not in this array. |
system | string | array | System prompt. A string, or an array of text blocks that xKiro joins in order. |
stream | boolean | Emit server-sent events. See Streaming. |
temperature | number | Randomness, 0–1 in this dialect. |
top_p | number | Nucleus sampling. |
top_k | integer | Sample from the K most likely tokens. |
stop_sequences | string[] | Sequences that end generation. |
tools | array | Tool definitions using Anthropic's input_schema shape. See Tool calling. |
tool_choice | object | { "type": "auto" | "any" | "none" } or { "type": "tool", "name": "..." }. |
thinking | object | Extended 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
| Field | Type | Description |
|---|---|---|
end_turn | string | The model finished naturally. |
max_tokens | string | Hit the max_tokens ceiling; the answer is truncated. |
stop_sequence | string | One of your stop sequences matched. |
tool_use | string | The 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 withid,nameandinput.
Counting tokens#
POST
/v1/messages/count_tokensEstimate 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
| Field | Type | Description |
|---|---|---|
system prompt | — | Top-level system field here; a system role message in Chat Completions. |
max_tokens | — | Required here, optional in Chat Completions. |
response | — | content block array here; choices[].message in Chat Completions. |
usage | — | input_tokens/output_tokens here; prompt_tokens/completion_tokens in Chat Completions. |
reasoning | — | thinking object here; reasoning_effort string in Chat Completions. Both reach the same control. |
