创建聊天补全 deepseek v3.1思考程度 (流式)
POST /v1/chat/completions
概览
| Method | POST |
|---|---|
| Path | /v1/chat/completions |
| Type | http |
| Status | 1 |
| Module | 2102810 |
| Folder | 45008044 |
参数
{ "header": [ { "id": "NQs7bxnpZf", "name": "Content-Type", "required": true, "description": "", "type": "string", "enable": true, "sampleValue": "application/json" }, { "id": "qb8tEQbCty", "name": "Accept", "required": true, "description": "", "type": "string", "enable": true, "sampleValue": "application/json" }, { "required": false, "description": "", "type": "string", "id": "gBxcCbXhsa", "enable": true, "name": "Authorization", "sampleValue": "Bearer {{YOUR_API_KEY}}" }, { "required": false, "description": "", "type": "string", "id": "t8P0euDZvz", "enable": false, "name": "X-Forwarded-Host", "sampleValue": "localhost:5173" } ] }
请求体
{ "type": "application/json", "parameters": [], "jsonSchema": { "type": "object", "properties": { "model": { "type": "string", "description": "使用的模型的 ID。" }, "max_tokens": { "type": "integer", "description": "限制一次请求中模型生成 completion 的最大 token 数。输入 token 和输出 token 的总长度受模型的上下文长度的限制。" }, "messages": { "type": "array", "items": { "type": "object", "properties": { "role": { "type": "string" }, "content": { "type": "string" } }, "required": [ "role", "content" ], "x-apifox-orders": [ "role", "content" ] }, "description": "对话的消息列表。" }, "temperature": { "type": "integer", "description": "使用什么采样温度,介于 0 和 2 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如 0.2)将使输出更加集中和确定。" }, "stream": { "type": "boolean", "description": "如果设置为 True,将会以 SSE(server-sent events)的形式以流式发送消息增量。消息流以 data: [DONE] 结尾。" }, "stream_options": { "type": "object", "properties": { "include_usage": { "type": "boolean", "description": "如果设置为 true,在流式消息最后的 data: [DONE] 之前将会传输一个额外的块。此块上的 usage 字段显示整个请求的 token 使用统计信息,而 choices 字段将始终是一个空数组。所有其他块也将包含一个 usage 字段,但其值为 null。" } }, "x-apifox-orders": [ "include_usage" ], "description": "流式输出相关选项。只有在 stream 参数为 true 时,才可设置此参数。" }, "thinking": { "type": "object", "properties": { "type": { "type": "string", "description": "enabled:默认强制开启,强制开启深度思考能力。\ndisabled:强制关闭深度思考能力。\nauto:模型自行判断是否进行深度思考。" } }, "x-apifox-orders": [ "type" ], "description": "部分深度思考能力的模型支持通过 thinking 字段控制是否关闭深度思考能力。" } }, "required": [ "model", "messages" ], "x-apifox-orders": [ "model", "max_tokens", "messages", "temperature", "stream", "stream_options", "thinking" ] }, "mediaType": "", "examples": [ { "value": "{\n \"model\": \"deepseek-v3-1-250821\",\n \"max_tokens\": 1000,\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"你好\"\n }\n ],\n \"temperature\": 1.0,\n \"stream\": true,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"thinking\":{\n \"type\":\"enabled\"\n }\n}", "mediaType": "application/json" } ], "oasExtensions": "" }
响应
[ { "id": 751807117, "name": "OK", "code": 200, "contentType": "json", "jsonSchema": { "type": "object", "properties": { "id": { "type": "string" }, "object": { "type": "string" }, "created": { "type": "integer" }, "choices": { "type": "array", "items": { "type": "object", "properties": { "index": { "type": "integer" }, "message": { "type": "object", "properties": { "role": { "type": "string" }, "content": { "type": "string" } }, "required": [ "role", "content" ], "x-apifox-orders": [ "role", "content" ] }, "finish_reason": { "type": "string" } }, "x-apifox-orders": [ "index", "message", "finish_reason" ] } }, "usage": { "type": "object", "properties": { "prompt_tokens": { "type": "integer" }, "completion_tokens": { "type": "integer" }, "total_tokens": { "type": "integer" } }, "required": [ "prompt_tokens", "completion_tokens", "total_tokens" ], "x-apifox-orders": [ "prompt_tokens", "completion_tokens", "total_tokens" ] } }, "required": [ "id", "object", "created", "choices", "usage" ], "x-apifox-orders": [ "id", "object", "created", "choices", "usage" ] }, "itemSchema": {}, "description": "", "mediaType": "", "headers": [], "oasExtensions": "" } ]
响应示例
[ { "name": "OK", "responseId": 751807117, "data": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\"\n },\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}", "description": "", "oasKey": "", "oasExtensions": "", "id": 670505148 } ]