To use the DeepSeek API, create an account at platform.deepseek.com, generate a key on the API keys page, add balance, and send requests to https://api.deepseek.com with the model name deepseek-flash or deepseek-v4-pro. The API works with the OpenAI and Anthropic SDKs, so most existing code only needs a new base URL and key. This guide covers setup, what it costs at peak and off-peak hours, how it compares with other models on a real workload, the limits, and the data terms a startup should read before sending customer data.
How to Get a DeepSeek API Key
The DeepSeek chat app and the DeepSeek API are separate. The app is for people. The API is for software, and it is billed by usage from a balance on your platform account. You need a platform account even if you already use the app.
Step 1: Create a platform account. Sign up at platform.deepseek.com with an address your company controls, so the account does not leave with whoever signed up first.
Step 2: Create a key. Open platform.deepseek.com/api_keys and create a key named after where it will run, such as "prod-backend". Copy it into your secrets manager straight away.
Step 3: Set an environment variable. DeepSeek's examples read DEEPSEEK_API_KEY. Keep the value out of source code, committed notebooks and anything shipped to a browser or mobile app.
export DEEPSEEK_API_KEY="your_api_key"
Step 4: Add balance. Fees are deducted from your balance as you use the API. Requests fail with a 402 error once it runs out, so add funds on the Top up page before you test anything real.
Step 5: Make a test call. Use the example below, then confirm the request appears in your usage page.
This short walkthrough shows the account and key creation steps on the DeepSeek platform.
Your First DeepSeek API Call
DeepSeek uses API formats compatible with OpenAI and Anthropic, so you can keep the SDK you already have. These are the settings that matter:
| Setting | Value |
|---|---|
| Base URL (OpenAI format) | https://api.deepseek.com |
| Base URL (Anthropic format) | https://api.deepseek.com/anthropic |
| Models | deepseek-flash, deepseek-v4-pro |
| Context / max output | 1M tokens / 384K tokens, on both models |
Here is a request with the OpenAI Python SDK. Install it with pip3 install openai first.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("DEEPSEEK_API_KEY"),
base_url="https://api.deepseek.com",
)
response = client.chat.completions.create(
model="deepseek-flash",
messages=[
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hello"},
],
)
print(response.choices[0].message.content)
And the same request with curl:
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-d '{
"model": "deepseek-flash",
"messages": [{"role": "user", "content": "Hello"}]
}'
Thinking mode is on by default. Both models run in thinking mode at high effort unless you change it. That suits hard problems, but it is wasted on simple classification or extraction. For those jobs, add "thinking": {"type": "disabled"} to the request body. With the OpenAI Python SDK, pass it through extra_body.
Old tutorials use old model names. deepseek-v4-flash and deepseek-v4-flash-vision-exp are still accepted, but those models are retired. Requests to them are served by DeepSeek-V4.1-Flash-1017 and billed at the Flash price. Use deepseek-flash in new code. Vision is supported on deepseek-flash but not on deepseek-v4-pro.
DeepSeek API Pricing
The key is free and usage is billed per million tokens. Unlike most providers, DeepSeek charges double at peak hours, so many pricing tables online are only half right. These are the rates on DeepSeek's pricing page as of November 2026:
| Per 1M tokens | deepseek-flash off-peak | deepseek-flash peak | deepseek-v4-pro off-peak | deepseek-v4-pro peak |
|---|---|---|---|---|
| Input (cache hit) | $0.003 | $0.006 | $0.022 | $0.044 |
| Input (cache miss) | $0.15 | $0.30 | $0.66 | $1.32 |
| Output | $0.60 | $1.20 | $1.98 | $3.96 |
Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday through Friday. All other hours are off-peak, including weekends and Chinese public holidays. That timing favors US teams: the whole US working day is off-peak. Teams in Europe and India hit peak hours during their working day, so batch jobs there are worth scheduling for later on.
Cache hits are the biggest discount. A cache hit on deepseek-flash costs 2% of the cache-miss rate. Put your long system prompt and other stable content at the start of every request so repeated prefixes can match.
Search and Fetch cost extra. DeepSeek's standalone Search and Fetch APIs are billed at $0.75 per 1,000 successful requests each. DeepSeek says prices can change, so check its pricing page before you commit to a budget.
What a Real Workload Costs
DeepSeek is cheap, but it is not automatically the cheapest. Take a job that triages 10,000 support tickets at 3,000 input and 700 output tokens each, which is 30 million input and 7 million output tokens. Before caching, using list prices as of November 2026:
| Model | Input / output per 1M | Cost of the job |
|---|---|---|
| gpt-6-luna | $0.10 / $0.50 | $6.50 |
| deepseek-flash, off-peak | $0.15 / $0.60 | $8.70 |
| deepseek-flash, peak | $0.30 / $1.20 | $17.40 |
| deepseek-v4-pro, off-peak | $0.66 / $1.98 | $33.66 |
| grok-4.3 | $1.25 / $2.50 | $55.00 |
| deepseek-v4-pro, peak | $1.32 / $3.96 | $67.32 |
| grok-4.7 | $2 / $6 | $102.00 |
| Claude Sonnet 5.5 | $2 / $10 | $130.00 |
The lesson is to compare on your own token mix and quality bar. A small efficient model from another provider can beat deepseek-flash on price, while deepseek-v4-pro is far cheaper than most flagship-class options. Run a sample of real tasks on each, then price the winner. Compare the alternatives on our OpenAI API pricing, Claude API pricing and Grok API pages.
Rate Limits and Common Errors
DeepSeek limits concurrent requests per account, not per key. The limit is 2,500 concurrent requests on deepseek-flash and 500 on deepseek-v4-pro. A request counts from when you send it until the response finishes. DeepSeek will review a capacity increase at no extra cost if you need more.
While you wait for a response, the server sends empty lines on non-streaming requests and keep-alive comments on streaming requests. The official SDKs handle this, but a custom HTTP parser must too. If inference has not started within 10 minutes, the server closes the connection.
| Error | What it means | What to do |
|---|---|---|
| 401 | Wrong API key | Check the key and the environment variable |
| 402 | Out of balance | Add funds on the Top up page |
| 422 | Invalid parameters | Fix the field named in the error message |
| 429 | Too many requests or concurrency limit hit | Slow down and retry with backoff |
| 503 | Server overloaded | Wait briefly and retry |
Where Your Data Goes
Read this section before you send customer data. DeepSeek's privacy policy says it collects, processes and stores personal data in the People's Republic of China. It lists user input among the data used to train and improve its models, and it describes a right to opt out by emailing privacy@deepseek.com, with availability depending on where you live. The API platform terms are governed by the laws of mainland China, with disputes going to a court with jurisdiction over DeepSeek's registered office in Hangzhou.
For a side project or non-sensitive batch job, that may be fine. If you sell to enterprises or handle regulated data, your customers' security reviews may rule it out, so check before you build on it. This is general information, not legal advice. Keep your model calls behind a thin internal interface so you can change provider without a rewrite.
One alternative is a third-party host. DeepSeek's V4 weights have been reported as published under an MIT license, so other inference providers can serve them under their own terms. Pricing and data handling then come from that provider, not from the tables above.
Is the DeepSeek API Free?
The key is free, but the API is not a free service. DeepSeek's docs describe paying from a topped-up balance or a granted balance, using granted balance first, and they do not publish a fixed signup grant or an ongoing free tier. Third-party articles quote very different signup offers, including 5 million tokens, $2 and $5, so treat those numbers as unconfirmed. Check the balance on your own dashboard after you sign up.
If you need to prototype without paying, other providers publish real free tiers. Our guide to free AI APIs compares them. Be careful with "free DeepSeek API key" videos and sites. Some route you through a third party or a shared key, and you should not send real data through a service you have not vetted.
We have found no official DeepSeek startup credit program. If you want credits, the practical route is a provider that has one, such as Grok for Startups or the cloud programs in our startup AI credits roundup. Because DeepSeek's API follows the OpenAI and Anthropic formats, code written for it moves between providers with few changes.
Frequently Asked Questions
How do I get a DeepSeek API key?
Create an account at platform.deepseek.com, open the API keys page and create a key. Store it in an environment variable called DEEPSEEK_API_KEY, then add balance so your requests do not fail with a 402 error.
How much does the DeepSeek API cost?
As of November 2026, deepseek-flash costs $0.15 input and $0.60 output per million tokens off-peak, and double that at peak. deepseek-v4-pro costs $0.66 input and $1.98 output off-peak, and $1.32 and $3.96 at peak. Cache hits are far cheaper.
When are DeepSeek's peak hours?
Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday through Friday. All other hours are off-peak at half price, including weekends and Chinese public holidays.
Is the DeepSeek API free?
Creating a key is free, but usage is paid from your balance. DeepSeek's docs mention granted balances but do not publish a fixed signup grant or an ongoing free tier, so check your dashboard after signing up.
Is the DeepSeek API compatible with OpenAI?
Yes. Use the OpenAI SDK with the base URL https://api.deepseek.com and your DeepSeek key. DeepSeek also offers an Anthropic-format endpoint at https://api.deepseek.com/anthropic.
Which DeepSeek model should I use?
Start with deepseek-flash. It is cheaper, allows more concurrent requests and supports vision. Move a task to deepseek-v4-pro if testing shows the quality gain is worth the higher price.
Is the DeepSeek API safe for customer data?
That depends on your obligations. DeepSeek's privacy policy says personal data is processed and stored in China and lists user input among the data used to train its models. Review the policy and your customer contracts before sending anything sensitive.
Next Steps
Create a key, add a small balance and run a sample of real tasks on deepseek-flash with thinking both on and off. Compare the results and cost with one other model. Decide whether the data terms work for your customers before you put it in production. If you would rather not pay while you test, start with our free AI API comparison, and see every credit program you can apply for in the AI credits index.