DeepSeek V4 API setup: Flash and Pro, first request to production.

Updated 2026-07-16

DeepSeek V4 ships as two models, deepseek-v4-flash and deepseek-v4-pro, both with a 1M-token context and an OpenAI-compatible request shape. Point base_url at https://api.apisrouter.com/v1, pick a variant, and the same key also serves GLM, Claude, and GPT ids for the steps V4 should not carry.

Quick answer: two ids, one request shape.

DeepSeek V4 is addressable through any OpenAI-compatible client with two exact model strings: deepseek-v4-flash for the fast high-volume tier and deepseek-v4-pro for the deeper reasoning tier. Base URL https://api.apisrouter.com/v1, standard /v1/chat/completions payload, no DeepSeek account or vendor SDK required. If you are migrating older code: DeepSeek's own docs state that the legacy model names deepseek-chat and deepseek-reasoner are deprecated as of July 24, 2026, with the old names mapping to V4 Flash's non-thinking and thinking modes for backward compatibility. New integrations should use the V4 ids directly.

curl https://api.apisrouter.com/v1/chat/completions \
  -H "Authorization: Bearer $APISROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [{"role": "user", "content": "Summarize this changelog in three bullets: ..."}]
  }'

What DeepSeek V4 actually is.

DeepSeek released V4 as an open-sourced preview on April 24, 2026, with MIT-licensed weights for both variants. By the vendor's published figures, V4 Pro is a 1.6-trillion-parameter Mixture-of-Experts with 49B active parameters per token, and V4 Flash is 284B total with 13B active; both serve a 1M-token context with output up to 384K tokens, and both support thinking and non-thinking modes. Capability-wise, the API docs list JSON output, tool calls, and chat prefix completion on both variants, with fill-in-the-middle completion restricted to non-thinking mode. The vendor also publishes concurrency ceilings, 2,500 parallel requests for Flash and 500 for Pro, which is unusually generous and part of why the family dominates batch and agent workloads. One posture note: the release is still labeled a preview, with no announced date for a stable version as of July 2026. In practice the ids have been serving production traffic for months, but teams that depend on frozen behavior should keep a small regression eval around model updates.

Quickstart: Python and JavaScript.

Both official OpenAI SDKs take a custom base URL at construction and pass the model field through as a plain string. Everything else, message roles, max_tokens, streaming, tools, is the standard chat completions surface. The usage block on every response carries prompt_tokens and completion_tokens, which is worth logging from day one on this family: V4's thinking mode bills reasoning as output, so completion_tokens is the honest cost signal, not the visible reply length.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["APISROUTER_API_KEY"],
    base_url="https://api.apisrouter.com/v1",
)

resp = client.chat.completions.create(
    model="deepseek-v4-flash",       # or deepseek-v4-pro
    messages=[
        {"role": "system", "content": "You are a precise technical assistant."},
        {"role": "user", "content": "Explain the difference between a mutex and a semaphore."},
    ],
    max_tokens=2000,
)
print(resp.choices[0].message.content)
print(resp.usage)

Flash vs Pro: when to pick which.

The dedicated Flash-vs-Pro pricing page linked below works the cost math per workload. The short version: the 3x rate difference only matters on tasks Pro is genuinely needed for, and the point of sharing an endpoint is that routing per task costs nothing to change.

  • Default to Flash. Chat, extraction, summarization, classification, straightforward agent steps: Flash handles them at roughly a third of Pro's per-token rate, and its published concurrency ceiling is five times higher.
  • Escalate to Pro when you can name the failure. Multi-step reasoning that loses the plot, hard code Flash fumbles, long tangled instructions it drops: those named workloads are what Pro's deeper reasoning buys.
  • The escalation test costs minutes: run your worst real prompt on Flash five times. If it holds, keep the lower rate; if it demonstrably fails, move that workload to Pro and leave the rest on Flash.
  • Mixing is a string edit, not an architecture decision. Same endpoint, same request shape; many teams run Pro as the planner and Flash as the executor inside one loop.

Tool calls and JSON output.

Both V4 variants list tool calls and JSON output among their supported features, exposed through the standard OpenAI conventions: a tools array of function declarations for calling out, and response_format for constrained JSON. Agent frameworks that speak the OpenAI function-calling protocol work against either id without adapters. Two practical notes from the vendor docs. Fill-in-the-middle completion is non-thinking-mode only, which matters to code-completion integrations. And on thinking-mode requests, tool selection happens after a reasoning pass, so tool-heavy loops bill more output than the visible JSON suggests; log completion_tokens across whole runs rather than per visible payload.

tools = [{
    "type": "function",
    "function": {
        "name": "search_orders",
        "description": "Search orders by customer email",
        "parameters": {
            "type": "object",
            "properties": {"email": {"type": "string"}},
            "required": ["email"],
        },
    },
}]

resp = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{"role": "user", "content": "Find orders for jane@example.com"}],
    tools=tools,
    max_tokens=2000,
)
print(resp.choices[0].message.tool_calls)

Streaming.

Set stream to true and consume server-sent chunks; both variants stream through the standard interface. On thinking-mode requests the model may reason before the first visible token, so streaming is the difference between a UI that shows progress and one that appears hung. For batch pipelines where latency is irrelevant, non-streamed calls keep per-request usage accounting simplest. If you need token usage on streamed requests, the OpenAI SDKs expose stream_options with include_usage, which appends a final usage chunk; support varies across OpenAI-compatible servers, so verify it once against the endpoint before building dashboards on it.

stream = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{"role": "user", "content": "Write a product description for a mechanical keyboard."}],
    max_tokens=1500,
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content if chunk.choices else None
    if delta:
        print(delta, end="", flush=True)

Pay-as-you-go · transparent per-model pricing

Selected models are priced below official list prices. Exact input, output, cache, and per-request prices are shown for each model.

ModelOfficial PriceOur Price
DeepSeek V4 Flash$0.14 / $0.28 per M$0.13 / $0.25 per M
DeepSeek V4 Pro$0.43 / $0.87 per M$0.39 / $0.78 per M
GLM-5.2$1.14 / $4.00 per M$1.03 / $3.60 per M
Claude Sonnet 4.6$3.00 / $15.00 per M$2.40 / $12.00 per M
GPT-5.5$5.00 / $30.00 per M$4.00 / $24.00 per M

Verify the endpoint and debug the first request.

List the served models first; both V4 ids should appear exactly as documented. A 401 means the key is wrong for the endpoint or missing from the environment your process actually runs in. A 404 usually means the base URL lost its /v1 suffix, since SDKs append route paths to whatever base they get. A model-not-found error is an id typo: the strings are deepseek-v4-flash and deepseek-v4-pro, fully hyphenated. If replies seem to stall on hard prompts, that is thinking-mode latency rather than an endpoint fault; stream the response or test the same prompt on Flash. And if older code suddenly errors on deepseek-chat or deepseek-reasoner, that is the July 24, 2026 deprecation landing, and the fix is the V4 ids above. Once traffic flows, the per-key usage view in the APIsRouter console breaks out model, token counts, and spend per request, which settles the Flash-vs-Pro question with your own data inside a day.

curl -s https://api.apisrouter.com/v1/models \
  -H "Authorization: Bearer $APISROUTER_API_KEY" | grep deepseek

FAQ

What are the DeepSeek V4 model ids?

deepseek-v4-flash and deepseek-v4-pro, fully hyphenated and lowercase. The legacy names deepseek-chat and deepseek-reasoner are deprecated as of July 24, 2026, per DeepSeek's docs, and new integrations should use the V4 ids directly.

Does DeepSeek V4 work with the OpenAI SDK?

Yes. Both variants speak the standard chat completions surface, so the official Python and Node SDKs work by setting base_url to https://api.apisrouter.com/v1 and passing the model id as a string. Streaming, tools, and JSON output use the normal OpenAI conventions.

What is the difference between DeepSeek V4 Flash and Pro?

Scale and depth. By vendor figures, Flash is 284B total parameters with 13B active; Pro is 1.6T total with 49B active. Flash is the high-volume default at roughly a third of Pro's rate; Pro reasons more reliably through multi-step tasks, hard code, and long instructions. Both share the 1M context and request shape.

What context window does DeepSeek V4 have?

One million tokens on both variants, with output up to 384K tokens, per DeepSeek's API docs, and the catalog here serves the V4 ids with the 1M window. Long contexts re-bill as input every request, so the window is a capacity fact, not a free feature.

Is DeepSeek V4 a reasoning model?

Both variants support thinking and non-thinking modes. Reasoning tokens bill as output, so on hard prompts completion_tokens runs well past the visible reply. Budget max_tokens with headroom and log usage per request for honest cost numbers.

Do I need a DeepSeek account to use the V4 API?

Not through a gateway. APIsRouter serves both V4 ids behind one key alongside GLM, Claude, and GPT models, with a free starting credit and no card required, so the first requests cost nothing while you evaluate.