Cost & models
Keys and the limits behind them
A DeepSeek key authenticates a request; it does not buy you capacity. The limits that actually bite are per-model concurrency, a 1M-token context with 384K max output, and a peak window where every price doubles. The first error most people see is a 401, not a limit.
A key is an identity, not a quota. That distinction explains almost every confusing error in the first afternoon: people expect “I have a key, so I have capacity”, then see a 401, a 400, or a bill they did not expect, and assume the key is broken.
This page separates the three things a key touches — authentication, model capacity, and money — and shows the one error we could reproduce without a key.
The first call, and the honest error
The cheapest test is an unauthenticated request: it proves the endpoint exists, that your network reaches it, and what a failure looks like.
$ curl -sS https://api.deepseek.com/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"deepseek-flash","messages":[{"role":"user","content":"ping"}]}'
{"error":{"message":"Authentication Fails (governor) (request_id: cdcfd256-2c4c-4184-ae20-7eed7894c63c)","type":"authentication_error","param":null,"code":"invalid_request_error"}}
HTTP 401. Three things worth noting in that body: the error is nested under error, the type is authentication_error rather than a generic 401 page, and there is a request_id — the one value support will ask you for and the one people forget to copy.
What the key does not control
| Limit | Value | Where it bites |
|---|---|---|
| Context length | 1M tokens | Long agent loops; context is resent every step |
| Max output | 384K tokens | One oversized generation, not the loop |
| Concurrency, flash | 2,500 | Batch jobs, parallel subagents |
| Concurrency, v4-pro | 500 | Same, earlier |
| Peak window | 01:00–04:00 and 06:00–10:00 UTC, Mon–Fri | Price, not throughput: everything doubles |
That last row is the one nobody expects. Concurrency limits throttle you; the peak window does not throttle you at all — it just charges twice as much for identical work. An agent that runs its heavy loop inside 06:00–10:00 UTC pays double for being early.
The model name can lie
Two names are retired: deepseek-v4-flash and deepseek-v4-flash-vision-exp. Requests using them are served by DeepSeek-V4.1-Flash-1017 and billed at the Flash price. So a request that says “v4-flash” may be running V4.1 — which matters when you are comparing outputs between two machines that are nominally on the same model.
Use deepseek-flash and deepseek-v4-pro, and read the model version from the response rather than from your own config.
Key handling, in the order it goes wrong
- Key in a repository. The common path is a config file that works locally and gets committed once. Our own rule: credentials live beside the state, not inside the project —
auth.jsonis in.gitignoreand never appears in a screenshot. - Key in a screenshot. Worse than a commit, because it is not scannable and shows up in support threads.
- Key rotated without restarting the process. The old key keeps being used from memory; you then debug a working key.
- Key scoped to the wrong project. Everything authenticates, but usage is attributed somewhere you are not looking — which looks like “it is not billing me” until it is.
What we have not verified
We have not hit the concurrency limit, so we do not describe the 429 or the error body it returns. We also have not measured whether a mid-run key rotation is picked up without a restart. Both are plausible failure modes with no specimen behind them — treat them as open questions, not as findings.
How you know it worked
An unauthenticated call is a free, repeatable test — it costs nothing and it tells you the endpoint and the error shape are what you think:
$ curl -s https://api.deepseek.com/chat/completions
{"error":{"message":"Authentication Fails (governor) (request_id: cdcfd256-...)",
"type":"authentication_error","param":null,"code":"invalid_request_error"}}
typeis the field to branch on.authentication_errormeans the key is wrong or missing; it does not mean you are out of quota, and it does not mean a model name is wrong. Those are differenttypevalues, and mixing them up is why people regenerate keys that were never the problem.- A
request_idin the body is the thing support can use. Copy it before you retry; a 401 raised three times is three different ids. - What this does not prove: that your key works, that the account has balance, or that a limit applies. It proves the endpoint is reachable and the shape is unchanged.
The positive test — a keyed request returning a usage object — is the only proof the key itself is fine. We describe it, but we do not paste a live keyed response here.
How to undo it
- Rotating a key: create the new key first, deploy it, confirm a keyed call succeeds, then revoke the old one. Do it the other way round and every running client fails between the two steps for no reason.
- A leaked key has no undo. Revoking stops the bleeding; deleting the line from git history does not, because history is mirrored, cached and cloned. Revoke first, tidy the repo second.
- A key in a screenshot or a chat counts as leaked. There is no partial exposure: one image is enough.
- If you keep credentials in
auth.json(mode 600), the undo is the copy you took before editing it — and check the mode again after restoring, becausecpacross filesystems can drop it.
A five-line check before you blame the key
$ curl -sS -o /dev/null -w '%{http_code}\n' https://api.deepseek.com/chat/completions \
-H 'Content-Type: application/json' -d '{"model":"deepseek-flash","messages":[]}'
$ grep -c 'sk-' .env 2>/dev/null || echo 'no dotenv'
$ curl -sS -H "Authorization: Bearer $DEEPSEEK_API_KEY" https://api.deepseek.com/models | head -c 200
Reading the three outputs in order tells you whether you have a network problem, a leaked-key problem, or a key that is simply not set in the shell that runs the agent. The third command is also the shortest way to see which models your key can actually address.
Last checked: 2026-11-18. The 401 is reproduced; the limits are read from the vendor’s own pages; the rate-limit response is explicitly untested.
Related
Questions people actually ask
What does a 401 from DeepSeek actually say?
Without a key: {"error":{"message":"Authentication Fails (governor) (request_id: …)","type":"authentication_error","code":"invalid_request_error"}}, returned with HTTP 401. The request_id is what support asks for.
What are the concurrency limits?
Published as 2,500 for deepseek-flash and 500 for deepseek-v4-pro. We have not hit either, so we do not describe the response body you get when you do.
Do old model names still work?
deepseek-v4-flash and deepseek-v4-flash-vision-exp are retired. Requests using them are served by DeepSeek-V4.1-Flash-1017 and billed at the Flash price — so the name lies about the model.
Sources
Last checked: 2026-11-18 · 401 响应为实跑(无凭据 curl);限额与计费为官方页读数;429/限流响应体未测,页面明标