Skip to content

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

POST https://az.gptplus5.com/v1/chat/completions

请求参数

Authorization

在 Header 添加参数Authorization,其值为在 Bearer 之后拼接 Token

示例:Authorization: Bearer ********************

Header 参数

参数名类型必需说明示例
Content-Typestring必需application/json
Acceptstring必需application/json
Authorizationstring可选Bearer {{YOUR_API_KEY}}
X-Forwarded-Hoststring可选localhost:5173

Body 参数 (application/json)

参数名类型必需说明
modelstring必需使用的模型的 ID。
max_tokensinteger可选限制一次请求中模型生成 completion 的最大 token 数。输入 token 和输出 token 的总长度受模型的上下文长度的限制。
messagesarray[object]必需
  └ rolestring必需
  └ contentstring必需
temperatureinteger可选使用什么采样温度,介于 0 和 2 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如 0.2)将使输出更加集中和确定。
streamboolean可选如果设置为 True,将会以 SSE(server-sent events)的形式以流式发送消息增量。消息流以 data: [DONE] 结尾。
stream_optionsobject可选流式输出相关选项。只有在 stream 参数为 true 时,才可设置此参数。
  └ include_usageboolean可选如果设置为 true,在流式消息最后的 data: [DONE] 之前将会传输一个额外的块。此块上的 usage 字段显示整个请求的 token 使用统计信息,而 choices 字段将始终是一个空数组。所有其他块也将包含一个 usage 字段,但其值为 null。
thinkingobject可选部分深度思考能力的模型支持通过 thinking 字段控制是否关闭深度思考能力。
  └ typestring可选enabled:默认强制开启,强制开启深度思考能力。 disabled:强制关闭深度思考能力。 auto:模型自行判断是否进行深度思考。

请求示例

json
{
  "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"
     }
}

cURL 示例

bash
curl --location --request POST 'https://az.gptplus5.com/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "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"
     }
}'

返回响应

🟢200OK

响应 Body

参数名类型必需说明
idstring必需
objectstring必需
createdinteger必需
choicesarray[object]必需
  └ indexinteger可选
  └ messageobject可选
  └ finish_reasonstring可选
usageobject必需
  └ prompt_tokensinteger必需
  └ completion_tokensinteger必需
  └ total_tokensinteger必需

响应示例

json
{
    "id": "chatcmpl-123",
    "object": "chat.completion",
    "created": 1677652288,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\n\nHello there, how may I assist you today?"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 9,
        "completion_tokens": 12,
        "total_tokens": 21
    }
}