POST
/
v1
/
chat
/
completions
Chat Completions DeepSeek V3.1
curl --request POST \
  --url https://api.example.com/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ],
  "thinking": {},
  "temperature": 123,
  "max_tokens": 123,
  "stream": true
}
'
Use DeepSeek V3.1 model with configurable thinking/reasoning depth.

Overview

DeepSeek V3.1 is a powerful reasoning model that allows you to control the depth of thinking. You can adjust how much effort the model puts into reasoning before generating a response.

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

model
string
required
ID of the model to use. Use deepseek-chat or deepseek-reasoner.
messages
array
required
A list of messages comprising the conversation so far.
thinking
object
Control thinking behavior with type and budget_tokens parameters.
temperature
number
default:"1"
Sampling temperature between 0 and 2.
max_tokens
integer
Maximum number of tokens to generate.
stream
boolean
default:"false"
Whether to stream back partial progress.

Request Example

curl -X POST https://api.example.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-reasoner",
    "messages": [
      {"role": "user", "content": "Explain the theory of relativity in simple terms."}
    ],
    "thinking": {
      "type": "enabled",
      "budget_tokens": 2048
    },
    "max_tokens": 4096
  }'

Response Example

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "deepseek-reasoner",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The theory of relativity, developed by Albert Einstein, consists of two parts...",
        "reasoning_content": "Let me think about how to explain this complex topic simply..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 250,
    "reasoning_tokens": 180,
    "total_tokens": 265
  }
}

Thinking Configuration

ParameterTypeDescription
typestringenabled or disabled
budget_tokensintegerMaximum tokens for thinking (128-8192)

Available Models

  • deepseek-chat
  • deepseek-reasoner
  • deepseek-coder