返回模型调用 API 参考
POST/v1/chat/completions

创建聊天补全 deepseek v3.1思考程度 (流式)

API Key application/json
Chat Completions 兼容协议

调用与返回说明

适合已经依赖 Chat Completions 的客户端和模型。新建 OpenAI 集成时优先确认模型支持 Responses API,再决定是否使用此兼容协议。

请求时注意

  • model 和 messages 是基本必填项;tools、tool_choice、response_format 等能力参数按场景发送,不是所有模型都支持。
  • 模型 ID 以 GET /v1/models 的返回为准。示例中的固定模型名只是格式示例,不代表当前账号一定可用。
  • 对于新推理模型,优先使用 max_completion_tokens;max_tokens 是旧字段,且可能与推理模型不兼容。

返回时注意

  • 非流式文本读取 choices[0].message.content,并检查 choices[0].finish_reason。
  • 流式读取 choices[].delta.content,收到 finish_reason 后结束;如需用量,在请求中确认服务支持 stream_options.include_usage。
  • Chat Completions 的工具调用位于 choices[].message.tool_calls,不能与 Responses 的 output[].type=function_call 混读。

请求示例

curl -X POST https://top.qingyuntop.ai/v1/chat/completions \
  -H "Authorization: Bearer ${QINGYUN_TOP_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "deepseek-v3-1-250821",
  "max_tokens": 1000,
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "你好"
    }
  ],
  "temperature": 1.0,
  "stream": true,
  "stream_options": {
    "include_usage": true
  },
     "thinking":{
         "type":"enabled"
     }
}'

请求参数

参数位置类型必填说明示例
Content-TypeHeaderstring-application/json
AcceptHeaderstring-application/json
AuthorizationHeaderstring-Bearer {{YOUR_API_KEY}}
X-Forwarded-HostHeaderstring-localhost:5173
modelJSON bodystring使用的模型的 ID。 必填。使用 GET /v1/models 返回的准确模型 ID。-
max_tokensJSON bodyinteger限制一次请求中模型生成 completion 的最大 token 数。输入 token 和输出 token 的总长度受模型的上下文长度的限制。 兼容旧模型的历史字段。新推理模型优先改用 max_completion_tokens,具体以模型能力为准。-
messagesJSON bodyarray<object>对话的消息列表。 必填。按 role 和 content 组成对话消息;多模态 content 使用该模型支持的内容块格式。-
messages[].roleJSON bodystring--
messages[].contentJSON bodystring--
temperatureJSON bodyinteger使用什么采样温度,介于 0 和 2 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如 0.2)将使输出更加集中和确定。-
streamJSON bodyboolean如果设置为 True,将会以 SSE(server-sent events)的形式以流式发送消息增量。消息流以 data: [DONE] 结尾。 可选,默认 false。为 true 时返回 chat.completion.chunk 增量。-
stream_optionsJSON bodyobject流式输出相关选项。只有在 stream 参数为 true 时,才可设置此参数。-
stream_options.include_usageJSON bodyboolean如果设置为 true,在流式消息最后的 data: [DONE] 之前将会传输一个额外的块。此块上的 usage 字段显示整个请求的 token 使用统计信息,而 choices 字段将始终是一个空数组。所有其他块也将包含一个 usage 字段,但其值为 null。-
thinkingJSON bodyobject部分深度思考能力的模型支持通过 thinking 字段控制是否关闭深度思考能力。-
thinking.typeJSON bodystringenabled:默认强制开启,强制开启深度思考能力。 disabled:强制关闭深度思考能力。 auto:模型自行判断是否进行深度思考。-

返回响应 (200)

参数位置类型必填说明示例
id响应 JSONstring--
object响应 JSONstring--
created响应 JSONinteger--
choices响应 JSONarray<object>--
choices[].index响应 JSONinteger--
choices[].message响应 JSONobject--
choices[].message.role响应 JSONstring--
choices[].message.content响应 JSONstring--
choices[].finish_reason响应 JSONstring--
usage响应 JSONobject--
usage.prompt_tokens响应 JSONinteger--
usage.completion_tokens响应 JSONinteger--
usage.total_tokens响应 JSONinteger--

响应示例

{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "model": "MODEL_ID_FROM_V1_MODELS",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "你好,我可以帮助你。"},
      "finish_reason": "stop"
    }
  ],
  "usage": {"prompt_tokens": 18, "completion_tokens": 12, "total_tokens": 30}
}

流式事件示例

下面只展示事件形状。生产客户端应按事件类型处理增量、完成、失败和未完成事件,并设置读取超时。

data: {"id":"chatcmpl_example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"你好"},"finish_reason":null}]}

data: {"id":"chatcmpl_example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]
来源原始接口定义(用于追溯)

以下内容来自 Apifox 快照,可能包含兼容层字段或旧示例;公开调用请以本页的协议说明和当前模型列表为准。

{
  "id": 497673426,
  "name": "创建聊天补全  deepseek v3.1思考程度 (流式)",
  "type": "http",
  "serverId": "",
  "preProcessors": [],
  "postProcessors": [],
  "inheritPreProcessors": {},
  "inheritPostProcessors": {},
  "description": "",
  "operationId": "",
  "sourceUrl": "",
  "method": "post",
  "path": "/v1/chat/completions",
  "tags": [],
  "status": 1,
  "requestBody": {
    "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"
      ]
    },
    "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"
      }
    ],
    "mediaType": "",
    "oasExtensions": "",
    "required": false,
    "additionalContentTypes": []
  },
  "parameters": {
    "path": [],
    "query": [],
    "cookie": [],
    "header": [
      {
        "id": "NQs7bxnpZf",
        "name": "Content-Type",
        "required": true,
        "enable": true,
        "description": "",
        "type": "string",
        "sampleValue": "application/json"
      },
      {
        "id": "qb8tEQbCty",
        "name": "Accept",
        "required": true,
        "enable": true,
        "description": "",
        "type": "string",
        "sampleValue": "application/json"
      },
      {
        "id": "gBxcCbXhsa",
        "name": "Authorization",
        "required": false,
        "enable": true,
        "description": "",
        "type": "string",
        "sampleValue": "Bearer {{YOUR_API_KEY}}"
      },
      {
        "id": "t8P0euDZvz",
        "name": "X-Forwarded-Host",
        "required": false,
        "enable": false,
        "description": "",
        "type": "string",
        "sampleValue": "localhost:5173"
      }
    ]
  },
  "commonParameters": {
    "query": [],
    "body": [],
    "cookie": [],
    "header": []
  },
  "auth": {},
  "responses": [
    {
      "id": 163134292,
      "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": ""
    }
  ],
  "responseExamples": [
    {
      "name": "OK",
      "responseId": 163134292,
      "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": "019fd25e-4bec-7266-8756-9dff3d9793f2"
    }
  ],
  "codeSamples": [],
  "projectId": 8662722,
  "moduleId": 8310462,
  "folderId": 92749354,
  "ordering": 78,
  "responsibleId": 0,
  "commonResponseStatus": {},
  "advancedSettings": {
    "disabledSystemHeaders": {},
    "isDefaultUrlEncoding": 1
  },
  "customApiFields": {},
  "oasExtensions": "",
  "mockScript": {},
  "createdAt": "2026-08-05T14:40:23.000Z",
  "updatedAt": "2026-08-06T12:15:55.000Z",
  "creatorId": 2863449,
  "editorId": 2863449,
  "creatorUserId": 2863449,
  "editorUserId": 2863449,
  "responseChildren": [
    "BLANK.163134292"
  ],
  "visibility": "INHERITED",
  "securityScheme": {},
  "callbacks": ""
}