
DeepSeek API: Access, Rate Limits & SDKs 2026
The DeepSeek API is OpenAI- and Anthropic-compatible, so a base-URL swap points your existing SDK at deepseek-v4-pro. It caps concurrency, not requests per minute.
DeepSeek API verdict
The DeepSeek API is the easiest of the leading models to adopt from existing code.
It is OpenAI- and Anthropic-compatible, so a bearer key plus a base-URL swap, to https://api.deepseek.com or /anthropic, lets the OpenAI or Anthropic SDK call deepseek-v4-pro unchanged. Agent tools like Claude Code or GitHub Copilot can use it as a backend with no code.
DeepSeek's API is the lowest-friction way to drop a cheap reasoning model into an existing OpenAI- or Anthropic-shaped codebase. Keep your SDK, swap the base URL and key, and point at deepseek-v4-pro. Agent tooling like Claude Code, Copilot and OpenCode treats it as a backend with no code. Plan around concurrency rather than RPM: 500 simultaneous connections per account for v4-pro, expandable for free, with per-user_id sub-limits for multi-tenant apps. Budget on a prepaid balance, and lean on the 99 percent cache-hit discount, at $0.004 per 1M, and the thinking-mode toggle to control reasoning cost. Watch two operational edges. A 402 stops you cold when the balance runs out, and long requests need keep-alive handling with a 10-minute idle cutoff.
- The limit is concurrency, not requests per minute: 500 simultaneous connections for deepseek-v4-pro at the account level, a 429 over that, with free capacity expansion on request.
- Billing is a prepaid balance. A 402 Insufficient Balance halts requests until you top up, and the granted balance is spent before the topped-up balance.
- The model names deepseek-chat and deepseek-reasoner are deprecated on 2026-07-24, so migrate to deepseek-v4-flash or pro with the thinking-mode toggle.
- Connections are held with keep-alive lines during long inference but closed after 10 minutes without inference, so handle empty lines and SSE keep-alive comments when parsing.
- Auth
- Bearer API key
- Compatibility
- OpenAI + Anthropic SDK
- Concurrency (pro)
- 500 (account level)
- Cache discount
- 99% ($0.004/1M)
- Context / output
- 1M / 384K
Build with the DeepSeek API
from openai import OpenAI
client = OpenAI(
api_key="<DEEPSEEK_API_KEY>",
base_url="https://api.deepseek.com",
)
response = client.chat.completions.create(
model="deepseek-v4-pro",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content){
"choices": [{
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 9, "completion_tokens": 8 }
}- Cost levers: prompt caching (cache hit $0.004/1M, 99% off); thinking-mode toggle (reasoning vs non-thinking); non-thinking deepseek-v4-flash for cheaper calls.
- Handle: 402 (Insufficient Balance (top up)), 429 (Rate limit / concurrency exceeded).
Real DeepSeek code from the official docs. The raw cURL hello-world is the code block above; full limits and endpoints are in the tables on this page.
Your first DeepSeek API request
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \
-d '{
"model": "deepseek-v4-pro",
"messages": [{"role": "user", "content": "Hello!"}],
"thinking": {"type": "enabled"},
"stream": false
}'How to authenticate with the DeepSeek API
| Aspect | Detail | Notes |
|---|---|---|
| Auth | Bearer API key in Authorization header | Authorization: Bearer ${DEEPSEEK_API_KEY} |
| Base URL (OpenAI) | https://api.deepseek.com | Drop-in for the OpenAI SDK |
| Base URL (Anthropic) | https://api.deepseek.com/anthropic | Drop-in for the Anthropic SDK |
| Models | deepseek-v4-pro, deepseek-v4-flash | deepseek-chat / deepseek-reasoner deprecated 2026-07-24 |
| Compatibility | OpenAI / Anthropic request format | Reuse existing SDKs or compatible software |
| Agent tools | Claude Code, GitHub Copilot, OpenCode | Use DeepSeek as backend model, no code |
| Billing model | Prepaid balance, deducted per token | Granted balance used before topped-up balance |
DeepSeek core endpoints and features
| Capability | How | Purpose |
|---|---|---|
| Chat completions | POST /chat/completions | Text generation in OpenAI message format |
| Thinking mode | thinking: {type: "enabled"} + reasoning_effort | Toggle reasoning vs non-thinking output |
| Streaming | stream: true (SSE) | Stream tokens as generated |
| JSON output | JSON Output feature | Structured JSON responses |
| Tool calls | Tool Calls feature | Function calling / tool use |
| Prefix / FIM | Chat Prefix + FIM completion (beta) | Continuation and fill-in-the-middle (FIM non-thinking only) |
| Multi-tenant isolation | user_id parameter | Content-safety, KVCache and scheduling isolation per end user |
| Keep-alive | Empty lines / SSE : keep-alive comments | Connection held during long inference; closed after 10 min idle |
Concurrency limits and isolation
| Limit | Detail | Notes |
|---|---|---|
| Concurrency (pro) | 500 simultaneous connections | deepseek-v4-flash: 2500 |
| Scope | Account level, across all API keys | Not per API key |
| Over-limit | HTTP 429 when concurrency exceeded | Within limit, all requests are served |
| Capacity expansion | Request higher concurrency, no extra cost | Matched to actual business needs |
| Per-user_id sub-limit | Each user_id capped (pro 500) on expanded accounts | Empty id treated as a special user_id |
| Request timeout | Connection closed after 10 min without inference | Keep-alive lines sent meanwhile |
| Context / output ceiling | 1M context, 384K max output | Per request |
DeepSeek SDKs, error handling and developer fit
| Aspect | Detail | Notes |
|---|---|---|
| SDKs | OpenAI SDK or Anthropic SDK | Set base_url; user_id goes in extra_body (OpenAI) or metadata (Anthropic) |
| 401 / 422 | Auth fails / invalid parameters | Check API key; fix request per error hints |
| 402 Insufficient Balance | Prepaid balance exhausted | Top up to continue |
| 429 Rate Limit | Requests too fast / concurrency exceeded | Pace requests; may fall back to another provider |
| 500 / 503 | Server error / overloaded | Retry after a brief wait |
| Cost levers | Cache hit $0.004/1M (99% off); off-peak none, prefer caching | Cache miss input $0.435/1M |
| API pricing (v4-pro) | $0.435/1M in (miss), $0.87/1M out | Independent cross-reference |
DeepSeek API FAQ
How do I authenticate with the DeepSeek API?
Apply for an API key, then send it as a bearer token in the Authorization header, as Authorization: Bearer ${DEEPSEEK_API_KEY}. The API is OpenAI- and Anthropic-compatible, so you can keep your existing SDK. Just swap the base URL to https://api.deepseek.com for the OpenAI format, or https://api.deepseek.com/anthropic for the Anthropic format, then call model deepseek-v4-pro.
Can I use the OpenAI or Anthropic SDK with DeepSeek?
Yes. The DeepSeek API mirrors both formats, so the official OpenAI SDK and Anthropic SDK work unchanged once you set the base URL and key. The user_id isolation parameter goes under extra_body for the OpenAI SDK and under metadata for the Anthropic SDK. Agent tools like Claude Code, GitHub Copilot and OpenCode can use DeepSeek as a backend model with no code changes.
What are the DeepSeek API rate limits?
DeepSeek does not throttle on requests per minute. It caps concurrency, at 500 simultaneous connections for deepseek-v4-pro and 2,500 for deepseek-v4-flash, calculated at the account level across all API keys. Exceeding the limit returns HTTP 429. You can request a free capacity expansion, and multi-tenant accounts can get per-user_id concurrency sub-limits.
How much does the DeepSeek API cost and how is it billed?
deepseek-v4-pro is $0.435 per 1M input tokens on a cache miss, $0.003625 per 1M cache-hit input, about 99% off, and $0.87 per 1M output tokens. It has a 1M-token context and 384K max output. Billing is prepaid. Fees are deducted per token from your balance, spending granted balance before topped-up balance, and a 402 Insufficient Balance error halts requests until you top up.
How do I handle DeepSeek API errors and long requests?
Error codes follow HTTP conventions: 401 for a bad key, 402 for insufficient balance, 422 for invalid parameters, 429 for too many requests or concurrency, and 500 or 503 for the server. For long inference, the server holds the connection open with keep-alive signals, empty lines for non-streaming and ': keep-alive' SSE comments for streaming, so handle those when parsing. Note the connection is closed after 10 minutes without inference.
Sources & verification
| Source | What was checked | Last checked |
|---|---|---|
| DeepSeek Official | Official product page | July 10, 2026 |
| Artificial Analysis | Independent reference | July 10, 2026 |
| DeepSeek | Product documentation | July 10, 2026 |
| DeepSeek Quick Start Error Codes | Quick Start Error Codes | July 10, 2026 |
| DeepSeek Quick Start Pricing | Pricing and plans | July 10, 2026 |
| DeepSeek Quick Start Rate Limit | Quick Start Rate Limit | July 10, 2026 |
Every fact on this DeepSeek page is tied to a named source and a verification date. Freshness-sensitive figures trace to the sources above; verify against the vendor before relying on them.
Explore DeepSeek
Every page on DeepSeek in one place, you are on api.
