Anthropic API Compatible
Authorization
This endpoint supports the following two authentication methods. Choose one and add it to the request headers:
- Method 1:x-api-keyauthentication, format:x-api-key: $UNISOUND_API_KEY
- Method 2:Authorization: Bearerauthentication, format:Authorization: Bearer $UNISOUND_API_KEY
$UNISOUND_API_KEY Used to verify account information, can be viewed in Metered & Packs > API Key Management.
Request Bodyapplication/json
modelstringRequired
Model code. Available values:
Unisound Series: u2-flash, u2, u2-med, u2-radimed
DeepSeek Series: deepseek-v4-flash-0731, deepseek-v4-pro
Kimi Series: kimi-k2.5, kimi-k2.6, kimi-k3
GLM Series: glm-5.3, glm-5.2, glm-5.1, glm-5
MiniMax Series: MiniMax-M3, MiniMax-M2.5
Qwen (Tongyi Qianwen) Series: qwen3.8-flash, qwen3.7-plus, qwen3.7-max, qwen3.8-max, qwen3.6-plus, qwen3.6-flash, qwen3.6-35b-a3b
max_tokensintegerRequired
Maximum number of tokens to generate. max_tokens does not limit the thinking process; when deep thinking is enabled, thinking tokens are controlled separately by thinking.budget_tokens.
systemstring | arrayOptional
System prompt used to define the model role or behavior.
system is passed as a top-level parameter, and the messages array does not accept the system role.
Passing a string is equivalent to a single content block with type="text".
typestringRequired
Fixed to text.
textstringRequired
System prompt text.
messagesarrayRequired
Message array arranged in alternating user / assistant turns.
The messages array does not accept the system role.
rolestringRequired
Message role. Available values: user, assistant.
contentstring | arrayRequired
Message content. It can be a plain text string or a structured content array (including multimodal blocks such as text and images).
When content is a string, it is equivalent to a single content block with type="text".
Text informationobject
typestringRequired
Fixed to text.
textstringRequired
Text content.
Image informationobject
(requires a vision model)
typestringRequired
Fixed to image.
sourceobjectRequired
Source of the image data.
typestringRequired
Available values:
url: public image URL.base64: Base64-encoded image data.
urlstringOptional
Public URL of the image. Required when type is url.
media_typestringOptional
MIME type of the image, such as image/jpeg. Required when type is base64.
datastringOptional
Base64-encoded image data. Required when type is base64.
Tool call informationobject
(assistant role, tool call instructions returned by the model)
typestringRequired
Fixed to tool_use.
idstringRequired
Unique identifier of the tool call, used to associate the result in a later tool_result.
namestringRequired
Name of the invoked tool.
inputobjectRequired
Input arguments of the tool call. The structure is determined by the corresponding input_schema in tools. The tool call content itself participates in the cache prefix.
Tool result informationobject
(user role, tool execution result sent back to the model)
typestringRequired
Fixed to tool_result.
tool_use_idstringRequired
Corresponds to the id in the tool_use information.
contentstringRequired
Content returned by the tool execution.
streambooleanOptionalDefault: false
Whether to enable streaming output. Defaults to false.
temperaturenumberOptional
Controls the diversity of generated text, with a value range of [0, 2). The larger the value, the more random the result.
This range differs from Anthropic's official [0.0, 1.0]. Confirm the value when migrating from Anthropic.
top_pnumberOptional
Nucleus sampling threshold. It is recommended to use either this or temperature, not both.
Value range: (0, 1.0].
The default value is determined by the model.
repetition_penaltynumberOptional
Penalty for consecutive sequence repetition. Gateway extension field, validated and forwarded upstream.
Value range: (0, 2.0].
Default value: 1.0 means no penalty.
presence_penaltynumberOptional
Controls content repetition. Gateway extension field, validated and forwarded upstream.
Value range: [-2.0, 2.0].
The default value is determined by the model.
frequency_penaltynumberOptional
Controls token frequency penalty. Gateway extension field.
Value range: [-2.0, 2.0].
The default value is determined by the model.
top_kintegerOptional
Size of the candidate sampling set during generation.
stop_sequencesarrayOptional
Stop sequences. Generation stops before a matched sequence, and the matched sequence itself is not included in the output.
stop_reason is still end_turn.thinkingobjectOptional
Deep thinking configuration. When enabled, the model reasons before generating the reply to improve accuracy. The response includes content blocks of type thinking.
u2, kimi-k3, glm-5.3, and MiniMax-M2.5 enable thinking by default and do not support disabling it. MiniMax-M3 supports disabling thinking (thinking.type=disabled), unlike MiniMax-M2.5. u2-radimed disables thinking by default and does not support enabling it.
typestringRequired
Available values: enabled (thinking mode on), disabled (thinking mode off).
budget_tokensintegerOptional
Maximum number of tokens available for the thinking process. This does not overlap with max_tokens: this parameter limits thinking, while max_tokens limits the final reply. Takes effect when type is enabled.
toolsarrayOptional
Array of tool definitions for Function Call scenarios.
namestringRequired
Tool name.
descriptionstringOptional
Functional description of the tool.
input_schemaobjectRequired
JSON Schema definition of the tool input parameters.
tool_choiceobjectOptional
Tool selection strategy.
typestringRequired
Available values: auto (the model decides whether to call a tool, default), any (force the model to call any tool), none (disable tool calls), tool (force the model to call a specific tool).
namestringOptional
When type is tool, specifies the name of the tool to call.
reasoning_effortstringOptional
Controls the model's reasoning effort. Supported values and defaults vary by model.
| Model | Default | Supported levels | Mapping of other levels |
|---|---|---|---|
deepseek-v4-pro, glm-5.2, glm-5.1, glm-5 | high | high, max | low and medium map to high; xhigh maps to max |
deepseek-v4-flash-0731 | high | max, high, low | medium maps to high; xhigh maps to high |
kimi-k3, glm-5.3, glm-5.3-flash | max | max, high, low | — |
qwen3.8-max, qwen3.8-flash | xhigh | xhigh, medium, low | max and high map to xhigh; minimal maps to low; none disables thinking |
u2-med | — | none, low, medium, high | minimal maps to low; xhigh and max map to high |
kimi-k3, glm-5.3, and glm-5.3-flash always enable thinking. thinking.type only supports enabled; passing disabled causes the API request to fail.
Values other than the supported options and mapped values above will cause an error.
output_configobjectOptional
Structured output configuration. When enabled, the model outputs a JSON string.
Strict structured output: applicable to DeepSeek Series and GLM Series models. The model strictly follows the provided JSON Schema for constrained output, ensuring field types and hierarchy are fully consistent.
Standard structured output: for all other models. Specific field constraints in the Schema are not enforced by default; the API converts it to standard JSON mode (valid JSON string only). Requires both: 1) explicitly passing output_config; 2) the word JSON (case-insensitive) in system or messages content.
formatobjectRequired
Output format configuration.
typestringRequired
Fixed to json_schema.
schemaobjectRequired
JSON Schema object. Must include type, properties, required, and additionalProperties (must be set to false).
Non-streaming response
idstring
Unique identifier of the message.
typestring
Fixed to message.
rolestring
Fixed to assistant.
modelstring
Model name used.
contentarray
Content array.
Text informationobject
typestring
Fixed to text.
textstring
Text reply generated by the model.
output_config is enabled, this field is a JSON string that the client must parse.Thinking informationobject
(returned when deep thinking is enabled)
typestring
Fixed to thinking.
thinkingstring
Model thinking process before generating the final reply.
signaturestring
Currently fixed to an empty string.
Tool call informationobject
(Function Call scenario)
typestring
Fixed to tool_use.
idstring
Unique identifier of the tool call, used to associate the result in a later tool_result.
namestring
Name of the invoked tool.
inputobject
Input arguments of the tool call.
stop_reasonstring
Stop reason. Available values:
end_turn(normal completion)max_tokens(token limit reached)tool_use(tool call)
usageobject
Token usage statistics.
usage field in the message_start event contains only input_tokens and output_tokens; all four fields are returned in the message_delta event.input_tokensinteger
Number of input tokens.
output_tokensinteger
Number of output tokens.
cache_creation_input_tokensinteger
Number of input tokens consumed for cache creation.
cache_read_input_tokensinteger
Number of input tokens consumed for cache reads.
Streaming response
message_start
The first event of the stream, marking the start of the message.
typestring
Fixed to message_start.
messageobject
Initial message object. content is an empty array, and usage contains only input_tokens and output_tokens.
content_block_start
Sent when each content block starts, marking the index and type of the new content block.
typestring
Fixed to content_block_start.
indexinteger
Content block index, starting from 0, corresponding to the position in the message content array.
content_blockobject
Initial object of the content block. type can be text, thinking, or tool_use. For tool_use, input is an empty object in this event, and the full arguments are assembled from subsequent content_block_delta increments.
content_block_delta
Incremental update event for a content block. Multiple events may be sent for the same block.
typestring
Fixed to content_block_delta.
indexinteger
Index of the related content block.
deltaobject
Incremental object. type can be:
text_delta: text increment with thetextfield.thinking_delta: thinking increment with thethinkingfield.signature_delta: signature increment with thesignaturefield (currently fixed to an empty string).input_json_delta: tool call argument increment with thepartial_jsonfield.
content_block_stop
Event indicating the end of a content block.
typestring
Fixed to content_block_stop.
indexinteger
Index of the ended content block.
message_delta
Message-level update event sent after all content blocks end. It includes the stop reason and complete token usage statistics.
typestring
Fixed to message_delta.
deltaobject
Contains stop_reason and stop_sequence. See the non-streaming response table above for possible values.
usageobject
Complete token usage statistics, including input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens.
message_stop
The final event of the stream, marking the end of the message.
typestring
Fixed to message_stop.