快速开始
POST
https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
1.
2.
1.
incremental_output
参数默认为 true
,且不支持设置为 false
,仅支持增量流式返回;2.
response_format
参数默认为"message"
。请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions' \
--header 'Authorization: Bearer {{DASHSCOPE_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "qwq-32b",
"messages": [
{
"role": "user",
"content": "9.9和9.11谁大"
}
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
响应示例响应示例
data: {"choices":[{"delta":{"content":null,"role":"assistant","reasoning_content":""},"index":0,"logprobs":null,"finish_reason":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"finish_reason":null,"delta":{"content":null,"reasoning_content":"嗯"},"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"delta":{"content":null,"reasoning_content":","},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"delta":{"content":null,"reasoning_content":"用户"},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
......
data: {"choices":[{"delta":{"content":"需","reasoning_content":null},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"delta":{"content":"进一步","reasoning_content":null},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"delta":{"content":"确认","reasoning_content":null},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"delta":{"content":"规则","reasoning_content":null},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"delta":{"content":"。","reasoning_content":null},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[{"finish_reason":"stop","delta":{"content":"","reasoning_content":null},"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: {"choices":[],"object":"chat.completion.chunk","usage":{"prompt_tokens":18,"completion_tokens":1015,"total_tokens":1033},"created":1741185359,"system_fingerprint":null,"model":"qwq-32b","id":"chatcmpl-6c2000e7-b744-9e61-bd03-fc4333d0e5d1"}
data: [DONE]
请求参数
Header 参数
Authorization
string
必需
示例值:
Bearer {{DASHSCOPE_API_KEY}}
Content-Type
string
必需
示例值:
application/json
Body 参数application/json