Create an API key and check the balance
This guide is for developers calling DeepSeek models from a program. If you only want to ask questions in Korean or another language on the web, start with the related guide to ordinary chat.
- Sign in to the official Platform above with the account you intend to use.
- Create a key in API Keys and store it in the connected program’s secret configuration.
- In Top Up and Billing, check payment methods, the billing account and records.
- In Usage, check the time range and API Key filters.
The official FAQ lists PayPal, bank cards, Alipay and WeChat Pay for top-ups. Check what your account actually offers and the payment conditions, then fund only what you need. The FAQ says topped-up balances do not expire; do not assume separately granted credits have the same conditions.
Treat the key like a password. Keep it out of repositories, shared documents, screenshots and browser JavaScript. For a deployed service, pass it through server-side secrets. Separating keys by team member or program purpose makes usage easier to review.
Calculate prices by input, output and time period
The following official rates are in US dollars per million tokens, checked on 25 October and rechecked on 29 October 2026. Recheck the current table before calling, because names, rates and time periods can change.
| Model and billing item | Off-peak | Peak |
|---|---|---|
| deepseek-flash input, cache hit | $0.003 | $0.006 |
| deepseek-flash input, cache miss | $0.15 | $0.30 |
| deepseek-flash output | $0.60 | $1.20 |
| deepseek-v4-pro input, cache hit | $0.022 | $0.044 |
| deepseek-v4-pro input, cache miss | $0.66 | $1.32 |
| deepseek-v4-pro output | $1.98 | $3.96 |
Peak periods are 01:00–04:00 and 06:00–10:00 UTC, Monday–Friday, excluding Chinese public holidays. Other hours, weekends and Chinese public holidays use off-peak rates. Those are UTC times, not the same clock times in Korea or your own location.
Estimate model cost by dividing each category’s token count by one million, multiplying by its rate and adding the results. Character counts and question counts are not enough. Cache hits, output length and reasoning mode affect usage. Separate Search and Fetch API charges are not included in this table.
Prepare a small first request in Python
This Python 3 standard-library example uses the official Chat Completion format. No SDK installation is needed; the key is entered without echo in the terminal. It is not executed on this page, and no paid response-quality test was performed. Running it can incur charges on your account.
Save it as deepseek_first.py and run python3 deepseek_first.py in a terminal. If Windows uses py as the Python command, use py deepseek_first.py. If a warning says hidden key input is unavailable, stop entering the key and use a normal terminal.
import getpass
import json
import urllib.error
import urllib.request
key = getpass.getpass("DeepSeek API key: ").strip()
if not key:
raise SystemExit("API key is required")
payload = {
"model": "deepseek-flash",
"messages": [
{"role": "user", "content": "한국어로 짧게 인사해 줘."}
],
"thinking": {"type": "disabled"},
"max_tokens": 256,
"stream": False,
}
request = urllib.request.Request(
"https://api.deepseek.com/chat/completions",
data=json.dumps(payload).encode("utf-8"),
headers={
"Content-Type": "application/json",
"Authorization": "Bearer " + key,
},
)
try:
with urllib.request.urlopen(request, timeout=90) as response:
result = json.load(response)
except urllib.error.HTTPError as error:
raise SystemExit(f"HTTP {error.code}; check key/balance/limits")
print(result["choices"][0]["message"]["content"])
print(result.get("usage", {}))
The Korean sample message asks for a brief greeting in Korean. Current official documentation lists deepseek-flash and deepseek-v4-pro. The example disables Thinking and caps output at 256 to keep the response short. That is not a fixed price or a guarantee of a total cost ceiling.
For a successful response, inspect its text and usage, then compare them with the same account, time range and key in the Platform. A timeout does not prove the server never received the request; inspect usage before automatically repeating it.
Check 401, 402 and 429 errors
| Code or symptom | Check first |
|---|---|
| 401 authentication failure | Key typos, whitespace, revocation, the DeepSeek key and endpoint |
| 402 insufficient balance | Balance of the key-owning account and the account actually funded |
| 400 or 422 request error | JSON structure, fields and parameters supported by the current model |
| 429 limit reached | Request spacing, concurrent requests and official limits |
| 500 or 503 server problem | Wait briefly, check service status and stop endless retries |
Do not send another provider’s key to a DeepSeek endpoint or use your consumer login password as an API key. For support, prepare the time, code, model and request structure with sensitive information removed. Do not send the full key.
Review usage by key and revoke a leaked key
Use Usage → Time → API Key to select the period and key. The official FAQ also describes opening the amount CSV from an Export ZIP file to inspect costs by key.
If a key is exposed, use API Keys → that key’s trash icon → Revoke and check the confirmation. A revoked key cannot be reused, so replace it in connected programs. Revoking a key and refunding a remaining top-up balance are separate procedures. For an unused-balance refund, check Billing and the official support guidance for the payment method.
Official sources
- Official first API call and model names ↗
- Current token prices and deduction rules ↗
- Chat Completion request and output parameters ↗
- Enable or disable Thinking mode ↗
- Official error codes ↗
- Rate and concurrency limits ↗
- Official FAQ — top-up, usage by key and revocation ↗
