DeepSeek API Documentation: A Guide to the Official Reference

DeepSeek API documentation guide for deepseek-flash and deepseek-v4-pro: endpoints, thinking mode, peak and off-peak pricing, limits and code samples.

API·April 24, 2026·By DS Guide Editorial
DeepSeek API documentation title card: eyebrow 'API · Documentation guide', title 'DeepSeek API Docs', tagline 'Endpoints, models, thinking mode and pricing.', and four stats: 1M context window; 384K max output; $0.30 Flash miss, peak; $1.32 Pro miss, peak; beside an open-manual illustration.

If you have just been handed a DeepSeek API key and told to ship something by Friday, the first question is usually the same: where in the DeepSeek API documentation do I actually start, and what has changed since V3? As of October 2026, quite a lot. The API now serves two current models from two different releases, thinking mode is a request parameter rather than a separate model, pricing has peak and off-peak rates, and the OpenAI-compatible wire format you already know is unchanged. This guide walks through the reference you need on day one — the endpoints, the parameters, pricing math for both models, and what happened to the legacy IDs — with code you can paste into a shell.

What the DeepSeek API actually is

Title card: eyebrow 'API · Surface map', title 'The API Surface', tagline 'Bearer auth, OpenAI and Anthropic formats.', and four stats: POST chat completions; 2 current models; MIT open weights; 429 concurrency cap; beside a mainframe-wall illustration.

The DeepSeek API is an OpenAI-compatible HTTP service for DeepSeek’s open-weight models. Chat requests hit POST /chat/completions at https://api.deepseek.com, and authentication is a standard bearer token. If your codebase already talks to OpenAI, you change two lines — base_url and api_key — and you are talking to DeepSeek. DeepSeek also offers an Anthropic-compatible format at a separate base URL, https://api.deepseek.com/anthropic, and supports the OpenAI Responses format at https://api.deepseek.com. Beyond chat, the official API reference lists FIM completions (Beta), Files (image uploads for vision), model listing, account balance and the Search/Fetch tools.

Two points that trip up newcomers on day one:

  • The API is stateless. The DeepSeek /chat/completions API is a “stateless” API, meaning the server does not record the context of the user’s requests, so the user must concatenate all previous conversation history and pass it to the chat API with each request. That is the opposite of how the web chat at chat.deepseek.com behaves — the web/app surface keeps chat history for you; the API does not.
  • You choose a model and a thinking setting separately. You pick the model with the model field and reasoning effort with a separate parameter. There is no longer a dedicated “reasoner” model ID.

Current model IDs (as of October 2026)

The official Models & Pricing page lists two models. Both have a 1M-token context, a 384K maximum output, and non-thinking and thinking modes with thinking as the default; both publish their weights under MIT on Hugging Face.

Model ID Served by Context / max output Vision
deepseek-flash DeepSeek-V4.1-Flash-1017 (17 Oct 2026) 1M / 384K Yes
deepseek-v4-pro DeepSeek-V4-Pro-0813 (13 Aug 2026) 1M / 384K No
deepseek-v4-flash, deepseek-v4-flash-vision-exp (legacy) Still accepted; served by DeepSeek-V4.1-Flash-1017 at the Flash price 1M / 384K —

The older IDs deepseek-chat and deepseek-reasoner (which pointed to the non-thinking and thinking modes of the April 2026 V4-Flash preview) were scheduled for retirement on 2026-07-24 at 15:59 UTC and are no longer listed in the official docs. Migrating is a one-line change: the base_url does not move, you only update model — DeepSeek’s 10 September 2026 Change Log says to change the model name to deepseek-flash to call the latest Flash model. If you maintain an older integration, see our notes on DeepSeek OpenAI SDK compatibility.

Long outputs need headroom. For running the open weights locally, the DeepSeek-V4-Pro-0813 model card recommends a maximum output length of 384K tokens for the high and max reasoning effort levels; on the API, set max_tokens generously when you use max.

Quickstart: a working request in curl and Python

The simplest thing that works is a non-streaming call to deepseek-flash. Thinking is enabled by default; to take the faster non-thinking path, pass extra_body={"thinking": {"type": "disabled"}} from Python or "thinking": {"type": "disabled"} in the JSON body. Here it is in curl:

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": "Summarise the DeepSeek V4 release in one sentence."}
    ],
    "thinking": {"type": "disabled"}
  }'

The same call in Python using the OpenAI SDK — note only base_url and the key differ from an OpenAI integration:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepseek.com",
    api_key=os.environ.get("DEEPSEEK_API_KEY"),
)

resp = client.chat.completions.create(
    model="deepseek-flash",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user",   "content": "Summarise the DeepSeek V4 release in one sentence."},
    ],
    extra_body={"thinking": {"type": "disabled"}},  # thinking is on by default; opt out for a fast, short answer
)
print(resp.choices[0].message.content)

If you have not created a key yet, start with our walk-through on how to get a DeepSeek API key, then use this snippet as your smoke test. For more variations — streaming, tool calls, retries — see our collection of DeepSeek API code examples.

Thinking mode: a parameter, not a model

The old “chat vs reasoner” split is now a request parameter. Both current models accept these settings:

  1. Non-thinking. Pass extra_body={"thinking": {"type": "disabled"}} to opt out of the default. No reasoning_content is returned. Required for FIM (Beta).
  2. Thinking (high) — the default. reasoning_effort="high" with thinking enabled is what you get if you send neither flag. Pass it explicitly when you want to be clear; the API returns reasoning_content alongside the final content. reasoning_effort="low" is also accepted; DeepSeek’s 13 August 2026 guidance suggests low for simple tasks and high for daily agent tasks.
  3. Thinking (max). Set reasoning_effort="max" for more complex scenarios. Leave plenty of max_tokens headroom.

Minimal Python for deepseek-v4-pro in thinking mode:

resp = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Plan a safe schema migration for a 2 TB Postgres table."}],
    reasoning_effort="high",
    extra_body={"thinking": {"type": "enabled"}},
)
print(resp.choices[0].message.reasoning_content)  # reasoning content emitted before the final answer
print(resp.choices[0].message.content)            # the final answer

The shape of that response — a separate reasoning_content field plus the normal content — is the same shape the legacy deepseek-reasoner ID produced, so existing parsing code keeps working. For a deeper treatment of when thinking mode earns its extra tokens, see our DeepSeek API review.

Core request parameters worth knowing

The reference page for /chat/completions is long; in practice you will touch a handful of fields. DeepSeek publishes temperature guidance, which is worth matching rather than reinventing — but note that thinking mode (the default) ignores temperature, presence_penalty and frequency_penalty.

Parameter What it does Typical value
temperature Randomness of sampling (non-thinking mode only) 0.0 code/math · 1.0 data analysis · 1.3 chat/translation · 1.5 creative
top_p Nucleus sampling cut-off Model-specific: on deepseek-flash it takes effect only in thinking mode, on deepseek-v4-pro only in non-thinking mode
max_tokens Cap on output length Up to 384K on both models; set high for JSON mode
reasoning_effort "low", "high" or "max" Default “high”; pass extra_body={"thinking": {"type": "disabled"}} for non-thinking
response_format Enables JSON mode {"type": "json_object"}
tools Function/tool declarations OpenAI-compatible schema
stream SSE streaming true for UIs

For local deployment of the open weights, the model cards give their own sampling recommendations: temperature 1.0 and top_p 1.0 for DeepSeek-V4.1-Flash-1017, and temperature 1.0 with top_p 0.95 for agentic scenarios (1.0 otherwise) for DeepSeek-V4-Pro-0813. For the hosted API in non-thinking mode you can deviate from that for specific tasks (code at 0.0, creative at 1.5), but do not copy OpenAI or Claude defaults into DeepSeek without checking.

JSON mode: designed, not guaranteed

JSON mode is one of the most useful features for agent work and also the one most often misused. Three rules:

  • Include the word “json” in the prompt plus a small example schema.
  • Set max_tokens high enough that the output cannot be truncated mid-object.
  • Handle the occasional empty content response on the client side.

JSON mode is designed to return valid JSON, not guaranteed. If you need the details, we cover validation patterns in DeepSeek API JSON mode.

Beta features

In FIM (Fill-In-the-Middle) completion, you provide a prefix and an optional suffix and the model completes the content in between — commonly used for content completion and code completion. FIM runs in non-thinking mode only, its maximum output is 4K tokens, and you must switch the base URL to https://api.deepseek.com/beta. Chat Prefix Completion requires the role of the last message to be assistant with prefix parameter set to True, and also needs base_url=”https://api.deepseek.com/beta” to enable the Beta feature.

Pricing and a worked cost calculation

DeepSeek charges separately for cache-hit input tokens, cache-miss input tokens, and output tokens, and every rate has a peak and an off-peak price. Peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday to Friday, excluding Chinese public holidays; all other hours (weekends included) are off-peak at half the peak rate. As of October 2026, per 1M tokens, per the official pricing page:

Model Cache hit (input), peak / off-peak Cache miss (input), peak / off-peak Output, peak / off-peak
deepseek-flash $0.006 / $0.003 $0.30 / $0.15 $1.20 / $0.60
deepseek-v4-pro $0.044 / $0.022 $1.32 / $0.66 $3.96 / $1.98

Every realistic cost estimate enumerates all three buckets. Here is a worked example for deepseek-flash: 1,000,000 calls, each with a 2,000-token system prompt (cached across calls), a 200-token user message (uncached on arrival), and a 300-token response.

                                                   PEAK                   OFF-PEAK
Cached input   : 2,000 × 1,000,000 = 2,000,000,000 tok × $0.006/M = $12.00    × $0.003/M = $6.00
Uncached input :   200 × 1,000,000 =   200,000,000 tok × $0.30/M  = $60.00    × $0.15/M  = $30.00
Output         :   300 × 1,000,000 =   300,000,000 tok × $1.20/M  = $360.00   × $0.60/M  = $180.00
                                                                    -------               -------
Total                                                               $432.00               $216.00

The same workload on deepseek-v4-pro:

                                       PEAK                       OFF-PEAK
Cached input   : 2,000,000,000 tok × $0.044/M = $   88.00    × $0.022/M = $  44.00
Uncached input :   200,000,000 tok × $1.32/M  = $  264.00    × $0.66/M  = $ 132.00
Output         :   300,000,000 tok × $3.96/M  = $1,188.00    × $1.98/M  = $ 594.00
                                                ---------                --------
Total                                           $1,540.00                $  770.00

On this workload deepseek-v4-pro costs about 3.6 times as much as deepseek-flash ($1,540.00 vs $432.00 at peak; $770.00 vs $216.00 off-peak). A real workload usually straddles both periods, so your bill will land between the two totals. Total input tokens equal prompt_cache_hit_tokens + prompt_cache_miss_tokens, both of which are reported back in the usage field on every response, so you can observe the cache-hit ratio on live traffic rather than guess at it. In thinking mode, reasoning tokens are counted inside completion_tokens and bill as output. For a calculator you can drop your own numbers into, try our DeepSeek pricing calculator, and for the full rate-card context see DeepSeek API pricing.

Rate limits and quotas

DeepSeek limits concurrency rather than tokens per minute. Its Rate Limit & Isolation page sets a per-account limit of 2,500 concurrent requests on deepseek-flash and 500 on deepseek-v4-pro, whichever API key is used; a request counts from the moment it is sent until the response is complete, and requests over the limit get HTTP 429. Higher limits can be requested at no additional cost. While a request waits to be scheduled, the server keeps the connection open with empty lines (non-streaming) or : keep-alive comments (streaming), and closes it if inference has not started after 10 minutes — so your retry logic needs explicit timeouts as well as backoff. The useful operational signals are HTTP status codes (401 for a wrong key, 402 for insufficient balance, 429 for the concurrency limit) plus two endpoints worth wiring into your deploy sanity checks: GET /models (lists the available models) and GET /user/balance (remaining balance). We keep a write-up of throughput behaviour at DeepSeek API rate limits.

Error handling patterns

Because the API uses the OpenAI wire format, the OpenAI SDK maps DeepSeek’s HTTP errors to its usual exception classes (a 429 raises RateLimitError, for example), so existing handlers keep working. The patterns worth baking in from day one:

  • Always validate tool-call arguments. The function arguments are generated by the model as JSON; check that they parse and match your function schema before calling your function.
  • Retry only what can succeed on retry. A 402 is not retryable until you top up the balance; 500 and 503 usually are, after a brief wait.
  • Use explicit timeouts. Because the platform can hold a connection during scheduling (up to the 10-minute cut-off above), set connect and read timeouts deliberately and pair them with a bounded retry rather than waiting indefinitely.
  • Log usage every call. The cache-hit split is how you debug sudden cost spikes.

The full error-code reference lives at DeepSeek API error codes.

Context caching — the cheapest optimisation

Cache-hit pricing is automatic: DeepSeek’s context caching on disk is enabled by default, and when a request fully matches a prefix the system has already persisted, those tokens bill at the hit rate (on deepseek-flash, $0.006 vs $0.30 cache-miss at peak and $0.003 vs $0.15 off-peak — 98% lower either way). Two things to remember. First, only the prefix hits; each new user message is still a miss against that prefix until the model has seen it. Second, DeepSeek describes the cache as “best-effort” with no guaranteed hit rate — you cannot assume a hit rate, only measure it. The practical implication for agent work is to put your stable system prompt and few-shot examples at the start of messages and let the variable user content trail at the end. More detail lives at DeepSeek context caching.

Where to go next

If you want to read the full official reference alongside this page, it is at api-docs.deepseek.com, and the Change Log records each model and pricing change with its date. For everything else on this site, the DeepSeek API docs and guides hub is the starting point.

Frequently asked questions

How do I start using the DeepSeek API?

Create an account at platform.deepseek.com, generate a key, and point an OpenAI SDK at https://api.deepseek.com. Your first call is a POST /chat/completions with a model and messages array — no extra setup. The DeepSeek API getting started walk-through covers account creation, key storage and a first smoke-test script in more detail.

What is the current DeepSeek model and what happened to deepseek-chat?

As of October 2026 the API lists two models: deepseek-flash, served by DeepSeek-V4.1-Flash-1017, and deepseek-v4-pro, served by DeepSeek-V4-Pro-0813. The legacy IDs deepseek-chat and deepseek-reasoner were scheduled for retirement on 2026-07-24 at 15:59 UTC and are no longer listed in the official docs; switch old integrations to deepseek-flash or deepseek-v4-pro. For the full history, see our DeepSeek V4 overview.

Is the DeepSeek API really OpenAI-compatible?

Yes. The wire format matches OpenAI Chat Completions, so changing base_url to https://api.deepseek.com and swapping the key is enough to redirect most existing OpenAI code. DeepSeek-specific fields such as thinking go in extra_body with the Python SDK. Our notes on DeepSeek OpenAI SDK compatibility cover the small edge cases.

Does the DeepSeek API remember my conversation?

No. The DeepSeek /chat/completions API is stateless, meaning the server does not record the context of the user’s requests, so the user must concatenate all previous conversation history and pass it to the chat API with each request. The web chat keeps session history; the API does not. The DeepSeek browser vs app page explains the wider difference between surfaces.

How much does a typical DeepSeek API call cost?

On deepseek-flash, a chat call with a 2,000-token cached system prompt, 200-token user message and 300-token response costs $432.00 per million calls at peak rates and $216.00 off-peak (as of October 2026). The same workload on deepseek-v4-pro costs $1,540.00 per million at peak and $770.00 off-peak. Use our DeepSeek cost estimator to model your own traffic.

Sources & Methodology

Last source check: October 25, 2026

Primary sources

Technical references

Methodology

Pricing figures were checked against the official DeepSeek pricing page and normalised into estimated monthly costs using sample token usage scenarios. Actual costs may vary depending on caching, input/output ratio, regional availability, and provider updates.

Data confidence

High — figures checked directly against the official pricing page on the review date.

Editorial note

The site's pricing dataset is fetched daily from DeepSeek's official pricing page; this article reflects the prices on the date shown above.

Leave a Reply

Your email address will not be published. Required fields are marked *