跳转至

MaaS_Qwen

能力地图

qwen3.8-max

能力项 支持情况 能力项 支持情况
输入模态 Image Text Video 输出模态 Text
模型体验 支持 Function Calling 支持
结构化输出 支持 联网搜索 支持
前缀续写 支持 上下文缓存 支持
批量推理 支持 模型调优 不支持
参数 参数
最大输入长度 991808 最大输出长度 131072
最大输入长度(思考模式下) 983616 最大输出长度(思考模式下) 131072
上下文长度 1000000 最大思维链长度 262144

qwen3.7-max

能力项 支持情况 能力项 支持情况
输入模态 Image Text Video 输出模态 Text
模型体验 支持 Function Calling 支持
结构化输出 支持 联网搜索 支持
前缀续写 支持 上下文缓存 支持
批量推理 支持 模型调优 不支持
参数 参数
最大输入长度 991808 最大输出长度 131072
上下文长度 1000000 最大输入长度(思考模式下) 983616
最大输出长度(思考模式下) 131072 最大思维链长度 262144

qwen3.5-plus

能力项 支持情况 能力项 支持情况
输入模态 Image Text Video 输出模态 Text
模型体验 支持 Function Calling 支持
结构化输出 支持 联网搜索 支持
前缀续写 支持 上下文缓存 支持
批量推理 支持 模型调优 不支持

上下文限制

参数 参数
最大输入长度 991808 最大输出长度 65536
上下文长度 1000000 最大输入长度(思考模式下) 983616
最大输出长度(思考模式下) 65536 最大思维链长度 81920

/chat/completions 请求url

POST
https://genaiapi.cloudsway.net/v1/ai/{endpoint}/chat/completions
参数名
Authorization Bearer
Content-Type application/json

请求Body

请求参数

model string 必选

模型名称。


messages array 必选

传递给大模型的上下文,按对话顺序排列。

消息类型

System Message object (可选)

系统消息,用于设定大模型的角色、语气、任务目标或约束条件等。一般放在messages数组的第一位。

QwQ 模型不建议设置 System Message,QVQ 模型设置 System Message不会生效。

属性

role string 必选

系统消息的角色,固定为 system

content string 必选

系统指令,用于明确模型的角色、行为规范、回答风格和任务约束等。

User Message object (必选)

用户消息,用于向模型传递问题、指令或上下文等。

属性

role string 必选

用户消息的角色,固定为user

content string / array 必选

消息内容。若输入只有文本,则为 string 类型;若输入包含图像等多模态数据,或启用显式缓存,则为 array 类型。

使用多模态模型或启用显式缓存时,content 为 array,每个元素包含:

type string 必选

可选值: - text:输入文本时需设为text - image_url:输入图片时需设为image_url - input_audio:输入音频时需设为input_audio - video:输入图片列表形式的视频时需设为video - video_url:输入视频文件时需设为video_url

text string

输入的文本。当typetext时,是必选参数。

image_url object

输入的图片信息。当typeimage_url时是必选参数。

属性

url string 必选

图片的 URL或 Base64 Data URL。

input_audio object

输入的音频信息。当typeinput_audio时是必选参数。

属性

data string 必选

音频的 URL 或Base64 Data URL。

format string 必选

输入音频的格式,如mp3wav等。

video array

输入的图片列表形式的视频信息。当typevideo时是必选参数。

video_url object

输入的视频文件信息。当typevideo_url时是必选参数。

属性

url string 必选

视频文件的公网 URL 或 Base64 Data URL。

fps float (可选)

每秒抽帧数。取值范围为 [0.1, 10],默认值为2.0。

min_pixels integer (可选)

设定输入图像或视频帧的最小像素阈值。

max_pixels integer (可选)

设定输入图像或视频帧的最大像素阈值。

total_pixels integer (可选)

限制从视频中抽取的所有帧的总像素(单帧图像像素 × 总帧数)。

cache_control object (可选)

用于开启显式缓存。

属性

type string 必选

仅支持设定为ephemeral

Assistant Message object (可选)

模型的回复。通常用于在多轮对话中作为上下文回传给模型。

属性

role string 必选

助手消息的角色,固定为assistant

content string (可选)

模型回复的文本内容。包含tool_calls时,content可以为空;否则content为必选。

partial boolean (可选)默认值为false

是否开启前缀续写。

tool_calls array (可选)

发起 Function Calling 后,返回的工具与入参信息。

属性

id string 必选

工具响应的ID。

type string 必选

工具类型,当前只支持设为function

function object 必选

工具与入参信息。

属性

name string 必选

工具名称。

arguments string 必选

入参信息,为JSON格式字符串。

index integer 必选

当前工具信息在tool_calls数组中的索引。

Tool Message object (可选)

工具的输出信息。

属性

role string 必选

固定为tool

content string 必选

工具函数的输出内容,必须为字符串。

tool_call_id string 必选

发起 Function Calling 后返回的 id,用于标记 Tool Message 对应的工具。


stream boolean 可选 默认值:false

是否以流式输出方式回复。

可选值: - false:模型生成全部内容后一次性返回 - true:边生成边输出,每生成一部分内容即返回一个数据块(chunk)

推荐设置为true,可提升阅读体验并降低超时风险。

说明

非流式调用若超过 300 秒未完成,服务将中断请求并返回已生成的内容(而非报错)。建议输出较长的场景务必使用流式调用。


stream_options object 可选

流式输出的配置项,仅在 streamtrue 时生效。

属性

include_usage boolean (可选)默认值为false

是否在响应的最后一个数据块包含Token消耗信息。

流式输出时,Token 消耗信息仅可出现在响应的最后一个数据块。


temperature float 可选

采样温度,控制模型生成文本的多样性。temperature越高,生成的文本更多样,反之,生成的文本更确定。

取值范围:[0, 2)

temperature与top_p均可以控制生成文本的多样性,建议只设置其中一个值。

temperature默认值
  • Qwen3.7(非思考模式)、Qwen3.6(非思考模式)、Qwen3.5(非思考模式)、Qwen3(非思考模式)、qwen-max系列、qwen-plus系列(非思考模式)、qwen-flash系列(非思考模式)、qwen-turbo系列(非思考模式)、qwen开源系列、qwen-coder系列、qwen-doc-turbo、Qwen3-VL(非思考):0.7
  • QVQ系列 : 0.5
  • qwen-vl系列、qwen2.5-omni-7b:0.01
  • qwen-math系列:0
  • Qwen3.7(思考模式)、Qwen3.6(思考模式)、Qwen3.5(思考模式)、Qwen3(思考模式)、QwQ 系列:0.6
  • qwen3-max-preview(思考模式)、qwen-long系列:1.0

top_p float 可选

核采样的概率阈值,控制模型生成文本的多样性。top_p越高,生成的文本更多样。反之,生成的文本更确定。

取值范围:(0, 1.0]

temperature与top_p均可以控制生成文本的多样性,建议只设置其中一个值。


top_k integer 可选

指定生成过程中用于采样的候选 Token 数量。值越大,输出越随机;值越小,输出越确定。若设为 null 或大于 100,则禁用 top_k 策略。

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。配置方式为:extra_body={"top_k":xxx}


repetition_penalty float 可选

模型生成时连续序列中的重复度。提高repetition_penalty时可以降低模型生成的重复度,1.0表示不做惩罚。只要大于0即可。

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。配置方式为:extra_body={"repetition_penalty":xxx}


presence_penalty float 可选

控制模型生成文本时的内容重复度。

取值范围:[-2.0, 2.0]。正值降低重复度,负值增加重复度。


response_format object 可选 默认值:{"type": "text"}

返回内容的格式。

可选值: - {"type": "text"}:输出文字回复 - {"type": "json_object"}:输出标准格式的JSON字符串

若指定为{"type": "json_object"},需在提示词中明确指示模型输出JSON,如:"请按照json格式输出",否则会报错。

属性

type string 必选

返回内容的格式。可选值:text / json_object


max_tokens integer 可选 即将废弃

该参数即将废弃,新接入请使用 max_completion_tokens

模型回答的最大长度(不包含思维链内容)。模型回答超过此值时将提前停止,返回的 finish_reasonlength


max_completion_tokens integer 可选

模型输出的最大长度,包含思维链和模型回答。模型输出超过此值时生成将提前停止,返回的 finish_reasonlength

max_tokens 的区别:max_completion_tokens 限制模型完整输出(思维链 + 回答),而 max_tokens 仅限制回答部分。思考类模型推荐使用 max_completion_tokens


vl_high_resolution_images boolean 可选 默认值:false

是否将输入图像的像素上限提升至 16384 Token 对应的像素值。

  • true:使用固定分辨率策略,忽略 max_pixels 设置
  • false:像素上限由 max_pixels 决定

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。配置方式为:extra_body={"vl_high_resolution_images":xxx}


n integer 可选 默认值:1

生成响应的数量,取值范围是1-4。适用于需生成多个候选响应的场景。

仅支持 Qwen3(非思考模式)、qwen-plus-character 模型。 若传入 tools 参数,请将n设为 1。


thinking object 可选 默认值:{"type":"adaptive"}

属性

thinking.type string

可选值: - adaptive:自适应(默认),模型自主判断是否需要思考 - disabled:关闭思考,直接回答

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。


preserve_thinking boolean 可选 默认值:false

是否将对话历史中 assistant 消息的 reasoning_content 拼接至模型输入。

重要:使用 qwen3.8-max 时,preserve_thinking 默认为 true,必须将历史对话中所有的 reasoning_content 完整回传。 该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。


thinking_budget integer 可选

思考过程的最大 Token 数。适用于Qwen3.7、Qwen3.5。

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。


reasoning_effort string 可选

控制模型的推理力度,不同模型支持的可选值和默认值不同。

  • DeepSeek-V4、GLM 系列与 kimi/kimi-k3:high(默认)/ max
  • qwen3.8-max 模型:xhigh(默认)/ medium / low

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。


tool_stream boolean 可选 默认值:false

仅在stream=true时生效。控制复杂工具参数是否流式输出。

  • false:复杂工具参数会一次性输出,默认行为,复杂格式会更准确
  • true:复杂工具参数会流式输出,复杂格式没有超时风险

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。


seed integer 可选

随机数种子。用于确保在相同输入和参数下生成结果可复现。

取值范围:[0, 2³¹−1]


logprobs boolean 可选 默认值:false

是否返回输出 Token 的对数概率。

思考阶段生成的内容(reasoning_content)不会返回对数概率。


top_logprobs integer 可选 默认值:0

指定在每一步生成时,返回模型最大概率的候选 Token 个数。取值范围:[0, 5]。仅当 logprobstrue 时生效。


stop string / array 可选

用于指定停止词。当模型生成的文本中出现 stop 指定的字符串或 token_id 时,生成将立即终止。


tools array 可选

包含一个或多个工具对象的数组,供模型在 Function Calling 中调用。设置 tools 且模型判断需要调用工具时,响应会通过 tool_calls 返回工具信息。

函数调用 (Function Calling)

type string 必选

工具类型,当前仅支持设为function

function object 必选

属性

name string 必选

工具名称。仅允许字母、数字、下划线(_)和短划线(-),最长 64 个 Token。

description string 必选

工具描述信息,帮助模型判断何时以及如何调用该工具。

parameters object (可选)默认值为 {}

工具的参数描述,需要是一个合法的JSON Schema。若parameters参数为空,表示该工具没有入参。


tool_choice string / object 可选 默认值:auto

工具选择策略。

可选值: - auto:大模型自主选择工具策略 - none:不希望进行工具调用 - {"type": "function", "function": {"name": "the_function_to_call"}}:强制调用某个工具

思考模式的模型不支持强制调用某个工具。


parallel_tool_calls boolean 可选 默认值:false

是否开启并行工具调用。


clear_thinking boolean 可选 默认值:false

用于控制多轮对话中是否将历史轮次的 reasoning_content(思考过程)作为上下文输入给模型。仅 GLM 系列支持。

  • true:忽略历史轮次的 reasoning_content
  • false(默认):保留历史轮次的 reasoning_content

该参数非OpenAI标准参数。通过 Python SDK调用时,请放入 extra_body 对象中。

请求示例

文本输入(非流式)

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": "你是谁?"}
    ]
}'

流式输出

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": "你是谁?"}
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    }
}'

图像输入

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": "这是什么"}
        ]
    }]
}'

视频输入(图片列表)

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": "描述这个视频的具体过程"}
        ]
    }]
}'

工具调用(Function Calling)

第一次请求

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": "杭州天气怎么样"}
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_current_weather",
                "description": "当你想查询指定城市的天气时非常有用。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "城市或县区,比如北京市、杭州市、余杭区等。"
                        }
                    },
                    "required": ["location"]
                }
            }
        }
    ]
}'

第二次请求(传入工具结果)

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": "杭州天气怎么样"},
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": "call_xxx",
                    "type": "function",
                    "function": {
                        "name": "get_current_weather",
                        "arguments": "{\"location\":\"杭州\"}"
                    },
                    "index": 0
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_xxx",
            "content": "{\"location\":\"杭州\",\"temperature\":\"25℃\",\"condition\":\"晴\"}"
        }
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_current_weather",
                "description": "当你想查询指定城市的天气时非常有用。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "城市或县区。"
                        }
                    },
                    "required": ["location"]
                }
            }
        }
    ]
}'

深度思考

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": "用Python写一个快速排序算法"}
    ],
    "enable_thinking": true
}'

结构化输出(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": "请按照json格式输出:姓名、年龄、职业"}
    ],
    "response_format": {"type": "json_object"}
}'

响应示例

非流式响应示例

{
    "id": "chatcmpl-6ada9ed2-7f33-9de2-8bb0-78bd4035025a",
    "object": "chat.completion",
    "created": 1735120033,
    "model": "qwen3.8-max",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "我是阿里云开发的一款超大规模语言模型,我叫千问。",
                "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
}

流式响应 chunk 示例

{"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":"我是","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":"阿里云的超大规模语言模型,我叫千问。","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 请求url

POST
https://genaiapi.cloudsway.net/{endpoint}/v1/messages

Header

参数名
Authorization Bearer
Content-Type application/json

请求Body

请求参数

model string 必选

调用模型ID。


max_tokens integer 必选

模型输出最大token数量。

模型差异说明
  • qwen3.8-max / deepseek‑v4‑pro:max_tokens = 回复token + thinking思考token总和;开启思考时 max_tokens > thinking.budget_tokens

system string / array 可选

系统提示词,设定模型角色与行为。

格式说明
  • 字符串形式等价于单个type=text内容块;
  • 需要开启显式缓存cache_control时,必须使用数组格式。
    [
        {
            "type":"text",
            "text":"你是助手",
            "cache_control":{"type":"ephemeral"}
        }
    ]
    

messages array 必选

对话消息数组,完整会话历史。

消息结构说明

roleuser / assistant / system content:支持字符串,也支持结构化数组(文本、图片、视频、tool_use、tool_result)

  • 文本块
    {"type":"text","text":"xxx","cache_control":{"type":"ephemeral"}}
    
  • 图片块(视觉模型)
    {"type":"image","source":{"type":"url","url":"https://xxx.jpg"}}
    
  • 视频块(视觉模型)
    {"type":"video","source":{"type":"url","url":"https://xxx.mp4"}}
    
  • tool_use:模型返回工具调用
  • tool_result:工具执行结果回传给模型

stream boolean 可选 默认false

是否开启流式输出。 - false:非流式一次性返回完整响应 - true:SSE流式增量返回,包含content_block_startcontent_block_deltacontent_block_stopmessage_deltamessage_stopping事件。


temperature number 可选

取值范围:[0,2),控制生成随机性。


top_p number 可选

核采样概率阈值。建议temperaturetop_p只设置其中一个。


top_k integer 可选

采样候选集大小。


stop_sequences array 可选

自定义停止序列,遇到该文本提前终止生成。

行为说明

命中停止序列后stop_reason仍然为end_turn,响应不会返回命中的stop文本。


thinking object 可选

深度思考配置。

属性

thinking.type string 必选 - enabled:开启深度思考,返回thinking内容块 - disabled:关闭深度思考

thinking.budget_tokens integer

type=enabled生效,代表思考过程最大token预算,与max_tokens相互独立。


tools array 可选

Function Calling工具定义数组。

工具结构示例
[
    {
        "name":"get_weather",
        "description":"获取城市天气",
        "input_schema":{
            "type":"object",
            "properties":{"city":{"type":"string"}},
            "required":["city"]
        }
    }
]

tool_choice object 可选

工具调用策略。

可选枚举
  • {"type":"auto"}:模型自主决定是否调用工具(默认)
  • {"type":"any"}:强制调用任意工具
  • {"type":"none"}:禁止调用工具
  • {"type":"tool","name":"xxx"}:强制调用指定工具

output_config object 可选

百炼平台扩展字段,推理力度、结构化输出配置。

属性

effort stringhigh / max,控制推理强度;仅部分模型支持。

format object

{
    "type":"json_schema",
    "schema":{
        "type":"object",
        "properties":{},
        "required":[],
        "additionalProperties":false
    }
}

请求示例

基础非流式调用 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": "你是谁?"}],
    "thinking":{"type":"disabled"}
}'

流式输出 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": "简单介绍人工智能"}],
    "thinking":{"type":"disabled"}
}'

深度思考开启 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":"分析量子计算发展前景"}]
}'

图片理解 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":"描述图片内容"}
            ]
        }
    ],
    "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":"获取城市天气",
            "input_schema":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}
        }
    ],
    "messages":[{"role":"user","content":"杭州今天天气怎么样"}]
}'

显式缓存 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":"<≥1024token长文本>",
            "cache_control":{"type":"ephemeral"}
        }
    ],
    "messages":[{"role":"user","content":"这段代码的内容是什么"}]
}'

JSON Schema结构化输出 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":"提取邮件信息:张三 zhangsan@example.com,想要预约下周二下午2点产品演示"}],
    "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
            }
        }
    }
}'

响应示例

非流式响应

{
    "id": "msg_e2898f19-fc0e-4cb3-bd9b-5b7dc4ea3bc9",
    "type": "message",
    "role": "assistant",
    "model": "qwen3.8-max",
    "content": [
        {
            "type": "thinking",
            "thinking": "让我分析一下这个问题...",
            "signature": ""
        },
        {
            "type": "text",
            "text": "你好!我是通义千问..."
        }
    ],
    "stop_reason": "end_turn",
    "stop_sequence": null,
    "usage": {
        "input_tokens": 22,
        "output_tokens": 223,
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0
    }
}
响应字段说明
  • content[]:数组,支持text文本、thinking思考过程、tool_use工具调用块
  • stop_reasonend_turn正常结束 / max_tokens达到输出上限 / tool_use触发工具调用
  • usagecache_creation_input_tokens创建缓存消耗token;cache_read_input_tokens命中缓存token。

流式SSE事件片段

{"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":"思考内容..."}}
{"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":"模型回复文本"}}
{"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"}
流式事件说明
  • message_start:流开始,仅返回input_tokens
  • content_block_start:单个内容块开始
  • content_block_delta:增量数据;text_delta/thinking_delta/input_json_delta
  • content_block_stop:单个内容块结束
  • message_delta:完整usage统计、stop_reason
  • message_stop:流结束
  • {"type":"ping"}:保活心跳,客户端直接忽略。