DeepSeek API: How to Get an API Key, Pricing and Your First Call (V4.1 Flash Guide)
A practical DeepSeek API guide: API key, base URL, curl and Python examples, deepseek-flash vs v4-pro pricing, parameters, rate limits and GDPR considerations.
Photo by <a href="https://unsplash.com/@ffstop?utm_source=WP+Agent&utm_medium=referral">Fotis Fotopoulos</a> on <a href="https://unsplash.com/?utm_source=WP+Agent&utm_medium=referral">Unsplash</a>
The DeepSeek API is one of the cheapest ways to add a frontier-class language model to an app, script or coding tool. In this guide you will learn how to get a DeepSeek API key, make your first call in curl and Python, choose between the deepseek-flash and deepseek-v4-pro models, understand the peak and off-peak pricing, and use the API safely from the UK or the EU. It is written for beginners, but developers will find the parameters, limits and error codes they need.

All prices, model names and parameters below were checked on 6 October 2026 against DeepSeek’s official API documentation. DeepSeek changes prices and model names fairly often, so confirm the figures on its pricing page before you budget a project.
Why the DeepSeek API Is in the News
On 5 October 2026, AI Weekly reported Bloomberg Intelligence analysis showing DeepSeek V4.1 Flash scoring 81.1 on the LiveBench benchmark, against 83.4 for Anthropic’s leading model: a gap of roughly 3%. On LiveBench’s agentic coding sub-score, the same report put DeepSeek ahead (77.3 versus 66.1). Benchmarks are not the whole story, but they explain why so many developers are now searching for how to use the DeepSeek API.
DeepSeek released V4.1 Flash on 10 September 2026. According to its release note, it is a 552-billion-parameter mixture-of-experts model that activates only 8 billion parameters for input and 16 billion for output, includes native visual understanding, and is published as open weights on Hugging Face. Through the API it is simply called deepseek-flash.
DeepSeek API Models
| API model name | Underlying model | Context length | Max output | Best for |
|---|---|---|---|---|
deepseek-flash |
DeepSeek-V4.1-Flash | 1M tokens | 384K tokens | Most tasks: chat, coding, agents, high volume |
deepseek-v4-pro |
DeepSeek-V4-Pro-0813 | 1M tokens | 384K tokens | Workloads you have tested and found need the larger model |
Older names such as deepseek-v4-flash and deepseek-v4-flash-vision-exp are still accepted, but DeepSeek says those models have been retired: requests are served by V4.1 Flash and billed at the Flash price. If you are updating old code, switch to deepseek-flash so your logs show the model you are really using.
DeepSeek API Pricing (October 2026)
DeepSeek charges per million tokens in US dollars, with separate prices for cached input, uncached input and output. Off-peak rates are half the peak rates.
| Model | Input (cache hit) | Input (cache miss) | Output |
|---|---|---|---|
deepseek-flash, off-peak |
$0.003 | $0.15 | $0.60 |
deepseek-flash, peak |
$0.006 | $0.30 | $1.20 |
deepseek-v4-pro, off-peak |
$0.022 | $0.66 | $1.98 |
deepseek-v4-pro, peak |
$0.044 | $1.32 | $3.96 |
Peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday to Friday, excluding Chinese public holidays. For readers in Europe that means peak pricing covers much of the working morning: during European summer time, 06:00–10:00 UTC is 07:00–11:00 in London and 08:00–12:00 in Berlin or Paris (one hour earlier once the clocks go back). Batch jobs scheduled for the afternoon, evening or weekend are charged at the lower rate.
A worked cost example
Suppose a script sends 1 million uncached input tokens and receives 200,000 output tokens using deepseek-flash:
- Peak: 1 × $0.30 + 0.2 × $1.20 = $0.54
- Off-peak: 1 × $0.15 + 0.2 × $0.60 = $0.27
Repeated prompts that hit the cache cost a tiny fraction of that. DeepSeek bills by deducting from a prepaid balance; when you have both a granted (promotional) balance and a topped-up balance, the granted balance is used first. There is no free tier listed on the pricing page, so you will need to add credit before your first call succeeds.
For context, our guides to Claude API and subscription pricing and ChatGPT pricing show how other providers charge for comparable access.
How to Get a DeepSeek API Key
- Create an account on the DeepSeek Platform at platform.deepseek.com.
- Add credit through the top-up page. Calls fail with error 402 if your balance is empty.
- Open the API keys page and create a new key. Copy it immediately and store it somewhere safe, such as a password manager.
- Save it as an environment variable rather than pasting it into code:
export DEEPSEEK_API_KEY="your-key-here"
On Windows PowerShell, use $env:DEEPSEEK_API_KEY="your-key-here" for the current session. Never commit keys to GitHub; if one leaks, delete it on the platform and create a new one.
How to Use the DeepSeek API: Your First Call

The DeepSeek API is OpenAI-compatible. The base URL is https://api.deepseek.com, so most tools and SDKs built for OpenAI’s chat completions format work once you change the base URL, key and model name.
Option 1: 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": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"stream": false
}'
Option 2: Python with the OpenAI SDK
Install the SDK with pip install openai, then point it at DeepSeek:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["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": "Explain GDPR in two sentences."},
],
)
print(response.choices[0].message.content)
Option 3: The Anthropic-compatible endpoint
DeepSeek also offers an Anthropic-compatible endpoint at https://api.deepseek.com/anthropic. Set these two environment variables and the Anthropic SDK (or tools built on it) will talk to DeepSeek instead:
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_API_KEY=${DEEPSEEK_API_KEY}
According to DeepSeek’s documentation, unsupported model names sent to this endpoint are mapped automatically: names containing “opus” go to deepseek-v4-pro, while “sonnet” and “haiku” go to deepseek-flash. DeepSeek also publishes integration pages for coding agents such as Claude Code, Codex and OpenCode. If you are new to those tools, our Claude Code beginner’s guide explains how terminal coding agents work, and our DeepSeek Harness guide covers DeepSeek’s own open-source agent.
Key DeepSeek API Parameters
| Parameter | What it does | Values |
|---|---|---|
thinking.type |
Turns step-by-step reasoning on or off | enabled (default) or disabled |
reasoning_effort |
How much reasoning the model spends | none, low, high (default), max |
response_format |
Forces valid JSON output | {"type": "json_object"} |
tools / tool_choice |
Function calling for agents | JSON Schema functions; auto, none, required |
max_tokens |
Caps the length of the reply | Up to 393,216; defaults to 8K (thinking off) or 64K (thinking on) |
temperature |
Randomness of the output | 0–2 (default 1) |
stream |
Sends the reply as it is generated | true or false |
Thinking mode is on by default, which improves difficult answers but uses more output tokens. For simple classification, extraction or short replies, disabling thinking (or lowering the effort) is an easy way to cut costs and latency. DeepSeek’s quick-start and API reference show the reasoning setting in slightly different places, so check the current API reference for the exact field position in your SDK.
Rate Limits and Common Errors
DeepSeek uses account-level concurrency limits rather than requests per minute: up to 2,500 concurrent requests for deepseek-flash and 500 for deepseek-v4-pro. Going over returns HTTP 429. DeepSeek says higher quotas can be requested at no extra cost. You can also pass a user_id (letters, numbers, hyphens and underscores, up to 512 characters, no personal data) to separate your own users for safety, caching and scheduling purposes.
| Error | Meaning | Fix |
|---|---|---|
| 400 | Invalid request body | Check your JSON against the API reference |
| 401 | Authentication failed | Check the key is correct and active |
| 402 | Insufficient balance | Top up your account |
| 422 | Invalid parameters | Fix the parameter named in the error |
| 429 | Rate limit reached | Slow down or request a higher quota |
| 500 / 503 | Server error or overload | Wait briefly and retry with back-off |
Long requests stay alive with periodic empty lines or keep-alive comments, but DeepSeek closes connections that are inactive for 10 minutes. Build retries with exponential back-off into any production code.
Using the DeepSeek API in the UK and EU: Privacy and GDPR

Price is only half of the decision for European businesses. DeepSeek has faced regulatory scrutiny in Europe over data transfers to China:
- In January 2025, Italy’s data protection authority, the Garante, blocked DeepSeek’s app and opened an investigation into its GDPR compliance, Euronews reported. Authorities in Ireland, Belgium, France, Spain and Portugal also opened inquiries.
- In June 2025, Berlin’s data protection commissioner, Meike Kamp, said DeepSeek’s transfer of user data to China was unlawful and reported the app to Apple and Google under the Digital Services Act, according to TechRadar.
These actions targeted the consumer app, and the regulatory position may have changed since, but they matter for API users too. Before sending personal or confidential data, read DeepSeek’s current privacy policy and terms, do a data protection impact assessment where required, and avoid sending personal data you do not need to.
Because V4.1 Flash is published as open weights, organisations that need data to stay in Europe have another route: host the model on their own infrastructure or with a provider whose servers and contracts meet their requirements. Be aware that the full model is very large; Activepieces estimates around 614 GB of GPU memory for self-hosting. For smaller open models on your own hardware, see our guide on how to run an LLM locally. European companies that prefer an EU provider can also compare Mistral’s offering, including its new Mistral Large 4 model and API pricing.
DeepSeek API Pros and Cons
Pros
- Very low per-token prices, halved again during off-peak hours
- OpenAI- and Anthropic-compatible endpoints, so existing tools work with minimal changes
- 1-million-token context and up to 384K output tokens
- Function calling, JSON output and adjustable reasoning effort
- Open weights for V4.1 Flash, allowing self-hosting
Cons
- No free tier on the official API; you must prepay
- Peak-hour pricing overlaps with the European working morning
- Data-protection questions for EU and UK organisations
- Model names and prices change often, so code and budgets need checking
Frequently Asked Questions
Is the DeepSeek API free?
No. The official pricing page lists paid rates only, and requests fail with error 402 when your balance is empty. Some third-party platforms offer DeepSeek models with free quotas, but those are separate services with their own terms.
What is the DeepSeek API base URL?
For the OpenAI-compatible format it is https://api.deepseek.com. For the Anthropic-compatible format it is https://api.deepseek.com/anthropic.
Which DeepSeek API model should I use?
Start with deepseek-flash. It is far cheaper than deepseek-v4-pro, and DeepSeek’s release note says V4.1 Flash outperforms V4-Pro on several benchmarks. Test the Pro model only if Flash falls short on your own tasks.
How much does the DeepSeek API cost?
deepseek-flash costs $0.30 per million uncached input tokens and $1.20 per million output tokens at peak, and half that off-peak. Cached input is much cheaper.
Can I use the DeepSeek API with Claude Code or Cursor?
DeepSeek publishes integration guides for several coding agents. For Anthropic-based tools, set ANTHROPIC_BASE_URL to https://api.deepseek.com/anthropic and use your DeepSeek key. OpenAI-compatible tools need the base URL https://api.deepseek.com and the model name deepseek-flash.
Is the DeepSeek API GDPR-compliant?
That is for your organisation to assess. Several European regulators have raised concerns about DeepSeek’s data transfers to China, so seek advice before processing personal data, or consider self-hosting the open weights.
Conclusion
The DeepSeek API is easy to adopt: create an account, top up, generate a key, set the base URL to https://api.deepseek.com and call deepseek-flash. Schedule heavy jobs outside peak hours, turn thinking off for simple tasks, and handle 429 and 5xx errors with retries. For European teams, weigh the low price against data-protection obligations, and remember that open weights give you a self-hosted option if data location matters.
Sources: DeepSeek API docs – first API call; Models & pricing; Chat completion API reference; Anthropic API guide; Rate limit & isolation; Error codes; DeepSeek-V4.1-Flash release note; AI Weekly on LiveBench (5 October 2026); Euronews; TechRadar; Activepieces.

3 thoughts on “DeepSeek API: How to Get an API Key, Pricing and Your First Call (V4.1 Flash Guide)”