DeepSeek API
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ Japanese
  • πŸ‡°πŸ‡· Korea
  • πŸ‡΅πŸ‡Ή Portuguese
  1. API Reference
DeepSeek API
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ Japanese
  • πŸ‡°πŸ‡· Korea
  • πŸ‡΅πŸ‡Ή Portuguese
  • Start quickly
    • Your First API Call
    • Models & Pricing
    • The Temperature Parameter
    • Token & Token Usage
    • Rate Limit
    • Error Codes
  • API Reference
    • Introduction
    • Create Chat Completion
      POST
    • Create FIM Completion (Beta)
      POST
    • Lists Models
      GET
    • Get User Balance
      GET
  • API Guides
    • Reasoning Model (deepseek-reasoner)
    • Multiple rounds of conversations
    • Chat Prefix Completion (Beta)
    • FIM Completion (Beta)
    • JSON Output
    • Function Calling
    • Context Caching
  • FAQ
    • FAQ
  1. API Reference

Create Chat Completion

POST
https://api.deepseek.com/chat/completions
Creates a model response for the given chat conversation.
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.deepseek.com/chat/completions' \
--header 'Authorization: Bearer ' \
--header 'Authorization;' \
--header 'Content-Type: application/json' \
--data-raw '{
  "messages": [
    {
      "content": "You are a helpful assistant",
      "role": "system"
    },
    {
      "content": "Hi",
      "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
}'
Response Response Example
200 - Success - Success
{
  "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
                ]
              }
            ]
          }
        ]
      }
    }
  ],
  "created": 0,
  "model": "string",
  "system_fingerprint": "string",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 0,
    "prompt_tokens": 0,
    "prompt_cache_hit_tokens": 0,
    "prompt_cache_miss_tokens": 0,
    "total_tokens": 0,
    "completion_tokens_details": {
      "reasoning_tokens": 0
    }
  }
}

Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Header Params
Content-Type
stringΒ 
required
Example:
application/json
Authorization
stringΒ 
required
Example:
Bearer {{API_KEY}}
Body Params application/json
messages
arrayΒ [object {2}]Β 
required
content
stringΒ 
required
role
stringΒ 
required
model
stringΒ 
required
frequency_penalty
integerΒ 
required
max_tokens
integerΒ 
required
presence_penalty
integerΒ 
required
response_format
objectΒ 
required
type
stringΒ 
required
stop
nullΒ 
required
stream
booleanΒ 
required
stream_options
nullΒ 
required
temperature
integerΒ 
required
top_p
integerΒ 
required
tools
nullΒ 
required
tool_choice
stringΒ 
required
logprobs
booleanΒ 
required
top_logprobs
nullΒ 
required
Examples

Responses

🟒200Success
application/json
OK, returns a chat completion object
Body
id
stringΒ 
required
choices
arrayΒ [object {4}]Β 
required
finish_reason
stringΒ 
optional
index
integerΒ 
optional
message
objectΒ 
optional
logprobs
objectΒ 
optional
created
integerΒ 
required
model
stringΒ 
required
system_fingerprint
stringΒ 
required
object
stringΒ 
required
usage
objectΒ 
required
completion_tokens
integerΒ 
required
prompt_tokens
integerΒ 
required
prompt_cache_hit_tokens
integerΒ 
required
prompt_cache_miss_tokens
integerΒ 
required
total_tokens
integerΒ 
required
completion_tokens_details
objectΒ 
required
🟒200 Success
Modified atΒ 2025-02-08 10:18:03
Previous
Introduction
Next
Create FIM Completion (Beta)
Built with