创建对话
POST
/chat/completions请求参数
Body 参数application/json
model
string <enum>
必需
可用模型名称:
deepseek-ai/DeepSeek-R1、deepseek-ai/DeepSeek-V3
示例值:
deepseek-ai/DeepSeek-R1
messages
array[object (Message_request) {2}]
对话历史消息列表
role
string <string>
交互角色
示例值:
user
content
string <string>
对话内容
示例值:
hello world
max_tokens
integer <int32>
可选
控制生成内容的最大 token 数量
示例值:
512
temperature
number <double>
可选
控制生成内容的随机性,值越高输出越随机,值越低输出越确定
示例值:
0.7
top_p
number <double>
可选
控制生成内容的多样性
示例值:
0.7
n
integer <int32>
可选
指定生成多少条独立的回复
示例值:
1
stream
boolean
可选
是否以流式传输的方式返回结果(逐段输出)
示例值:
true
stop
array[string]
可选
指定生成内容在遇到某些字符串时停止
示例值:
uwqmlk,8wh77n
presence_penalty
number <double>
可选
控制生成内容中是否倾向于提及新主题
示例值:
68.35
frequency_penalty
number <double>
可选
控制生成内容中是否倾向于减少重复
示例值:
15.68
logit_bias
object
可选
调整特定 token 的生成概率,正数增加概率,负数减少概率(map data)
示例1
{
"model": "deepseek-ai/DeepSeek-R1",
"messages": [
{
"role": "user",
"content": "hello world"
}
],
"max_tokens": 512,
"temperature": 0.7,
"top_p": 0.7,
"n": 1,
"stream": true,
"stop": [
"rnv853"
],
"presence_penalty": 54.26,
"frequency_penalty": 32.41,
"logit_bias": {
"mapKey": 992
}
}
示例代码
返回响应
成功(200)
HTTP 状态码: 200
内容格式: JSON*/*
OK
数据结构
id
string
必需
本次对话的唯一标识符
object
string
返回对象的类型
created
string
时间戳
choices
array [object {5}]
结果数组
index
string
必需
当前结果的索引,从 0 开始
logprobs
string
必需
每个 token 的对数概率信息
finish_reason
string
结束原因
matched_stop
string
匹配到的停止符
delta
object
必需
增量数据,表示本次返回的内容变化
usage
string
必需
本次请求的资源使用情况(例如 token 数量)
示例
{
"id": "22b1ccf26e4346bba4d5655f1fa20b93",
"object": "chat.completion.chunk",
"created": 1739796748,
"choices": [
{
"index": 0,
"delta": {
"role": null,
"content": "如需",
"tool_calls": null
},
"logprobs": null,
"finish_reason": "",
"matched_stop": null
}
],
"usage": null
}
最后修改时间: 22 天前