Skip to content
, ,

How to Get a DeepSeek API Key (November 2026 Guide)

10–15 minutes
Excited woman in a purple denim jacket at a tech conference holding a DeepSeek card, hook 5 minutes DeepSeek API key

Getting a DeepSeek API key takes about five minutes on platform.deepseek.com. The model line-up changed a lot this autumn: deepseek-flash now runs DeepSeek-V4.1-Flash, and on 13 November DeepSeek opened its full set of application APIs.

This guide covers every step. You will sign up, add balance, create and name a key, make your first call with curl and Python, and keep the key safe.

TLDR

  • Where: sign in at platform.deepseek.com, then open the API keys page (platform.deepseek.com/api_keys).
  • Cost: the API is prepaid. Top up a balance first, or calls fail with error 402.
  • Shown once: copy the key the moment it appears. You cannot view it again later.
  • Models: deepseek-flash (V4.1-Flash) and deepseek-v4-pro, both with a 1M token context.
  • Base URLs: https://api.deepseek.com for OpenAI-style calls and https://api.deepseek.com/anthropic for Anthropic-style calls.

What You Need Before You Start

You only need a few things ready. None of them cost anything except the balance you choose to add.

  • An account login: an email address or phone number to register on the DeepSeek Platform.
  • A way to pay: the API runs on a prepaid balance, so you need a payment method that the Top up page accepts in your region.
  • A terminal: macOS Terminal, a Linux shell or Windows PowerShell, to set the key and test it.
  • Python 3 (optional): for the OpenAI or Anthropic Python SDK examples below.

Note: The free DeepSeek chat app and the DeepSeek API are separate products. Using chat.deepseek.com does not give you API access or API balance.

Step 1: Sign Up and Top Up Your Balance

DeepSeek’s API is pay as you go. Each call takes money from your balance based on the tokens you use. When the balance runs out, requests fail with error 402 Insufficient Balance.

  1. Open the platform. Go to platform.deepseek.com and choose to sign up.
  2. Register. Enter your email or phone number, then type the verification code you receive. Check your spam folder if the email code does not arrive.
  3. Set a password. Finish the form and sign in. You land on the platform dashboard.
  4. Open Top up. Click Top up in the left sidebar.
  5. Pick an amount and a payment method. Choose the options shown for your region and confirm the payment.
  6. Check the balance. Your new balance appears on the dashboard and on the Usage page.

The minimum top-up amount and the list of payment methods can change and can differ by region. The Top up page always shows the current options, so read it before you pay.

Tip: Start small. DeepSeek’s own pricing page says to top up based on your actual usage. With deepseek-flash output at $1.20 per million tokens (peak), even a few dollars goes a long way for testing.

Topped-up vs granted balance

DeepSeek tracks two kinds of balance: the topped-up balance (money you paid in) and the granted balance (any promotional credit DeepSeek gives you). When both exist, the granted balance is used first.

Step 2: Create and Name Your API Key

With a balance in place, you can create the key. The whole thing takes under a minute.

  1. Open API keys. Click API keys in the left sidebar, or go to platform.deepseek.com/api_keys.
  2. Create a new key. Click the button to create a new API key.
  3. Name it clearly. Use a name that tells you where the key lives, such as blog-bot-prod or laptop-dev. Good names make it easy to revoke the right key later.
  4. Copy it straight away. The full key is shown only once. Paste it into a password manager or secrets manager before you close the dialog.
  5. Close the dialog. The key now shows in the list with its name, but the secret itself stays hidden.

Warning: If you lose the key, you cannot view it again. Delete it and create a new one. Never paste a key into a public GitHub repo, a screenshot or a chat.

Create one key per app or machine. That way, if one leaks, you delete only that key and the others keep working.

Current Models and Prices (November 2026)

DeepSeek’s API now has two model IDs. Both support a 1M token context, up to 384K output tokens, and both thinking and non-thinking modes. Thinking is on by default.

Model ID Runs Vision Input, cache hit Input, cache miss Output
deepseek-flash DeepSeek-V4.1-Flash-1017 Yes $0.006 $0.30 $1.20
deepseek-v4-pro DeepSeek-V4-Pro-0813 No $0.044 $1.32 $3.96

Prices are per 1 million tokens at peak rates, and off-peak rates are exactly half. Peak hours are 01:00-04:00 and 06:00-10:00 UTC, Monday to Friday. Everything else, including weekends and full Chinese public holidays, is off-peak.

  • Off-peak flash: $0.003 cache hit, $0.15 cache miss and $0.60 output per million tokens.
  • Off-peak pro: $0.022 cache hit, $0.66 cache miss and $1.98 output per million tokens.
  • Legacy names: deepseek-v4-flash and deepseek-v4-flash-vision-exp still work, but those models are retired. Requests go to V4.1-Flash and are billed at the Flash price.

For a full cost breakdown with worked examples, see my DeepSeek API pricing guide.

What changed recently

  • 10 September 2026: DeepSeek-V4.1-Flash launched under the new deepseek-flash name, and API prices dropped.
  • 17 October 2026: deepseek-flash moved to the upgraded V4.1-Flash-1017 build, with the same calling method and price. DeepSeek also opened its in-house search API.
  • 13 November 2026: the full suite of application APIs went live (more below).

Step 3: Save the Key as an Environment Variable

Never hard-code the key in your source files. DeepSeek’s docs use an environment variable named DEEPSEEK_API_KEY, so use the same name.

macOS or Linux (add the line to ~/.zshrc or ~/.bashrc to keep it):

export DEEPSEEK_API_KEY="paste-your-key-here"

Windows PowerShell (the first line is for this session, the second saves it for new windows):

$env:DEEPSEEK_API_KEY = "paste-your-key-here"
setx DEEPSEEK_API_KEY "paste-your-key-here"

For projects, you can also keep the key in a .env file and load it with a library such as python-dotenv. Add .env to your .gitignore first.

Step 4: Make Your First Call (curl and Python)

DeepSeek’s API is OpenAI-compatible. You point any OpenAI client at https://api.deepseek.com and send your DeepSeek key.

Test with curl

This is the official quick-start request, with thinking turned on:

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!"}
        ],
        "thinking": {"type": "enabled"},
        "reasoning_effort": "high",
        "stream": false
      }'

A JSON reply with a choices array means your key works. On Windows, run it in Git Bash or WSL, because PowerShell handles the line breaks and quotes differently.

Test with Python

Install the OpenAI SDK with pip install openai, then run:

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!"},
    ],
    reasoning_effort="high",
    extra_body={"thinking": {"type": "enabled"}},
)

print(response.choices[0].message.content)

Note that thinking goes inside extra_body when you use the OpenAI SDK. The model’s reasoning comes back in message.reasoning_content, next to the normal content.

  • Turn thinking off: pass {"thinking": {"type": "disabled"}} for faster, cheaper replies.
  • Effort levels: low, high (default) and max. Other values like medium are mapped to the nearest level.
  • Streaming: set stream to true to get tokens as they are generated.

Want streaming, multi-turn chat and tool calls? My DeepSeek API Python tutorial goes step by step.

Use the Anthropic-Compatible Endpoint

DeepSeek also speaks the Anthropic Messages format at https://api.deepseek.com/anthropic. The same DeepSeek key works there, so tools built for the Anthropic SDK can run on DeepSeek models.

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_API_KEY="your-deepseek-key"

Then call it with the Anthropic Python SDK (pip install anthropic):

import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="deepseek-flash",
    max_tokens=1000,
    system="You are a helpful assistant.",
    messages=[{"role": "user", "content": "Hi, how are you?"}],
)
print(message.content)
  • Model mapping: names starting with claude-opus map to deepseek-v4-pro. Other claude names map to deepseek-flash.
  • Ignored fields: top_k, cache_control, citations, budget_tokens and mcp_servers are ignored.
  • Unknown names: any other model name returns a 400 error.

Note: DeepSeek has a separate guide for wiring this endpoint into Claude Code. Remember that your prompts then go to DeepSeek’s servers, not Anthropic’s.

The New Application APIs (13 November)

On 13 November 2026, DeepSeek released “the full DeepSeek App experience, now via API”. Your normal key unlocks these features on deepseek-flash through the Chat Completions, Responses and Messages interfaces. DeepSeek runs the tool calls on its own servers.

  • Web search: enable the deepseek_web_search tool with thinking off, and the model searches the web or images and cites sources.
  • Deep thinking search: the same tool with thinking on searches and reads pages across several reasoning steps.
  • File input: PDFs, Office files and images are parsed into the conversation.
  • URL reading: the deepseek_read_url tool fetches links found in user messages.
  • Safety checks: inputs and outputs are screened, and a refusal marker comes back when a risk is found. Public apps must turn this on.
  • Standalone APIs: Search, Fetch, OCR, speech to text and text to speech.

These tools add usage fees on top of tokens. The pricing page lists web search and web fetch at $0.75 per 1,000 calls, and file parsing or OCR at $0.225 per 1,000 pages. For setup code, read my DeepSeek application APIs guide.

Keep Your Key Safe: Rotate and Revoke

Anyone with your key can spend your balance. Treat it like a password and follow these habits.

  • Use env vars or a secrets manager: never commit keys to Git, and add .env to .gitignore.
  • Keep keys on the server: never ship a key inside a website, browser extension or mobile app. Call DeepSeek from your backend.
  • One key per app: separate keys make it simple to cut off one leak without breaking everything.
  • Rotate regularly: create a new key, deploy it, confirm it works, then delete the old one.
  • Top up in small amounts: a modest balance limits the damage if a key leaks.

How to revoke a leaked key

  1. Go to API keys. Open platform.deepseek.com/api_keys.
  2. Find the key by name. This is where clear names pay off.
  3. Delete it. Click the delete icon and confirm. Calls with that key then fail with 401.
  4. Create a replacement. Make a new key and update your app’s environment variable.
  5. Check usage. Review the Usage page for spending you do not recognise.

Rate Limits and Balance Checks

DeepSeek limits concurrent requests per account, not per key. Creating more keys does not raise your limit.

Model Concurrency limit Over the limit
deepseek-flash 2,500 requests HTTP 429
deepseek-v4-pro 500 requests HTTP 429

A request holds a slot from the moment it is sent until the reply finishes. You can ask DeepSeek for a higher limit at no extra cost. If inference has not started within 10 minutes, the server closes the connection.

To check your balance in code, call the balance endpoint:

curl https://api.deepseek.com/user/balance \
  -H "Authorization: Bearer ${DEEPSEEK_API_KEY}"

The reply includes is_available (true if you can still make calls) and a balance_infos list with total, granted and topped-up amounts in CNY or USD.

For a cross-provider look at limits, see LLM API rate limits and tiers.

Troubleshooting: Common Problems and Fixes

Most first-call problems come from one of these errors. My DeepSeek API errors guide covers every code in more depth.

Error What it means Fix
401 Authentication Fails The key is wrong, deleted or missing Check the env var is set in this terminal, with no extra spaces or quotes. Create a new key if needed.
402 Insufficient Balance Your balance is empty Top up on the Top up page, then retry.
429 Rate Limit Reached Too many requests at once Slow down, add retries with backoff, or request a higher limit.
400 Invalid Format The request body is malformed Read the hint in the error message and fix the JSON.
422 Invalid Parameters A parameter value is not allowed Check the model name and parameter values.
500 / 503 Server error or overload Wait briefly and retry.

Other common snags

  • Key works in curl but not Python: your editor or IDE may not see the env var. Restart it after setting the variable, or print os.environ.get("DEEPSEEK_API_KEY") to check.
  • “Model not found” style errors: use deepseek-flash or deepseek-v4-pro. Old names from blog posts may be retired.
  • Empty lines in the raw response: these are keep-alive fillers sent while the model works. SDKs skip them, but raw HTTP parsers must ignore them.
  • Payment declined: try another method listed on the Top up page, or contact your bank about international payments.
  • Requests feel slow or costly: turn thinking off for simple tasks, and run batch jobs off-peak to pay half price.

FAQ

Is the DeepSeek API free?

No. The API is prepaid and charges per token, so you need a balance before calls work. DeepSeek may sometimes add a granted (promotional) balance, which is used first, and the DeepSeek chat app itself is free.

Is the DeepSeek API safe to use?

The API uses HTTPS and your key stays private if you store it well. DeepSeek’s privacy policy says it collects, processes and stores personal data in the People’s Republic of China, so avoid sending sensitive or regulated data. If that is a concern, you can run DeepSeek locally instead.

Can I see my DeepSeek API key again after creating it?

No. The full key is shown only once, at creation. If you lose it, delete it on the API keys page and create a new one.

Which model should I use first?

Start with deepseek-flash. It is the cheapest, supports vision and the new application APIs, and has a 2,500 request concurrency limit. Move to deepseek-v4-pro only if you need its extra quality.

Does the DeepSeek API work with OpenAI and Anthropic SDKs?

Yes. Use https://api.deepseek.com as the base URL for the OpenAI SDK, and https://api.deepseek.com/anthropic for the Anthropic SDK. Your DeepSeek key works for both.

How do I check my remaining balance?

Look at the dashboard on platform.deepseek.com, or call GET https://api.deepseek.com/user/balance with your key. The reply shows whether your balance is enough to make calls.

Do more API keys give me a higher rate limit?

No. Concurrency limits apply to your whole account, whatever key you use. To get more, submit a capacity request to DeepSeek, which it says costs nothing extra.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Excited woman in a purple denim jacket at a tech conference holding a DeepSeek card, hook 5 minutes DeepSeek API key