MaaS_Qwen
Capability Map
qwen3.8-max
| Capability | Support Status | Capability | Support Status |
|---|---|---|---|
| Input Modality | Image Text Video | Output Modality | Text |
| Model Playground | Supported | Function Calling | Supported |
| Structured Output | Supported | Web Search | Supported |
| Prefix Continuation | Supported | Context Caching | Supported |
| Batch Inference | Supported | Model Fine-tuning | Not Supported |
| Parameter | Value | Parameter | Value |
|---|---|---|---|
| Max Input Length | 991808 | Max Output Length | 131072 |
| Max Input Length (Thinking Mode) | 983616 | Max Output Length (Thinking Mode) | 131072 |
| Context Length | 1000000 | Max Chain-of-Thought Length | 262144 |
qwen3.7-max
| Capability | Support Status | Capability | Support Status |
|---|---|---|---|
| Input Modality | Image Text Video | Output Modality | Text |
| Model Playground | Supported | Function Calling | Supported |
| Structured Output | Supported | Web Search | Supported |
| Prefix Continuation | Supported | Context Caching | Supported |
| Batch Inference | Supported | Model Fine-tuning | Not Supported |
| Parameter | Value | Parameter | Value |
|---|---|---|---|
| Max Input Length | 991808 | Max Output Length | 131072 |
| Context Length | 1000000 | Max Input Length (Thinking Mode) | 983616 |
| Max Output Length (Thinking Mode) | 131072 | Max Chain-of-Thought Length | 262144 |
qwen3.5-plus
| Capability | Support Status | Capability | Support Status |
|---|---|---|---|
| Input Modality | Image Text Video | Output Modality | Text |
| Model Playground | Supported | Function Calling | Supported |
| Structured Output | Supported | Web Search | Supported |
| Prefix Continuation | Supported | Context Caching | Supported |
| Batch Inference | Supported | Model Fine-tuning | Not Supported |
Context Limits
| Parameter | Value | Parameter | Value |
|---|---|---|---|
| Max Input Length | 991808 | Max Output Length | 65536 |
| Context Length | 1000000 | Max Input Length (Thinking Mode) | 983616 |
| Max Output Length (Thinking Mode) | 65536 | Max Chain-of-Thought Length | 81920 |
/chat/completions Request URL
Request Header
| Parameter | Value |
|---|---|
| Authorization | Bearer |
| Content-Type | application/json |
Request Body
Request Parameters
model string Required
Model name.
messages array Required
Context passed to the model, arranged in conversation order.
Message Types
System Message object (Optional)
System message, used to set the model's role, tone, task objectives, or constraints. Typically placed as the first element in the messages array.
It is not recommended to set System Message for QwQ models. System Message will not take effect for QVQ models.
Properties
role string Required
Role of the system message, fixed as system.
content string Required
System instructions, used to define the model's role, behavior guidelines, response style, and task constraints.
User Message object (Required)
User message, used to pass questions, instructions, or context to the model.
Properties
role string Required
Role of the user message, fixed as user.
content string / array Required
Message content. If the input contains only text, it is of string type; if the input contains multimodal data such as images, or explicit caching is enabled, it is of array type.
When using multimodal models or enabling explicit caching, content is an array where each element contains:
type string Required
Possible values:
- text: Set to text when inputting text
- image_url: Set to image_url when inputting images
- input_audio: Set to input_audio when inputting audio
- video: Set to video when inputting video as a list of images
- video_url: Set to video_url when inputting video files
text string
Input text. Required when type is text.
image_url object
Input image information. Required when type is image_url.
Properties
url string Required
Image URL or Base64 Data URL.
input_audio object
Input audio information. Required when type is input_audio.
Properties
data string Required
Audio URL or Base64 Data URL.
format string Required
Format of the input audio, such as mp3, wav, etc.
video array
Input video information in the form of an image list. Required when type is video.
video_url object
Input video file information. Required when type is video_url.
Properties
url string Required
Public URL or Base64 Data URL of the video file.
fps float (Optional)
Frames per second for extraction. Value range: [0.1, 10], default: 2.0.
min_pixels integer (Optional)
Sets the minimum pixel threshold for input images or video frames.
max_pixels integer (Optional)
Sets the maximum pixel threshold for input images or video frames.
total_pixels integer (Optional)
Limits the total pixels of all frames extracted from the video (single frame pixels × total number of frames).
cache_control object (Optional)
Used to enable explicit caching.
Properties
type string Required
Only supports being set to ephemeral.
Assistant Message object (Optional)
Model's response. Typically used as context passed back to the model in multi-turn conversations.
Properties
role string Required
Role of the assistant message, fixed as assistant.
content string (Optional)
Text content of the model's response. Can be empty when tool_calls is included; otherwise content is required.
partial boolean (Optional) Default: false
Whether to enable prefix continuation.
tool_calls array (Optional)
Tool and parameter information returned after initiating Function Calling.
Properties
id string Required
ID of the tool response.
type string Required
Tool type, currently only supports being set to function.
function object Required
Tool and parameter information.
Properties
name string Required
Tool name.
arguments string Required
Parameter information, as a JSON format string.
index integer Required
Index of the current tool information in the tool_calls array.
Tool Message object (Optional)
Output information from the tool.
Properties
role string Required
Fixed as tool.
content string Required
Output content of the tool function, must be a string.
tool_call_id string Required
The id returned after initiating Function Calling, used to identify which tool the Tool Message corresponds to.
stream boolean Optional Default: false
Whether to reply in streaming output mode.
Possible values:
- false: Returns all content at once after the model finishes generating
- true: Outputs while generating, returning a data chunk for each portion of content generated
Recommended to set to true to improve reading experience and reduce timeout risk.
Note
If a non-streaming call does not complete within 300 seconds, the service will interrupt the request and return the content generated so far (rather than returning an error). It is strongly recommended to use streaming calls for scenarios with longer outputs.
stream_options object Optional
Configuration options for streaming output, only effective when stream is true.
Properties
include_usage boolean (Optional) Default: false
Whether to include token consumption information in the last data chunk of the response.
During streaming output, token consumption information can only appear in the last data chunk of the response.
temperature float Optional
Sampling temperature, controls the diversity of text generated by the model. Higher temperature produces more diverse text; lower temperature produces more deterministic text.
Value range: [0, 2)
Both temperature and top_p can control the diversity of generated text. It is recommended to set only one of them.
temperature Default Values
- Qwen3.7 (non-thinking mode), Qwen3.6 (non-thinking mode), Qwen3.5 (non-thinking mode), Qwen3 (non-thinking mode), qwen-max series, qwen-plus series (non-thinking mode), qwen-flash series (non-thinking mode), qwen-turbo series (non-thinking mode), qwen open-source series, qwen-coder series, qwen-doc-turbo, Qwen3-VL (non-thinking): 0.7
- QVQ series: 0.5
- qwen-vl series, qwen2.5-omni-7b: 0.01
- qwen-math series: 0
- Qwen3.7 (thinking mode), Qwen3.6 (thinking mode), Qwen3.5 (thinking mode), Qwen3 (thinking mode), QwQ series: 0.6
- qwen3-max-preview (thinking mode), qwen-long series: 1.0
top_p float Optional
Nucleus sampling probability threshold, controls the diversity of text generated by the model. Higher top_p produces more diverse text; lower top_p produces more deterministic text.
Value range: (0, 1.0]
Both temperature and top_p can control the diversity of generated text. It is recommended to set only one of them.
top_k integer Optional
Specifies the number of candidate tokens used for sampling during generation. Larger values produce more random output; smaller values produce more deterministic output. If set to null or greater than 100, the top_k strategy is disabled.
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object. Configuration:
extra_body={"top_k":xxx}.
repetition_penalty float Optional
Repetition degree in consecutive sequences during model generation. Increasing repetition_penalty reduces repetition in model output. 1.0 means no penalty. Must be greater than 0.
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object. Configuration:
extra_body={"repetition_penalty":xxx}.
presence_penalty float Optional
Controls content repetition when the model generates text.
Value range: [-2.0, 2.0]. Positive values reduce repetition, negative values increase repetition.
response_format object Optional Default: {"type": "text"}
Format of the returned content.
Possible values:
- {"type": "text"}: Output text response
- {"type": "json_object"}: Output standard format JSON string
If set to
{"type": "json_object"}, you must explicitly instruct the model to output JSON in the prompt, e.g., "Please output in JSON format", otherwise an error will occur.
Properties
type string Required
Format of the returned content. Possible values: text / json_object.
max_tokens integer Optional Deprecated Soon
This parameter will be deprecated soon. For new integrations, please use
max_completion_tokens.
Maximum length of the model's response (excluding chain-of-thought content). When the model's response exceeds this value, generation will stop early and the returned finish_reason will be length.
max_completion_tokens integer Optional
Maximum length of the model's output, including chain-of-thought and model response. When the model's output exceeds this value, generation will stop early and the returned finish_reason will be length.
Difference from max_tokens: max_completion_tokens limits the model's complete output (chain-of-thought + response), while max_tokens only limits the response portion. Thinking models are recommended to use max_completion_tokens.
vl_high_resolution_images boolean Optional Default: false
Whether to increase the pixel upper limit of input images to the pixel value corresponding to 16384 tokens.
true: Uses fixed resolution strategy, ignoresmax_pixelssettingfalse: Pixel upper limit is determined bymax_pixels
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object. Configuration:
extra_body={"vl_high_resolution_images":xxx}.
n integer Optional Default: 1
Number of responses to generate, value range is 1-4. Suitable for scenarios requiring multiple candidate responses.
Only supported for Qwen3 (non-thinking mode) and qwen-plus-character models. If the
toolsparameter is passed, setnto 1.
thinking object Optional Default: {"type":"adaptive"}
Properties
thinking.type string
Possible values:
- adaptive: Adaptive (default), the model autonomously determines whether thinking is needed
- disabled: Disable thinking, respond directly
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object.
preserve_thinking boolean Optional Default: false
Whether to concatenate the reasoning_content from assistant messages in conversation history to the model input.
Important: When using qwen3.8-max, preserve_thinking defaults to true, and all reasoning_content from historical conversations must be passed back completely. This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object.
thinking_budget integer Optional
Maximum number of tokens for the thinking process. Applicable to Qwen3.7 and Qwen3.5.
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object.
reasoning_effort string Optional
Controls the model's reasoning intensity. Different models support different possible values and defaults.
- DeepSeek-V4, GLM series, and kimi/kimi-k3:
high(default) /max - qwen3.8-max model:
xhigh(default) /medium/low
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object.
tool_stream boolean Optional Default: false
Only effective when stream=true. Controls whether complex tool parameters are output in streaming mode.
false: Complex tool parameters are output all at once (default behavior), complex formats are more accuratetrue: Complex tool parameters are output in streaming mode, no timeout risk for complex formats
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object.
seed integer Optional
Random number seed. Used to ensure reproducible results with the same input and parameters.
Value range: [0, 2³¹−1]
logprobs boolean Optional Default: false
Whether to return log probabilities of output tokens.
Content generated during the thinking phase (
reasoning_content) will not return log probabilities.
top_logprobs integer Optional Default: 0
Specifies the number of highest-probability candidate tokens to return at each generation step. Value range: [0, 5]. Only effective when logprobs is true.
stop string / array Optional
Used to specify stop words. When the string or token_id specified by stop appears in the model-generated text, generation will terminate immediately.
tools array Optional
An array containing one or more tool objects for the model to call during Function Calling. When tools are set and the model determines a tool call is needed, the response will return tool information via tool_calls.
Function Calling
type string Required
Tool type, currently only supports being set to function.
function object Required
Properties
name string Required
Tool name. Only allows letters, numbers, underscores (_), and hyphens (-), maximum 64 tokens.
description string Required
Tool description information, helps the model determine when and how to call the tool.
parameters object (Optional) Default: {}
Parameter description for the tool, must be a valid JSON Schema. If the parameters field is empty, it means the tool has no input parameters.
tool_choice string / object Optional Default: auto
Tool selection strategy.
Possible values:
- auto: The model autonomously selects the tool strategy
- none: No tool calls desired
- {"type": "function", "function": {"name": "the_function_to_call"}}: Force calling a specific tool
Models in thinking mode do not support forcing a specific tool call.
parallel_tool_calls boolean Optional Default: false
Whether to enable parallel tool calls.
clear_thinking boolean Optional Default: false
Controls whether the reasoning_content (thinking process) from historical turns is included as context input to the model in multi-turn conversations. Only supported by GLM series.
true: Ignorereasoning_contentfrom historical turnsfalse(default): Preservereasoning_contentfrom historical turns
This parameter is not an OpenAI standard parameter. When calling via Python SDK, place it in the extra_body object.
Request Examples
Text Input (Non-streaming)
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
]
}'
Streaming Output
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
Image Input
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-vl-plus",
"messages": [{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"}},
{"type": "text", "text": "What is this"}
]
}]
}'
Video Input (Image List)
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-vl-max",
"messages": [{
"role": "user",
"content": [
{
"type": "video",
"video": [
"https://img.alicdn.com/imgextra/i3/O1CN01K3SgGo1eqmlUgeE9b_!!6000000003923-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01BjZvwg1Y23CF5qIRB_!!6000000003000-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01Ib0clU27vTgBdbVLQ_!!6000000007859-0-tps-3840-2160.jpg"
]
},
{"type": "text", "text": "Describe the specific process of this video"}
]
}]
}'
Tool Calling (Function Calling)
First Request
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the weather like in Hangzhou"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City or district, such as Beijing, Hangzhou, Yuhang, etc."
}
},
"required": ["location"]
}
}
}
]
}'
Second Request (Passing Tool Results)
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the weather like in Hangzhou"},
{
"role": "assistant",
"tool_calls": [
{
"id": "call_xxx",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": "{\"location\":\"Hangzhou\"}"
},
"index": 0
}
]
},
{
"role": "tool",
"tool_call_id": "call_xxx",
"content": "{\"location\":\"Hangzhou\",\"temperature\":\"25℃\",\"condition\":\"Sunny\"}"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City or district."
}
},
"required": ["location"]
}
}
}
]
}'
Deep Thinking
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{"role": "user", "content": "Write a quicksort algorithm in Python"}
],
"enable_thinking": true
}'
Structured Output (JSON)
curl -X POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions \
-H "Authorization: Bearer ${your_ak}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{"role": "user", "content": "Please output in JSON format: name, age, occupation"}
],
"response_format": {"type": "json_object"}
}'
Response Examples
Non-streaming Response Example
{
"id": "chatcmpl-6ada9ed2-7f33-9de2-8bb0-78bd4035025a",
"object": "chat.completion",
"created": 1735120033,
"model": "qwen3.8-max",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I am a large-scale language model developed by Alibaba Cloud, my name is Qwen.",
"reasoning_content": null,
"tool_calls": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"usage": {
"prompt_tokens": 3019,
"completion_tokens": 104,
"total_tokens": 3123,
"prompt_tokens_details": {
"cached_tokens": 2048
}
},
"system_fingerprint": null
}
Streaming Response Chunk Example
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":"","role":"assistant","tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":"I am","role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":" a large-scale language model from Alibaba Cloud, my name is Qwen.","role":null,"tool_calls":null},"finish_reason":"stop","index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","usage":{"completion_tokens":17,"prompt_tokens":22,"total_tokens":39,"prompt_tokens_details":{"cached_tokens":0}}}
/v1/messages Request URL
Header
| Parameter | Value |
|---|---|
| Authorization | Bearer |
| Content-Type | application/json |
Request Body
Request Parameters
model string Required
Model ID to call.
max_tokens integer Required
Maximum number of tokens for model output.
Model Differences
qwen3.8-max/deepseek‑v4‑pro: max_tokens = response tokens + thinking tokens total; when thinking is enabled,max_tokens > thinking.budget_tokens
system string / array Optional
System prompt, sets the model's role and behavior.
Format Description
- String form is equivalent to a single
type=textcontent block; - When enabling explicit caching (cache_control), array format must be used.
messages array Required
Conversation message array, complete session history.
Message Structure Description
role: user / assistant / system
content: Supports strings, and also structured arrays (text, images, video, tool_use, tool_result)
- Text block
- Image block (vision models)
- Video block (vision models)
- tool_use: Model returns tool call
- tool_result: Tool execution result passed back to the model
stream boolean Optional Default: false
Whether to enable streaming output.
- false: Non-streaming, returns complete response at once
- true: SSE streaming incremental return, includes content_block_start, content_block_delta, content_block_stop, message_delta, message_stop, ping events.
temperature number Optional
Value range: [0,2), controls generation randomness.
top_p number Optional
Nucleus sampling probability threshold. It is recommended to set only one of temperature or top_p.
top_k integer Optional
Sampling candidate set size.
stop_sequences array Optional
Custom stop sequences, terminates generation early when this text is encountered.
Behavior Description
After hitting a stop sequence, stop_reason will still be end_turn, and the response will not return the matched stop text.
thinking object Optional
Deep thinking configuration.
Properties
thinking.type string Required
- enabled: Enable deep thinking, returns thinking content block
- disabled: Disable deep thinking
thinking.budget_tokens integer
Only effective when
type=enabled, represents the maximum token budget for the thinking process, independent of max_tokens.
tools array Optional
Function Calling tool definition array.
Tool Structure Example
tool_choice object Optional
Tool calling strategy.
Possible Values
{"type":"auto"}: Model autonomously decides whether to call tools (default){"type":"any"}: Force calling any tool{"type":"none"}: Prohibit tool calls{"type":"tool","name":"xxx"}: Force calling a specific tool
output_config object Optional
Platform extension field for reasoning intensity and structured output configuration.
Properties
effort string: high / max, controls reasoning intensity; only supported by some models.
format object
Request Examples
Basic Non-streaming Call curl
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages" \
-H "Content-Type: application/json" \
-H "Authorization: ${your_ak}" \
-d '{
"model": "qwen3.8-max",
"max_tokens": 1024,
"system": "You are a helpful assistant",
"messages": [{"role": "user", "content": "Who are you?"}],
"thinking":{"type":"disabled"}
}'
Streaming Output curl
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages" \
-H "Content-Type: application/json" \
-H "Authorization: ${your_ak}" \
--no-buffer \
-d '{
"model": "qwen3.8-max",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Briefly introduce artificial intelligence"}],
"thinking":{"type":"disabled"}
}'
Deep Thinking Enabled curl
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages" \
-H "Content-Type: application/json" \
-H "Authorization: ${your_ak}" \
-d '{
"model": "qwen3.8-max",
"max_tokens":2048,
"stream":true,
"thinking":{"type":"enabled","budget_tokens":1024},
"messages":[{"role":"user","content":"Analyze the development prospects of quantum computing"}]
}'
Image Understanding curl
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages" \
-H "Content-Type: application/json" \
-H "Authorization: ${your_ak}" \
-d '{
"model":"qwen3.8-max",
"max_tokens":1024,
"stream":true,
"messages":[
{
"role":"user",
"content":[
{
"type":"image",
"source":{"type":"url","url":"https://xxx.jpg"}
},
{"type":"text","text":"Describe the image content"}
]
}
],
"thinking":{"type":"disabled"}
}'
Function Call curl
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages" \
-H "Content-Type: application/json" \
-H "Authorization: ${your_ak}" \
-d '{
"model":"qwen3.8-max",
"max_tokens":1024,
"tools":[
{
"name":"get_weather",
"description":"Get city weather",
"input_schema":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}
}
],
"messages":[{"role":"user","content":"What is the weather like in Hangzhou today"}]
}'
Explicit Caching curl
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages" \
-H "Content-Type: application/json" \
-H "Authorization: ${your_ak}" \
-d '{
"model":"qwen3.8-max",
"max_tokens":1024,
"system":[
{
"type":"text",
"text":"<≥1024 token long text>",
"cache_control":{"type":"ephemeral"}
}
],
"messages":[{"role":"user","content":"What is the content of this code"}]
}'
JSON Schema Structured Output curl
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages" \
-H "Content-Type: application/json" \
-H "Authorization: ${your_ak}" \
-d '{
"model":"deepseek-v4-pro",
"max_tokens":1024,
"messages":[{"role":"user","content":"Extract email information: Zhang San zhangsan@example.com, wants to schedule a product demo next Tuesday at 2 PM"}],
"output_config":{
"format":{
"type":"json_schema",
"schema":{
"type":"object",
"properties":{
"name":{"type":"string"},
"email":{"type":"string"},
"demo_requested":{"type":"boolean"}
},
"required":["name","email","demo_requested"],
"additionalProperties":false
}
}
}
}'
Response Examples
Non-streaming Response
{
"id": "msg_e2898f19-fc0e-4cb3-bd9b-5b7dc4ea3bc9",
"type": "message",
"role": "assistant",
"model": "qwen3.8-max",
"content": [
{
"type": "thinking",
"thinking": "Let me analyze this question...",
"signature": ""
},
{
"type": "text",
"text": "Hello! I am Tongyi Qwen..."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 22,
"output_tokens": 223,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}
Response Field Description
- content[]: Array, supports
texttext,thinkingthinking process,tool_usetool call blocks - stop_reason:
end_turnnormal completion /max_tokensreached output limit /tool_usetriggered tool call - usage:
cache_creation_input_tokenstokens consumed for cache creation;cache_read_input_tokenstokens from cache hits.
Streaming SSE Event Fragment
{"type":"message_start","message":{"id":"msg_xxx","type":"message","role":"assistant","model":"qwen3.8-max","content":[],"usage":{"input_tokens":15,"output_tokens":0}}}
{"type":"content_block_start","index":0,"content_block":{"type":"thinking","thinking":"","signature":""}}
{"type":"content_block_delta","index":0,"delta":{"type":"thinking_delta","thinking":"Thinking content..."}}
{"type":"content_block_stop","index":0}
{"type":"content_block_start","index":1,"content_block":{"type":"text","text":""}}
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"Model response text"}}
{"type":"content_block_stop","index":1}
{"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":15,"output_tokens":1078,"cache_creation_input_tokens":0,"cache_read_input_tokens":0}}
{"type":"message_stop"}
Streaming Event Description
message_start: Stream starts, only returnsinput_tokenscontent_block_start: Single content block startscontent_block_delta: Incremental data;text_delta/thinking_delta/input_json_deltacontent_block_stop: Single content block endsmessage_delta: Complete usage statistics, stop_reasonmessage_stop: Stream ends{"type":"ping"}: Keep-alive heartbeat, client should ignore directly.