对话补全
POST
https://api.deepseek.com/chat/completions
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.deepseek.com/chat/completions' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"messages": [
{
"content": "You are a helpful assistant",
"role": "system"
},
{
"content": "你是谁?",
"role": "user"
}
],
"model": "deepseek-chat",
"frequency_penalty": 0,
"max_tokens": 2048,
"presence_penalty": 0,
"response_format": {
"type": "text"
},
"stop": null,
"stream": false,
"stream_options": null,
"temperature": 1,
"top_p": 1,
"tools": null,
"tool_choice": "none",
"logprobs": false,
"top_logprobs": null
}'
响应示例响应示例
200 - No streaming - 成功示例
{
"id": "e137bb42-7580-4cb8-88ba-825209cf966b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today? 😊"
},
"logprobs": null,
"finish_reason": "stop"
}
],
"created": 1739112811,
"model": "deepseek-chat",
"system_fingerprint": "fp_3a5790e1b4",
"object": "chat.completion",
"usage": {
"prompt_tokens": 9,
"completion_tokens": 11,
"total_tokens": 20,
"prompt_tokens_details": {
"cached_tokens": 0
},
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 9
}
}
请求参数
Header 参数
Content-Type
string
必需
示例值:
application/json
Authorization
string
必需
示例值:
Bearer {{API_KEY}}
Body 参数application/json
返回响应
修改于 2025-02-10 05:49:36