Developers / Docs / API reference / Messages

Messages

POST /api/anthropic/v1/messages: the Anthropic-compatible way to chat, streamed or in one piece. For examples and explanations, see the Messages API guide.

Create message

POST /api/anthropic/v1/messages

Anthropic's Messages API on ARK models. No anthropic-version header is required. Unknown fields are rejected with 400.

Request body

modelstringrequired

A chat or vision model id.

messagesarrayrequired
user and assistant turns. Content is a string or blocks: text, image (base64 or url source), document (plain-text source), search_result, tool_use, tool_result, thinking (dropped).
max_tokensintegerrequired

Maximum tokens to generate, thinking included.

systemstring or arrayoptional

System prompt, as text or text blocks.

temperaturenumber, 0–1optional

Default 0.6.

top_p, top_knumber, integeroptional

Sampling parameters.

stop_sequencesarrayoptional

Up to 4. Not allowed with ark_stateful.

streambooleanoptional

Stream events.

toolsarrayoptional

Client tools: {"name", "description", "input_schema"}. Server tools return 400.

tool_choiceobjectoptional
{"type": "auto" | "any" | "none"} or {"type": "tool", "name": …}; disable_parallel_tool_use limits the reply to one call.
thinkingobjectoptional
{"type": "enabled", "budget_tokens": n} (n ≥ 8192: high, otherwise medium), {"type": "adaptive"} (medium) or {"type": "disabled"}. Absent: no thinking.
output_configobjectoptional
effort (low … max) and format: {"type": "json_schema", "schema": …}.
ark_stateful, ark_max_session_tokensstring, integerARK extension

Stateful session, as on the chat route.

metadata, service_tier, speed, cache_control, container, context_management, mcp_serversaccepted, no effect

Accepted for compatibility.

Response

content holds thinking, text and tool_use blocks, in that order. stop_reason is end_turn, max_tokens, stop_sequence or tool_use. In usage, input_tokens plus cache_read_input_tokens is the full prompt; output_tokens_details.thinking_tokens counts thinking.

curl https://api.ark-labs.cloud/api/anthropic/v1/messages \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "arklabsai/Qwen3.5-122B-A10B",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
Response
{
  "id": "msg_01J9…",
  "type": "message",
  "role": "assistant",
  "model": "arklabsai/Qwen3.5-122B-A10B",
  "content": [{"type": "text", "text": "Hello! How can I help you today?"}],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 18,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 10,
    "output_tokens_details": {"thinking_tokens": 0},
    "service_tier": "standard"
  }
}

Message stream events

With "stream": true, each event is event: <name> followed by data: <json>:

  1. message_start: the message with empty content and the prompt usage.
  2. content_block_start, then ping once.
  3. content_block_delta: text_delta, thinking_delta, or one input_json_delta carrying a whole tool input.
  4. content_block_stop for each block.
  5. message_delta: stop_reason and the final usage.
  6. message_stop.

An error mid-stream arrives as event: error.

Stream
event: message_start
data: {"type":"message_start","message":{"id":"msg_…","type":"message","role":"assistant","content":[],…}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}

event: ping
data: {"type":"ping"}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn",…},"usage":{"output_tokens":10,…}}

event: message_stop
data: {"type":"message_stop"}