Messages (Anthropic)
Compatible with the Anthropic Messages protocol; you can use the Anthropic SDK directly by pointing base_url at https://api.wylon.cn. Streaming and tool use are controlled through request parameters.
Authentication
wl-xxxx. The Anthropic SDK sends this header automatically; the gateway also accepts Authorization: Bearer <key>. Create API keys in the dashboard.2023-06-01.Request body
Content-Type: application/json
moonshotai/Kimi-K2.6. The available list is in the model catalog or via the list models endpoint.
system field.
user or assistant.{type:"text", text} or {type:"image", source:{...}}.messages). May be a string or an array of content blocks.0 – 1. Higher means more random.0 – 1. Samples from the smallest set whose cumulative probability reaches top_p.true, message events are streamed as SSE (text/event-stream).{name, description, input_schema}, where input_schema is a JSON Schema. See Function calling.{type:"auto"} lets the model decide; {type:"any"} forces at least one tool call; {type:"tool", name:"..."} forces a specific tool; {type:"none"} disables tools. Note Anthropic uses "any" / "tool", which differ from OpenAI.{user_id: "..."}, used for abuse monitoring and audit.{type:"enabled", budget_tokens: 1024}; budget_tokens controls the thinking token budget.Response
Non-streaming: returns an Anthropic Message object (not the OpenAI shape).
Streaming (stream=true): a series of message events is returned as SSE.
msg_....message.assistant.{type:"text", text}.{type:"tool_use", id, name, input}.{type:"thinking", thinking}.end_turn / max_tokens / stop_sequence / tool_use.null if none matched.prompt/completion_tokens).{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"model": "moonshotai/Kimi-K2.6",
"content": [
{ "type": "text", "text": "A KV cache stores already-computed key/value tensors so they aren't recomputed." }
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 24,
"output_tokens": 31
}
}
When streaming (stream=true), the SSE event types are, in order: message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop, with ping events interleaved.
Bad request, authentication failure, or an exceeded rate limit. Errors use the Anthropic envelope: {"type":"error","error":{"type":"...","message":"..."}}.
error.invalid_request_error, authentication_error, rate_limit_error, overloaded_error, api_error.{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "Number of request tokens has exceeded your rate limit."
}
}
Transient server error or overload. Retry with exponential backoff and jitter.
{
"type": "error",
"error": {
"type": "overloaded_error",
"message": "Overloaded, please retry shortly."
}
}