进阶 api-docs.deepseek.com 2026-10-13 22:45:34 · 29 阅读
第1章 Chat Completions API 参考
Chat Completions API
POST /chat/completions
为给定的对话创建模型响应。
请求 (Request)
application/json Body required
messages: object[] required
可能取值: >= 1
目前对话的消息列表。
Array [oneOf System message User message Assistant message Tool message
content: string required
系统消息的内容。
role: string required
可能取值: [system]
消息作者的角色,在此为 system。
name: string
参与者的可选名称。提供信息以便模型区分同一角色的不同参与者。
content: string | object[] required
用户消息的内容。可以是字符串,也可以是内容部分数组(用于图像输入)。详情请参阅 Vision 指南。
oneOf Text content Array of content parts
string
Array [oneOf Text content part Image content part File content part
type: string required
可能取值: [text]
内容部分的类型,在此为 text。
text: string required
文本内容。
type: string required
可能取值: [image_url]
内容部分的类型,在此为 image_url。
image_url: object required
url: string required
图像的 http(s) URL(最多 8192 个字符)或 base64 编码的数据 URL(data:image/jpeg;base64,...)。支持的格式:JPEG、PNG、GIF 和 WebP。
detail: string
可能取值: [low, high, original, auto]
控制图像的处理方式。low 将图像下采样至 512x512(速度更快,成本更低)。high、original 和 auto 保留原始图像。
type: string required
可能取值: [file]
内容部分的类型,在此为 file。
file_id: string
通过 Files API 上传的文件 ID,形式为 file-api-...。与 file_data 互斥。
file_data: string
图像的 base64 编码数据 URL(data:image/jpeg;base64,...)。与 file_id 互斥。
filename: string
可选的文件名。仅与 file_data 一起有效。
]
role: string required
可能取值: [user]
消息作者的角色,在此为 user。
name: string
参与者的可选名称。提供信息以便模型区分同一角色的不同参与者。
content: string nullable required
助手消息的内容。
role: string required
可能取值: [assistant]
消息作者的角色,在此为 assistant。
name: string
参与者的可选名称。提供信息以便模型区分同一角色的不同参与者。
prefix: bool (Beta)
设置为 true 可强制模型以该助手消息中提供的 prefix 内容作为回答的开头。
必须设置 base_url="https://api.deepseek.com/beta" 才能使用此功能。
reasoning_content: string nullable (Beta)
用于 Chat Prefix Completion 功能中思考模式的输入,作为最后一条助手消息中 CoT 的输入。使用此功能时,必须将 prefix 参数设置为 true。
role: string required
可能取值: [tool]
消息作者的角色,在此为 tool。
content: string | object[] required
工具消息的内容。可以是字符串,也可以是内容部分数组(用于图像输入)。详情请参阅 Vision 指南。
oneOf Text content Array of content parts
string
Array [oneOf Text content part Image content part File content part
type: string required
可能取值: [text]
内容部分的类型,在此为 text。
text: string required
文本内容。
type: string required
可能取值: [image_url]
内容部分的类型,在此为 image_url。
image_url: object required
url: string required
图像的 http(s) URL(最多 8192 个字符)或 base64 编码的数据 URL(data:image/jpeg;base64,...)。支持的格式:JPEG、PNG、GIF 和 WebP。
detail: string
可能取值: [low, high, original, auto]
控制图像的处理方式。low 将图像下采样至 512x512(速度更快,成本更低)。high、original 和 auto 保留原始图像。
type: string required
可能取值: [file]
内容部分的类型,在此为 file。
file_id: string
通过 Files API 上传的文件 ID,形式为 file-api-...。与 file_data 互斥。
file_data: string
图像的 base64 编码数据 URL(data:image/jpeg;base64,...)。与 file_id 互斥。
filename: string
可选的文件名。仅与 file_data 一起有效。
]
tool_call_id: string required
该消息所响应的工具调用 ID。
]
model: string required
可能取值: [deepseek-flash, deepseek-v4-pro]
要使用的模型 ID。使用 deepseek-flash 或 deepseek-v4-pro。
thinking: object nullable
控制思考模式与非思考模式的切换。
type: string
可能取值: [enabled, disabled]
默认值: enabled
如果设置为 enabled,则使用思考模式。如果设置为 disabled,则使用非思考模型。
reasoning_effort: string
可能取值: [none, low, high, max]
控制思考模式的开关及思考投入程度。none 禁用思考模式;low / high / max 启用思考模式。默认投入程度为 high。为了与现有软件兼容,minimal 会被接受并映射为 low,medium / xhigh 会被接受并映射为 high。
max_tokens: integer nullable
Chat completion 中可生成的最大 token 数。
输入 token 和生成 token 的总长度受模型上下文长度限制。
值必须在 1 到 384K (393216) 之间。未设置时,非思考模式默认值为 8K,思考模式默认值为 64K(当 reasoning_effort 设置为 max 时为 128K)。详情请参阅“模型与定价”页面。
response_format: object nullable
指定模型必须输出的格式的对象。
设置为 { "type": "json_object" } 可启用 JSON 输出,保证模型生成的消息是有效的 JSON。
重要提示:使用 JSON 输出时,必须通过 system 或 user 消息自行指示模型生成 JSON。否则,模型可能会生成无尽的空白流,直到达到 token 限制,导致请求长时间运行并看似“卡住”。另外请注意,如果 finish_reason="length",消息内容可能会被部分截断,这表示生成超过了 max_tokens 或对话超过了最大上下文长度。
type: string
可能取值: [text, json_object]
默认值: text
必须是 text 或 json_object 之一。
stop: string | string[] nullable
最多 16 个序列,API 会在这些序列处停止生成更多 token。
oneOf Single stop sequence Stop sequence list
string
Array [string]
stream: boolean nullable
如果设置,将发送部分消息增量。Token 将作为仅数据服务器发送事件 (SSE) 在可用时发送,流由 data: [DONE] 消息终止。
stream_options: object nullable
流式响应的选项。必须与 stream: true 一起设置;如果未将 stream 设置为 true,API 将返回 400 错误。
include_usage: boolean
如果设置为 true,流中的所有 chunk 都将包含 usage 字段,其值在最后一个 chunk 之前均为 null。如果省略或设置为 false,除了最后一个 chunk 外,所有 chunk 中都不存在 usage 字段。
无论如何,在 data: [DONE] 消息之前的最后一个 chunk 的 usage 字段中包含整个请求的 token 使用统计信息。注意,不会单独发出仅含 usage 的 chunk:统计信息搭载在最后一个内容 chunk 上,其 choices 数组始终包含恰好一个元素,该元素不携带新内容且 finish_reason 非 null。
temperature: number nullable
可能取值: <= 2
默认值: 1
使用的采样温度,介于 0 和 2 之间。较高的值(如 0.8)会使输出更随机,而较低的值(如 0.2)则使其更集中且确定性强。
我们通常建议调整 temperature 或 top_p,但不要同时调整。在思考模式下无效。
top_p: number nullable
可能取值: <= 1
默认值: 1
使用温度采样的替代方案,称为核采样 (nucleus sampling),模型考虑具有 top_p 概率质量的 token 结果。因此 0.1 意味着只考虑构成前 10% 概率质量的 token。
值必须大于 0 且最多为 1。我们通常建议调整 top_p 或 temperature,但不要同时调整。它仅在思考模式下生效,有效范围为 0.95–1.0:低于 0.95 的值被视为 0.95。在非思考模式下固定为 1.0,传入的值被忽略。
tools: object[] nullable
模型可能调用的工具列表。目前,仅支持函数作为工具。
使用此参数提供模型可能生成 JSON 输入的函数列表。工具名称必须唯一。
Array [type: string required
可能取值: [function]
工具的类型。目前仅支持 function。
function: object required
description: string
关于该函数功能的描述,供模型选择何时以及如何调用该函数使用。
name: string required
要调用的函数名称。必须为 a-z、A-Z、0-9 或包含下划线和破折号,最大长度为 128。
parameters: object
函数接受的参数,描述为 JSON Schema 对象。示例请参见 Tool Calls 指南,格式文档请参见 JSON Schema 参考。
省略 parameters 定义为空参数列表的函数。
property name * any
函数接受的参数,描述为 JSON Schema 对象。示例请参见 Tool Calls 指南,格式文档请参见 JSON Schema 参考。
省略 parameters 定义为空参数列表的函数。
strict: boolean
默认值: false
如果设置为 true,API 将对工具调用使用严格模式,以确保输出始终符合函数的 JSON schema。这是一个 Beta 功能,更多详情请参阅 Tool Calls 指南
]
tool_choice: string | object nullable
控制模型调用哪个(如果有)工具。
none 表示模型不调用任何工具,而是生成消息。
auto 表示模型可以在生成消息或调用一个或多个工具之间选择。
required 表示模型必须调用一个或多个工具。
通过 {"type": "function", "function": {"name": "my_function"}} 指定特定工具可强制模型调用该工具。
在没有工具时,默认为 none。在存在工具时,默认为 auto。
required 和命名工具选择在思考模式下不支持;API 将返回 400 错误。请先禁用思考模式再使用它们。
oneOf ChatCompletionToolChoice ChatCompletionNamedToolChoice
string
可能取值: [none, auto, required]
type: string required
可能取值: [function]
工具的类型。目前仅支持 function。
function: object required
name: string required
要调用的函数名称。
logprobs: boolean nullable
是否返回输出 token 的对数概率。如果为 true,返回在消息内容中返回的每个输出 token 的对数概率。
top_logprobs: integer nullable
可能取值: <= 20
指定在每个 token 位置返回的最可能 token 数量(0 到 20 之间的整数),每个都带有相关的对数概率。如果使用此参数,必须将 logprobs 设置为 true。
user_id: nullable
自定义 user_id。允许字符集为 [a-zA-Z0-9\-_],最大长度为 512。请勿在 user_id 中包含用户隐私信息。
user_id 可用于区分您这边的用户身份,以帮助我们进行内容安全审核。
user_id 可用于 KVCache 隔离以进行隐私管理。
user_id 可用于您业务侧的用户调度隔离。
有关 user_id 参数的更多详细信息,请参见 Rate Limit & Isolation
frequency_penalty deprecated
此参数不再支持。传入 API 时不会生效。
presence_penalty deprecated
此参数不再支持。传入 API 时不会生效。
响应 (Responses)
200 (No streaming)
200 (Streaming)
OK, 返回 chat completion 对象
application/json
Schema
Example (from schema)
Example
Schema
id: string required
Chat completion 的唯一标识符。
choices: object[] required
Chat completion 选项列表。
Array [finish_reason: string required
可能取值: [stop, length, content_filter, tool_calls, insufficient_system_resource, aborted]
模型停止生成 token 的原因。如果是模型遇到自然停止点或提供的停止序列,则为 stop;
如果达到请求中指定的最大 token 数,则为 length;
如果内容因内容过滤器标记而被省略,则为 content_filter;
如果模型调用了工具,则为 tool_calls;
如果由于推理系统资源不足导致请求中断,则为 insufficient_system_resource;
如果生成被中断,则为 aborted。
index: integer required
选项在选项列表中的索引。
message: object required
模型生成的 chat completion 消息。
content: string nullable required
消息的内容。
reasoning_content: string nullable
仅限思考模式。助手消息在最终答案之前的推理内容。
tool_calls: object[]
模型生成的工具调用。
Array [id: string required
工具调用的 ID。
type: string required
可能取值: [function]
工具的类型。目前仅支持 function。
function: object required
模型调用的函数。
name: string required
要调用的函数名称。
arguments: string required
调用函数的参数,由模型以 JSON 格式生成。注意,模型并不总是生成有效的 JSON,可能会幻想出函数架构中未定义的参数。在调用函数前请在代码中验证参数。
]
role: string required
可能取值: [assistant]
该消息作者的角色。
logprobs: object nullable required
选项的对数概率信息。
content: object[] nullable required
带有对数概率信息的消息内容 token 列表。
Array [token: string required
Token。
logprob: number required
该 token 的对数概率,如果它在前 20 个最可能的 token 内。否则,使用值 -9999.0 表示该 token 可能性极低。
bytes: integer[] nullable required
代表 token 的 UTF-8 字节表示的整数列表。在字符由多个 token 表示且需要结合它们的字节表示以生成正确文本表示的情况下有用。如果 token 没有字节表示,可以为 null。
top_logprobs: object[] required
该 token 位置最可能的 token 及其对数概率列表。在极少数情况下,返回的数量可能少于请求的 top_logprobs 数量。
Array [token: string required
Token。
logprob: number required
该 token 的对数概率,如果它在前 20 个最可能的 token 内。否则,使用值 -9999.0 表示该 token 可能性极低。
bytes: integer[] nullable required
代表 token 的 UTF-8 字节表示的整数列表。在字符由多个 token 表示且需要结合它们的字节表示以生成正确文本表示的情况下有用。如果 token 没有字节表示,可以为 null。
]
]
reasoning_content: object[] nullable
带有对数概率信息的消息内容 token 列表。
Array [token: string required
Token。
logprob: number required
该 token 的对数概率,如果它在前 20 个最可能的 token 内。否则,使用值 -9999.0 表示该 token 可能性极低。
bytes: integer[] nullable required
代表 token 的 UTF-8 字节表示的整数列表。在字符由多个 token 表示且需要结合它们的字节表示以生成正确文本表示的情况下有用。如果 token 没有字节表示,可以为 null。
top_logprobs: object[] required
该 token 位置最可能的 token 及其对数概率列表。在极少数情况下,返回的数量可能少于请求的 top_logprobs 数量。
Array [token: string required
Token。
logprob: number required
该 token 的对数概率,如果它在前 20 个最可能的 token 内。否则,使用值 -9999.0 表示该 token 可能性极低。
bytes: integer[] nullable required
代表 token 的 UTF-8 字节表示的整数列表。在字符由多个 token 表示且需要结合它们的字节表示以生成正确文本表示的情况下有用。如果 token 没有字节表示,可以为 null。
]
]
]
created: integer required
创建 chat completion 时的 Unix 时间戳(以秒为单位)。
model: string required
用于 chat completion 的模型。
system_fingerprint: string required
该指纹代表模型运行的后端配置。
object: string required
可能取值: [chat.completion]
对象类型,始终为 chat.completion。
usage: object
Completion 请求的使用统计信息。
completion_tokens: integer required
生成的 completion 中的 token 数。
prompt_tokens: integer required
Prompt 中的 token 数。等于 prompt_cache_hit_tokens + prompt_cache_miss_tokens。
prompt_tokens_details: object required
Prompt 中使用的 token 分解。
cached_tokens: integer
命中上下文缓存的 prompt token 数。与 prompt_cache_hit_tokens 相同。
prompt_cache_hit_tokens: integer required
命中上下文缓存的 prompt token 数。
prompt_cache_miss_tokens: integer required
未命中上下文缓存的 prompt token 数。
total_tokens: integer required
请求中使用的总 token 数(prompt + completion)。
completion_tokens_details: object
Completion 中使用的 token 分解。
reasoning_tokens: integer
模型为推理生成的 token 数。
{
"id": "string",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "string",
"reasoning_content": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"role": "assistant"
},
"logprobs": {
"content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
],
"reasoning_content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
]
}
}
],
"created": 0,
"model": "string",
"system_fingerprint": "string",
"object": "chat.completion",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0
},
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 0,
"total_tokens": 0,
"completion_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "930c60df-bf64-41c9-a88e-3ec75f81e00e",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! How can I help you today?",
"role": "assistant"
},
"logprobs": null
}
],
"created": 1705651092,
"model": "deepseek-flash",
"object": "chat.completion",
"system_fingerprint": "fp_7a09fdf9c2",
"usage": {
"completion_tokens": 10,
"prompt_tokens": 16,
"total_tokens": 26,
"prompt_tokens_details": {
"cached_tokens": 0
}, "prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 16
}
}
HTTP 状态码 200,返回 chat completion chunk 对象的流式序列。 Content-Type: text/event-stream示例(来自 schema)
- id (string, 必填):chat completion 的唯一标识符。每个 chunk 拥有相同的 ID。
- choices (object[], 必填):chat completion 的选项列表。
- delta (object, 必填):由流式模型响应生成的 chat completion 增量数据。
- content (string, 可空):chunk 消息的内容。
- reasoning_content (string, 可空):仅适用于思考模式。在最终答案之前,助手消息的推理内容。
- role (string):该消息作者的角色的可能取值:[assistant]。
- tool_calls (object[]):模型生成的工具调用(如函数调用)。每个工具调用的首个 chunk 携带 id、type 和 function 字段;后续的 chunk 仅携带 function 参数。
- index (integer, 必填)
- id (string):工具调用的 ID。
- type (string):工具类型的可能取值:[function]。目前仅支持 function。
- function (object)
- name (string):要调用的函数名。
- arguments (string):模型以 JSON 格式生成的用于调用函数的参数。注意:模型并非总是生成合法的 JSON,可能会幻觉出未在函数 schema 中定义的参数。在调用函数前,请在代码中验证参数。
- logprobs (object, 可空):该选项的对数概率信息。
- content (object[], 可空, 必填):带有对数概率信息的消息内容 token 列表。
- token (string, 必填):token 本身。
- logprob (number, 必填):如果该 token 位于前 20 个最可能的 token 之中,则为该 token 的对数概率;否则使用 -9999.0 表示该 token 的可能性极低。
- bytes (integer[], 可空, 必填):表示 token 的 UTF-8 字节表示的整数列表。当字符由多个 token 表示且需合并它们的字节表示以生成正确的文本表示时,该字段很有用。如果 token 没有字节表示,可为 null。
- top_logprobs (object[], 必填):在该 token 位置返回最可能的 token 及其对数概率列表。在极少数情况下,返回的 top_logprobs 数量可能少于请求的数量。
- token (string, 必填):token 本身。
- logprob (number, 必填):如果该 token 位于前 20 个最可能的 token 之中,则为该 token 的对数概率;否则使用 -9999.0 表示该 token 的可能性极低。
- bytes (integer[], 可空, 必填):表示 token 的 UTF-8 字节表示的整数列表。当字符由多个 token 表示且需合并它们的字节表示以生成正确的文本表示时,该字段很有用。如果 token 没有字节表示,可为 null。
- reasoning_content (object[], 可空):带有对数概率信息的消息内容 token 列表。
- token (string, 必填):token 本身。
- logprob (number, 必填):如果该 token 位于前 20 个最可能的 token 之中,则为该 token 的对数概率;否则使用 -9999.0 表示该 token 的可能性极低。
- bytes (integer[], 可空, 必填):表示 token 的 UTF-8 字节表示的整数列表。当字符由多个 token 表示且需合并它们的字节表示以生成正确的文本表示时,该字段很有用。如果 token 没有字节表示,可为 null。
- top_logprobs (object[], 必填):在该 token 位置返回最可能的 token 及其对数概率列表。在极少数情况下,返回的 top_logprobs 数量可能少于请求的数量。
- token (string, 必填):token 本身。
- logprob (number, 必填):如果该 token 位于前 20 个最可能的 token 之中,则为该 token 的对数概率;否则使用 -9999.0 表示该 token 的可能性极低。
- bytes (integer[], 可空, 必填):表示 token 的 UTF-8 字节表示的整数列表。当字符由多个 token 表示且需合并它们的字节表示以生成正确的文本表示时,该字段很有用。如果 token 没有字节表示,可为 null。
- finish_reason (string, 可空, 必填):模型停止生成 token 的原因的可能取值:[stop, length, content_filter, tool_calls, insufficient_system_resource, aborted]。若模型遇到自然停止点或指定的停止序列,则为 stop;若达到请求中指定的最大 token 数,则为 length;若因内容过滤器标记而省略内容,则为 content_filter;若模型调用了工具,则为 tool_calls;若因推理系统资源不足导致请求中断,则为 insufficient_system_resource;若生成过程被中止,则为 aborted。
- index (integer, 必填):该选项在选项列表中的索引。
- created (integer, 必填):chat completion 创建时的 Unix 时间戳(以秒为单位)。每个 chunk 拥有相同的时间戳。
- model (string, 必填):生成 completion 所用的模型。
- system_fingerprint (string, 必填):该指纹代表模型运行的后端配置。
- object (string, 必填):对象类型的可能取值:[chat.completion.chunk]。对象类型始终为 chat.completion.chunk。
{
"id": "string",
"choices": [
{
"delta": {
"content": "string",
"reasoning_content": "string",
"role": "assistant",
"tool_calls": [
{
"index": 0,
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
]
},
"logprobs": {
"content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
],
"reasoning_content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
]
},
"finish_reason": "stop",
"index": 0
}
],
"created": 0,
"model": "string",
"system_fingerprint": "string",
"object": "chat.completion.chunk"
}
]
data: {"id": "1f633d8bfc032625086f14113c411638", "choices": [{"index": 0, "delta": {"content": "", "role": "assistant"}, "finish_reason": null, "logprobs": null}], "created": 1718345013, "model": "deepseek-flash", "system_fingerprint": "fp_a49d71b8a1", "object": "chat.completion.chunk"}
data: {"choices": [{"delta": {"content": "Hello", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": "!", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 我", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 能", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 帮", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 您", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 做", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 些", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 什么", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": "?", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": "", "role": null}, "finish_reason": "stop", "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1", "usage": {"completion_tokens": 9, "prompt_tokens": 17, "total_tokens": 26, "prompt_tokens_details": {"cached_tokens": 0}, "prompt_cache_hit_tokens": 0, "prompt_cache_miss_tokens": 17}}
data: [DONE]
加载中...
"id": "string",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "string",
"reasoning_content": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"role": "assistant"
},
"logprobs": {
"content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
],
"reasoning_content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
]
}
}
],
"created": 0,
"model": "string",
"system_fingerprint": "string",
"object": "chat.completion",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0
},
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 0,
"total_tokens": 0,
"completion_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "930c60df-bf64-41c9-a88e-3ec75f81e00e",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! How can I help you today?",
"role": "assistant"
},
"logprobs": null
}
],
"created": 1705651092,
"model": "deepseek-flash",
"object": "chat.completion",
"system_fingerprint": "fp_7a09fdf9c2",
"usage": {
"completion_tokens": 10,
"prompt_tokens": 16,
"total_tokens": 26,
"prompt_tokens_details": {
"cached_tokens": 0
}, "prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 16
}
}
HTTP 状态码 200,返回 chat completion chunk 对象的流式序列。 Content-Type: text/event-stream
{
"id": "string",
"choices": [
{
"delta": {
"content": "string",
"reasoning_content": "string",
"role": "assistant",
"tool_calls": [
{
"index": 0,
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
]
},
"logprobs": {
"content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
],
"reasoning_content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
]
},
"finish_reason": "stop",
"index": 0
}
],
"created": 0,
"model": "string",
"system_fingerprint": "string",
"object": "chat.completion.chunk"
}
]
data: {"id": "1f633d8bfc032625086f14113c411638", "choices": [{"index": 0, "delta": {"content": "", "role": "assistant"}, "finish_reason": null, "logprobs": null}], "created": 1718345013, "model": "deepseek-flash", "system_fingerprint": "fp_a49d71b8a1", "object": "chat.completion.chunk"}
data: {"choices": [{"delta": {"content": "Hello", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": "!", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 我", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 能", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 帮", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 您", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 做", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 些", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": " 什么", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": "?", "role": "assistant"}, "finish_reason": null, "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1"}
data: {"choices": [{"delta": {"content": "", "role": null}, "finish_reason": "stop", "index": 0, "logprobs": null}], "created": 1718345013, "id": "1f633d8bfc032625086f14113c411638", "model": "deepseek-flash", "object": "chat.completion.chunk", "system_fingerprint": "fp_a49d71b8a1", "usage": {"completion_tokens": 9, "prompt_tokens": 17, "total_tokens": 26, "prompt_tokens_details": {"cached_tokens": 0}, "prompt_cache_hit_tokens": 0, "prompt_cache_miss_tokens": 17}}
data: [DONE]
加载中...