LLM ยท API Platform

DeepSeek API

V4-Flash and V4-Pro โ€” DeepSeek's frontier models with 1M token context, native thinking mode, and full OpenAI / Anthropic API compatibility. Drop-in replacement for your existing stack.

๐Ÿง  Models: V4-Flash ยท V4-Pro ๐Ÿ“ฆ Context: 1M tokens ๐Ÿ”Œ Formats: OpenAI ยท Anthropic โšก Concurrency: up to 2,500
DeepSeek-V4 is a new family of open-weight models. The old deepseek-chat and deepseek-reasoner model names will be deprecated on 2026/07/24 โ€” migrate to deepseek-v4-flash now.

Pricing

Billed per 1M tokens in USD. Cost = tokens ร— price, deducted from topped-up balance first, then granted balance. Cache-hit input tokens are 50ร— cheaper than cache-miss โ€” use context caching to cut costs dramatically.

DeepSeek-V4-Pro

maximum reasoning quality
Input (cache hit)$0.003625/1M
Input (cache miss)$0.435/1M
Output$0.87/1M
๐Ÿ“ 1M context ยท 384K max output
๐Ÿ’ก Cost optimization: Enable context caching to get 50ร— cheaper input tokens. Use the offline tokenizer (deepseek_tokenizer.zip) to estimate costs before sending requests. Actual token counts come from the usage field in API responses.

Model Comparison

CapabilityV4-FlashV4-Pro
Context Window1M tokens1M tokens
Max Outputโ€”384K tokens
Thinking Modeโœ“โœ“
JSON Outputโœ“โœ“
Tool Callsโœ“โœ“
Chat Prefix Completion (Beta)โœ“โœ“
FIM Completion (Beta)โœ“โœ“
OpenAI Formatโœ“โœ“
Anthropic Formatโœ“โœ“
Context Cachingโœ“โœ“
Concurrency Limit2,500500

Key Features

๐Ÿง 

Thinking Mode

Configurable via reasoning_effort

๐Ÿ“

1M Context

Million-token window

๐Ÿ’พ

Context Caching

50ร— cheaper on cache hits

๐Ÿ”Œ

OpenAI Compatible

Drop-in with official SDKs

๐Ÿค–

Anthropic Compatible

Works with Claude SDK

๐Ÿ”ง

Tool Calls

Agentic function calling

๐Ÿ“‹

JSON Output

Structured responses

โšก

Streaming

SSE for real-time apps

Thinking Mode

Both V4-Flash and V4-Pro support native thinking/reasoning. Enable it via the thinking parameter and control effort with reasoning_effort:

{
  "model": "deepseek-v4-flash",
  "thinking": { "type": "enabled" },
  "reasoning_effort": "medium",
  "messages": [{"role": "user", "content": "Explain quantum entanglement simply"}]
}
How it works: When thinking is enabled, the model allocates internal reasoning tokens before producing the final response. Higher reasoning_effort values yield deeper reasoning at higher token cost.

API Endpoints

DeepSeek supports both OpenAI and Anthropic API formats โ€” same API key works for both.

MethodEndpointDescription
POST/chat/completionsChat completions (OpenAI)
POST/anthropic/v1/messagesMessages (Anthropic)
GET/modelsList available models
GET/models/{model}Model details

Base URLs

FormatBase URL
OpenAIhttps://api.deepseek.com
Anthropichttps://api.deepseek.com/anthropic

Code Examples

Authentication

Get your API key from platform.deepseek.com. All requests require a Bearer token:

Authorization: Bearer <DEEPSEEK_API_KEY>

Chat Completion

curl https://api.deepseek.com/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    "stream": false
  }'

Streaming

curl https://api.deepseek.com/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [{"role": "user", "content": "Tell me a story"}],
    "stream": true
  }'

Responses return as Server-Sent Events (SSE) with data: {...} lines and a final [DONE] sentinel.

Context Caching

Repeat the same prefix across requests to trigger automatic caching. Cache-hit tokens billed at the discounted rate โ€” no code changes required beyond reusing the prefix.

# First request โ€” full price (cache miss)
curl https://api.deepseek.com/chat/completions \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [
      {"role": "system", "content": "You are a coding assistant. Here is the project context: [long docs]..."},
      {"role": "user", "content": "Now help me with this specific question..."}
    ]
  }'

# Subsequent requests โ€” prefix cached at $0.0028/1M
curl https://api.deepseek.com/chat/completions \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [
      {"role": "system", "content": "You are a coding assistant. Here is the project context: [long docs]..."},
      {"role": "user", "content": "A different question with same prefix..."}
    ]
  }'

Token Usage

Tokens are the basic billing units โ€” roughly 1 English character โ‰ˆ 0.3 tokens, 1 Chinese character โ‰ˆ 0.6 tokens. Actual counts vary by model; the definitive count comes from the usage field in the API response.

๐Ÿ“Š Quick reference: 1 English word โ‰ˆ 1.3 tokens ยท 1 Chinese character โ‰ˆ 0.6 tokens ยท Use the offline tokenizer to pre-calculate costs.

Token Cost Estimator

Rough estimate based on average token ratios. Actual counts come from the model's usage field.

$0.0004 estimated

Rate Limits

Concurrency limits are enforced at the account level regardless of which API key is used. A request counts as concurrent from send until response completes.

ModelConcurrency Limit
deepseek-v4-flash2,500 concurrent
deepseek-v4-pro500 concurrent
โš ๏ธ Note: Exceeding concurrency returns HTTP 429. If inference hasn't started after 10 minutes, the server closes the connection. No per-minute request or token limits are documented.

Error Codes

CodeMeaningTroubleshooting
400Invalid FormatFix request body per error message
401Authentication FailsVerify API key; create one at platform.deepseek.com
402Insufficient BalanceCheck account balance; top up
422Invalid ParametersAdjust parameters per error message
429Rate Limit ReachedSlow down; consider exponential backoff
500Server ErrorRetry after brief wait
503Server OverloadedRetry after brief wait

Agent Integrations

DeepSeek integrates directly with popular coding agents. Configure via OpenAI-compatible or Anthropic-compatible format depending on your tool.

Configure ~/.claude/settings.json:

  • ANTHROPIC_BASE_URL = https://api.deepseek.com/anthropic
  • ANTHROPIC_AUTH_TOKEN = your DeepSeek API key
  • ANTHROPIC_MODEL = deepseek-v4-flash

Claude Code Docs โ†’

Use DeepSeek as a Copilot provider. Set the API base URL and model in your Copilot configuration to route through DeepSeek.

Copilot Docs โ†’

CLI tool. Configure ~/.config/opencode/opencode.json:

  • Provider: DeepSeek (OpenAI-compatible)
  • Base URL: https://api.deepseek.com
  • Model: deepseek-v4-flash

OpenCode Docs โ†’

FAQ

Visit platform.deepseek.com/api-docs/api-key and create a new key. Store it securely โ€” it's shown only once.

V4-Flash is the default โ€” fast, affordable, 2,500 concurrency. V4-Pro offers maximum reasoning quality at higher cost with 500 concurrency and 384K max output. Both support thinking mode and all API features.

Yes. For OpenAI: set base_url="https://api.deepseek.com". For Anthropic: client = anthropic.Anthropic(base_url="https://api.deepseek.com/anthropic"). Minimal code changes needed.

Cache entries expire after 1 hour of inactivity. The next request pays full price (cache miss) and re-establishes the cache. Design your workloads to reuse prefixes within the 1-hour window.

New accounts receive a small granted balance. Check the platform dashboard for current offers. Otherwise, usage is billed from your topped-up balance at the rates shown above.

Full FAQ โ†’

Getting Started

Browse the rest of the Dump collection.