Deepseek | liteLLM
Skip to main content

Deepseek

https://deepseek.com/

We support ALL Deepseek models, just set deepseek/ as a prefix when sending completion requests

API Key​

# env variable
os.environ['DEEPSEEK_API_KEY']

Sample Usage​

from litellm import completion
import os

os.environ['DEEPSEEK_API_KEY'] = ""
response = completion(
model="deepseek/deepseek-chat",
messages=[
{"role": "user", "content": "hello from litellm"}
],
)
print(response)

Sample Usage - Streaming​

from litellm import completion
import os

os.environ['DEEPSEEK_API_KEY'] = ""
response = completion(
model="deepseek/deepseek-chat",
messages=[
{"role": "user", "content": "hello from litellm"}
],
stream=True
)

for chunk in response:
print(chunk)

Supported Models - ALL Deepseek Models Supported!​

We support ALL Deepseek models, just set deepseek/ as a prefix when sending completion requests

Model NameFunction Call
deepseek-chatcompletion(model="deepseek/deepseek-chat", messages)
deepseek-codercompletion(model="deepseek/deepseek-coder", messages)
deepseek-flashcompletion(model="deepseek/deepseek-flash", messages)
deepseek-v4-procompletion(model="deepseek/deepseek-v4-pro", messages)

Reasoning Models​

Model NameFunction Call
deepseek-reasonercompletion(model="deepseek/deepseek-reasoner", messages)

Thinking / Reasoning Mode​

Enable thinking mode for DeepSeek reasoner models using thinking or reasoning_effort parameters:

from litellm import completion
import os

os.environ['DEEPSEEK_API_KEY'] = ""

resp = completion(
model="deepseek/deepseek-reasoner",
messages=[{"role": "user", "content": "What is 2+2?"}],
thinking={"type": "enabled"},
)
print(resp.choices[0].message.reasoning_content) # Model's reasoning
print(resp.choices[0].message.content) # Final answer
note

DeepSeek only supports {"type": "enabled"} - unlike Anthropic, it doesn't support budget_tokens. Any reasoning_effort value other than "none" enables thinking mode.

Basic Usage​

from litellm import completion
import os

os.environ['DEEPSEEK_API_KEY'] = ""
resp = completion(
model="deepseek/deepseek-reasoner",
messages=[{"role": "user", "content": "Tell me a joke."}],
)

print(
resp.choices[0].message.reasoning_content
)

Off-Peak Pricing​

DeepSeek bills half its listed rate outside its peak hours. Peak hours are 01:00-04:00 and 06:00-10:00 UTC, Monday through Friday, excluding Chinese public holidays. Every other hour is off-peak, including weekends and Chinese public holidays in full. The rates below are USD per 1M tokens, from the DeepSeek pricing page, for deepseek-flash (DeepSeek-V4.1-Flash) and deepseek-v4-pro (DeepSeek-V4-Pro-0813)

ModelRateInputOutputCache hit
deepseek-flashPeak$0.30$1.20$0.006
deepseek-flashOff-peak$0.15$0.60$0.003
deepseek-v4-proPeak$1.32$3.96$0.044
deepseek-v4-proOff-peak$0.66$1.98$0.022

LiteLLM's cost tracking applies the off-peak rate automatically. The built-in cost map entries for these models carry the schedule above, and each request is priced from the UTC time and weekday it completes at, so tracked spend matches the DeepSeek invoice with no extra configuration. Chinese public holidays are not modeled, so on those days peak hours bill at the peak rate, a small overestimate. The legacy deepseek-v4-flash and deepseek-v4-flash-vision-exp names are served by DeepSeek-V4.1-Flash and billed at the Flash rate, off-peak included. To change the schedule or rates, or to set one on another deployment, see Off-Peak Pricing

🚅
LiteLLM Enterprise
SSO/SAML, audit logs, spend tracking, multi-team management, and guardrails — built for production.
Learn more →