Key takeaways

  • Create the key on the API keys page of platform.deepseek.com and store it as DEEPSEEK_API_KEY.
  • The API is pay as you go: charges come out of a topped-up or granted balance, and error 402 means the balance is empty.
  • As of October 28, 2026, deepseek-flash costs $0.15 per million cache-miss input tokens off-peak and $0.60 per million output tokens.

DeepSeek how to get an API key, in short: sign in to the DeepSeek platform, open the API keys page and create a key. DeepSeek's quick start says to use that key with the base URL https://api.deepseek.com and the model name deepseek-flash. The API is pay as you go: you add funds on the top-up page, and each request is deducted from that balance.

This guide is for developers who want to make a first call to the DeepSeek API. At the end you will have a key, a funded balance and a working request. Everything below comes from DeepSeek's API docs, read on October 28, 2026. We could not open the platform's own pages, which block scripts, so the exact buttons you click are not described here.

If you only want to know whether DeepSeek costs money, see is DeepSeek free. If you have used another vendor's console, our guide to getting a Claude API key follows a similar path.

What you need first

  • An account on the DeepSeek platform at platform.deepseek.com.
  • A way to add funds. The docs say charges are "deducted from your topped-up balance or granted balance", and that granted balance is used first when you have both.
  • Python with the OpenAI SDK (pip3 install openai), or just curl.

How to get a DeepSeek API key

  1. Go to platform.deepseek.com and sign in.
  2. Open the API keys page. This is the page the docs link to as "apply for an API key".
  3. Create a key and copy it somewhere safe. Treat it like a password.
  4. Store it in an environment variable named DEEPSEEK_API_KEY. DeepSeek's own examples read the key from that name.
export DEEPSEEK_API_KEY="your-key-here"

How to pay for the DeepSeek API

DeepSeek's pricing page says fees come out of your topped-up balance or a granted balance. It advises topping up "based on your actual usage". The error-code page points to a top-up page on the platform when you see error 402, "Insufficient Balance", which means you have run out of balance.

So the order is: create the key, open the top-up page, add funds, then call the API. The docs we could read do not list which payment methods or currencies the top-up page accepts, so check it before you plan around a specific card or wallet.

How to use the DeepSeek API

The API is compatible with the OpenAI and Anthropic formats. You change the base URL and key in an existing SDK or tool and it works.

Setting Value
Base URL, OpenAI format https://api.deepseek.com
Base URL, Anthropic format https://api.deepseek.com/anthropic
API key From the platform's API keys page
Model names deepseek-flash, deepseek-v4-pro

The docs say deepseek-flash is served by DeepSeek-V4.1-Flash-1017. The older names deepseek-v4-flash and deepseek-v4-flash-vision-exp still work, but those models are retired. Requests under those names go to DeepSeek-V4.1-Flash-1017 and are billed at the Flash price.

Here is DeepSeek's curl example from the quick start:

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
      }'

And the Python version from the same page:

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

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

These are non-streaming calls. The docs say you can set stream to true for a streamed response. We did not run either example, because that needs a funded account.

How much the DeepSeek API costs

Prices below are per million tokens, as listed on DeepSeek's pricing page on October 28, 2026. A token is the unit the model reads and bills by, roughly a word or a piece of one. DeepSeek charges less at off-peak hours, which it defines as half the peak rate.

deepseek-flash deepseek-v4-pro
Input, cache hit, off-peak / peak $0.003 / $0.006 $0.022 / $0.044
Input, cache miss, off-peak / peak $0.15 / $0.30 $0.66 / $1.32
Output, off-peak / peak $0.60 / $1.20 $1.98 / $3.96
Context length 1M 1M
Max output 384K 384K

Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday through Friday, excluding Chinese public holidays. Every other hour is off-peak. DeepSeek says it can change prices, so check the page before you top up.

Search and Fetch, two separate APIs, cost $0.75 per 1,000 successful requests each. The docs say that calls made through DeepSeek Harness, Claude Code or Codex are free for now, and per-request billing starts at 00:00 Beijing time on November 1, 2026.

Common problems

DeepSeek's error-code page lists the ones you are most likely to hit:

  • 401, authentication fails: the key is wrong. Check it, or create a new one.
  • 402, insufficient balance: top up your account.
  • 429, rate limit reached: you are sending too fast. The docs list a concurrency limit per account of 2,500 for deepseek-flash and 500 for deepseek-v4-pro, and say you can request more at no extra cost.
  • 500 and 503: a server problem or overload. Wait and retry.

What to do next

DeepSeek says its API also works as the backend for coding tools such as Claude Code, GitHub Copilot and OpenCode with no code, and the docs have an Agent Integrations guide for each. Before you ship anything, read the pricing page again, because the peak and off-peak split changes what a job costs.

Frequently asked questions

How do I get a DeepSeek API key?

Sign in at platform.deepseek.com, open the API keys page and create a key. DeepSeek's docs link to that page as the place to apply for a key.

How do I pay for the DeepSeek API?

You top up a balance on the platform's top-up page, and DeepSeek deducts usage from it, using any granted balance first. The docs we could read do not list payment methods.

How do I use the DeepSeek API?

Point an OpenAI-compatible SDK at https://api.deepseek.com, pass your key and use the model name deepseek-flash or deepseek-v4-pro. An Anthropic-format endpoint also exists at https://api.deepseek.com/anthropic.

Why does the DeepSeek API return error 402?

DeepSeek's error-code page says 402 means insufficient balance. Check your balance and add funds on the top-up page.

Sources

  1. Your First API CallDeepSeek
  2. Models & PricingDeepSeek
  3. Error CodesDeepSeek
  4. Rate Limit & IsolationDeepSeek
  5. DeepSeek PlatformDeepSeek