wylon
POST https://api.wylon.cn/v1/messages

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

x-api-key string · header required
Your wylon API key, e.g. wl-xxxx. The Anthropic SDK sends this header automatically; the gateway also accepts Authorization: Bearer <key>. Create API keys in the dashboard.
anthropic-version string · header required
Anthropic API version, e.g. 2023-06-01.

Request body

Content-Type: application/json

model string required
Model ID to call, e.g. moonshotai/Kimi-K2.6. The available list is in the model catalog or via the list models endpoint.
messages array required
Ordered conversation turns. Note: the system prompt is NOT a message — use the top-level system field.
role enum required
One of user or assistant.
content string · array required
A plain text string, or an array of content blocks. Each block is e.g. {type:"text", text} or {type:"image", source:{...}}.
max_tokens integer required
Maximum tokens to generate. Required by the Messages API; cannot exceed the model context window.
system string · array optional
System prompt / instructions, passed at the top level (not inside messages). May be a string or an array of content blocks.
temperature number optional
Sampling temperature, range 0 – 1. Higher means more random.
top_p number optional
Nucleus-sampling threshold, range 0 – 1. Samples from the smallest set whose cumulative probability reaches top_p.
top_k integer optional
Sample from the top-K most probable tokens at each step.
stop_sequences array optional
Custom strings that stop generation when matched.
stream boolean false
When true, message events are streamed as SSE (text/event-stream).
tools array optional
Tool definitions the model may call. Each is {name, description, input_schema}, where input_schema is a JSON Schema. See Function calling.
tool_choice object optional
Control tool invocation: {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.
metadata object optional
Request metadata, e.g. {user_id: "..."}, used for abuse monitoring and audit.
thinking object optional · wylon/Anthropic extension
Extended thinking. Shaped as {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.

idstring
Unique identifier for this message, e.g. msg_....
typestring
Always message.
rolestring
Always assistant.
contentarray
Array of content blocks.
type:"text"object
Text block, shaped as {type:"text", text}.
type:"tool_use"object
Tool-call block, shaped as {type:"tool_use", id, name, input}.
type:"thinking"object
Extended-thinking block, shaped as {type:"thinking", thinking}.
modelstring
The model ID that actually served this request.
stop_reasonenum
end_turn / max_tokens / stop_sequence / tool_use.
stop_sequencestring · null
The matched stop sequence, or null if none matched.
usageobject
Token usage stats (Anthropic naming, not prompt/completion_tokens).
input_tokensinteger
Input token count.
output_tokensinteger
Output token count.
Example response
{
  "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":"..."}}.

typestring
Always error.
error.typestring
Error category, e.g. invalid_request_error, authentication_error, rate_limit_error, overloaded_error, api_error.
error.messagestring
Human-readable error description.
Example — 429 rate-limited
{
  "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.

Example — 529 / 503 overloaded
{
  "type": "error",
  "error": {
    "type": "overloaded_error",
    "message": "Overloaded, please retry shortly."
  }
}
沪ICP备2026010432号-1 沪公网安备31010402336632号