// how to

How to Use the DeepSeek API: Key, Prices and First Call

Sign in at platform.deepseek.com, top up your balance and create a key on the API Keys page. The API uses the OpenAI format at https://api.deepseek.com (and the Anthropic format at /anthropic), so most OpenAI-compatible tools work by changing the base URL, key and model name to deepseek-flash. You pay per million tokens, with off-peak rates at half the peak price.

By Published Last updated 2 min read

The short version

The DeepSeek API is pay-as-you-go and speaks the same “language” as OpenAI’s and Anthropic’s APIs. If a tool lets you set a base URL and an API key, it can probably use DeepSeek.

Step by step

  1. Sign in at platform.deepseek.com (the DeepSeek Platform).
  2. Top up. DeepSeek’s FAQ lists PayPal, bank card, Alipay and WeChat Pay. Balances don’t expire.
  3. Create a key on the API Keys page. Copy it somewhere safe; treat it like a password.
  4. Make a first call with the OpenAI Python library (pip3 install openai):
text
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": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
  1. Check usage on the platform’s Usage page, where you can filter by key and export the details.

Models and prices

DeepSeek’s pricing page lists two model names on October 29, 2026. Prices are per million tokens:

deepseek-flash deepseek-v4-pro
Input, cache hit (off-peak / peak) $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

Both have a 1 million token context and up to 384K tokens of output. Only deepseek-flash accepts images. DeepSeek estimates 1 English character at about 0.3 tokens. The separate Search and Fetch APIs cost $0.75 per 1,000 successful requests each.

Prompts to copy

A system message for a support bot built on the API:

text
You answer questions about [business] using only the policy text below.
If the answer isn't in the text, say "I'll pass this to a colleague" and stop.
Policy: [paste]

Example

Use case: summarizing 500 customer reviews a week.

How to set it up: run the job outside peak hours to pay the off-peak rate, keep the same instructions at the start of every request so they’re billed at the cheaper cache-hit price, and switch thinking off for a simple job like this. See cut your DeepSeek API costs.

Mistakes to avoid

  • Putting the key in a web page or app code. DeepSeek’s FAQ warns never to expose keys in browsers or client-side code. If a key leaks, revoke it on the API Keys page and create a new one.
  • Ignoring error codes. 401 means a wrong key, 402 means your balance ran out, 429 means too many requests at once, and 503 means DeepSeek’s servers are overloaded; retry after a short wait.
  • Using old model names. DeepSeek has retired names before. The pricing page says deepseek-v4-flash now routes to the current Flash model.
  • Sending your customers’ personal data without checking the rules. See use DeepSeek safely at work.

Good to know

Thinking mode is on by default in the API. Turn it off for simple tasks with "thinking": {"type": "disabled"} (passed in extra_body with the OpenAI SDK). Each account can run 2,500 requests at once on deepseek-flash and 500 on deepseek-v4-pro; DeepSeek says it raises limits on request at no extra cost.

Related: use DeepSeek in Claude Code and other tools and cut your DeepSeek API costs.

Frequently asked questions

How much does the DeepSeek API cost?

For deepseek-flash on October 29, 2026: $0.30 per million input tokens ($0.006 when cached) and $1.20 per million output tokens at peak times, and half that off-peak. Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday to Friday, excluding Chinese public holidays.

Does my balance expire?

No. DeepSeek's FAQ says top-up balances don't expire and unused balances can be refunded.

Is the API covered by the same privacy policy as the app?

DeepSeek's privacy policy covers its own services. It notes that apps built by developers on its platform must give their own users their own privacy policy.

Sources

  1. DeepSeek API Docs: your first API call
  2. DeepSeek API Docs: models and pricing
  3. DeepSeek API Docs: error codes
  4. DeepSeek FAQ (API section)