DeepSeek V4 Pro API: Key, Endpoint, and Python Quickstart
Aug 13, 2026

DeepSeek V4 Pro API: Key, Endpoint, and Python Quickstart

Connect to the DeepSeek V4 Pro API in 3 steps: get a key at platform.deepseek.com, point at the OpenAI-compatible endpoint, and run copy-paste Python and curl examples — including thinking mode.

You just got the go-ahead to integrate DeepSeek V4 Pro, and now you are stuck on the most annoying part: the model ID lives on the pricing page, the request examples are scattered across separate guides, nobody tells you thinking mode is on by default, and your first request returns an error you do not recognize. This is the classic "I have the model, I cannot call it" gap. This guide collapses all of it into one page: where the key is issued, what the endpoint and model ID are, and copy-paste Python and curl examples that work — including how to toggle thinking mode, stream, and debug the errors that stop everyone (401, 429, 400).

Everything here is written against DeepSeek's official API documentation and model pages as of 2026-08-13, when DeepSeek released the current DeepSeek-V4-Pro-0813 update. Model IDs, parameters, and pricing drift fast — treat the official pricing page as the source of truth for production, and confirm the exact model string in your dashboard before you ship.

What This Article Solves

Three friction points kill most first integrations with the DeepSeek V4 Pro API:

  • Where things live. The API key is issued on the developer platform, the base URL is different for OpenAI- and Anthropic-format clients, and the model ID is documented on the pricing page rather than in a single "copy this" block.
  • What the defaults are. V4 Pro ships with thinking mode enabled by default, which surprises people who expect a plain chat completion — and costs output tokens you may not have budgeted for.
  • Why requests fail. 401/429/400 errors plus a 500-concurrent-request ceiling that is much tighter than the Flash tier's 2,500, with different engineering implications.

The short version of the fix: get a key at platform.deepseek.com, point your OpenAI-format client at https://api.deepseek.com, use the model ID from the pricing page, and the first request runs in under two minutes. Read on for the copy-paste version.

Prerequisites: Account and DeepSeek V4 Pro API Key

DeepSeek issues API credentials from its developer platform, not from the consumer chat app. Three steps:

  1. Go to platform.deepseek.com and sign in, or create an account.
  2. Open API Keys in the dashboard and create a new key. Copy it immediately — the full secret is shown only once, like most providers.
  3. Top up your account balance. The DeepSeek API is pay-as-you-go by token usage.

Store the key as an environment variable rather than hardcoding it into source files:

export DEEPSEEK_API_KEY="your-api-key-here"

Windows PowerShell equivalent:

$env:DEEPSEEK_API_KEY = "your-api-key-here"

That is the whole "deepseek v4 pro api key" story: it lives on the developer platform, it is a standard bearer token, and there are no signing or handshake steps.

DeepSeek V4 Pro Model ID and Base URL

Two values matter, and both are documented in the official quick start and pricing pages.

  • Base URL: https://api.deepseek.com for OpenAI-compatible clients (DeepSeek also accepts https://api.deepseek.com/v1 — the v1 is a compatibility path, not an API version). For Anthropic-format clients, use https://api.deepseek.com/anthropic.
  • Model ID: deepseek-v4-pro is the model string listed in DeepSeek's official model and pricing tables, covering the current DeepSeek-V4-Pro-0813 release. The 0813 update is the latest version as of this writing; always confirm the exact string in your dashboard, since model IDs can shift across releases.

If your stack is Anthropic-shaped — you already use the Anthropic SDK or Claude Code-style tooling — DeepSeek exposes an Anthropic-compatible surface at the /anthropic base URL, so you can point an existing Anthropic client at V4 Pro with the same key. That is the "deepseek v4 pro anthropic api" path: same API key, different base URL, same model string.

Python Quickstart: First DeepSeek V4 Pro Request

No DeepSeek-specific library is needed — install the OpenAI SDK and you are done, because the V4 Pro API is OpenAI-compatible end to end:

pip install openai

Then a standard chat completion:

import os
from openai import OpenAI

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

response = client.chat.completions.create(
    model="deepseek-v4-pro",  # confirm the exact ID in your dashboard
    messages=[
        {"role": "system", "content": "You are a senior software engineer."},
        {"role": "user", "content": "Explain when to choose an orchestrator pattern over a simple queue for an agent pipeline, in three sentences."},
    ],
)

print(response.choices[0].message.content)

If you get text back, key + endpoint + model ID are all correct. That is the "deepseek v4 pro python" flow in its entirety: change base_url and model on any existing OpenAI SDK code and your integration is live.

Non-thinking vs thinking, side by side. V4 Pro supports both thinking (default) and non-thinking modes, and the toggle is a parameter you can add to the same call. Here is the same prompt in non-thinking mode:

import os
from openai import OpenAI

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

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    thinking={"type": "disabled"},  # non-thinking mode; see official thinking-mode guide
    messages=[
        {"role": "user", "content": "Rewrite this commit message in ten words: <paste your draft>"},
    ],
)

print(response.choices[0].message.content)

The schema for the thinking toggle is versioned — check the official Thinking Mode guide for the exact shape on your release — but the pattern is constant: one parameter switches between the reasoning path and the fast path, and both modes use the same model ID and endpoint.

The Same Request in curl

For smoke tests, scripts, or non-Python stacks, the raw HTTP call is:

curl https://api.deepseek.com/chat/completions \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [
      {"role": "user", "content": "What is the context window of DeepSeek V4 Pro?"}
    ]
  }'

That is the "deepseek v4 pro curl" recipe: one POST to the OpenAI-format endpoint, bearer auth, JSON body. Because the surface is OpenAI-compatible, LangChain, LlamaIndex, Instructor, and any internal wrapper that speaks chat completions work with the same two substitutions.

Going Further: Streaming, JSON Output, Tool Calls, Responses API

Once the plain request works, the next four capabilities cover most production needs.

Streaming — for chat UIs and agents, render tokens as they arrive:

import os
from openai import OpenAI

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

stream = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {"role": "user", "content": "List three pitfalls of long-context RAG."},
    ],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

The response becomes a sequence of server-sent events in OpenAI's streaming format. Guard with if delta: — the final chunk can carry an empty content field. Note that in thinking mode, V4 Pro can emit a reasoning preamble before the final answer, so if your UI shows a single blob, decide explicitly how to surface (or hide) that phase.

JSON output — for extraction pipelines, force structured output with response_format:

import os
from openai import OpenAI

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

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    response_format={"type": "json_object"},
    messages=[
        {"role": "user", "content": "Extract the model names and their prices as JSON."},
    ],
)

print(response.choices[0].message.content)

Tool calls — V4 Pro supports function calling natively, so agents can hand off to tools within the same chat-completions shape you already know from OpenAI. Register tools with JSON schemas, read tool_calls from the response, execute, and append the result message — the loop is identical to standard OpenAI tool-calling.

Responses API — DeepSeek also exposes a Responses API surface for agent-centric workflows, along with Chat Prefix Completion (Beta) and FIM Completion (Beta, non-thinking mode only) on the official feature matrix. If your codebase already uses the Responses API shape, check the official docs for the compatible endpoint before porting.

Thinking Mode Deep Dive: It's On by Default

The single biggest surprise in the V4 Pro API is the default. V4 Pro runs in thinking mode by default — the model does chain-of-thought reasoning before producing its final answer. That is a feature when you want it and a hidden cost when you do not:

  • Latency: the reasoning phase adds time before the first answer token. Independent measurements on Artificial Analysis put V4 Pro's output speed at 83.2 tokens/s with a 1.63s time-to-first-token (better than the category median of 1.89s), but those are final-stream numbers — the reasoning preamble still adds wall-clock time per request.
  • Cost: reasoning tokens are billed as output tokens at $0.87 per 1M on DeepSeek's official pricing. Artificial Analysis's evaluation also showed V4 Pro is verbose — ~130M tokens of output across the eval suite versus a ~100M category median — so thinking mode inflates the output-token bill on top of the reasoning itself.
  • When to turn it off: for extraction, classification, routing, formatting, and any task where a fast, direct answer is the goal, pass the non-thinking toggle (thinking={"type": "disabled"} in the pattern above) and you cut both latency and output spend. For hard coding, math, and agentic planning, leave it on — that reasoning depth is the point of paying for a flagship.

Rule of thumb: default to non-thinking for high-volume shallow tasks, and turn thinking on per-request only where the answer quality measurably improves. Because the switch is per-request, you can route by difficulty — bulk traffic non-thinking, escalated prompts thinking — with a single code path.

Troubleshooting: 401, 429, 400 — and the Concurrency-500 Wall

Most first-call failures are one of four things:

ErrorMeaningFix
401 UnauthorizedBad or missing API keyCheck DEEPSEEK_API_KEY is exported in the same shell; regenerate the key if it was rotated.
429 Too Many RequestsRate or concurrency limit hitRetry with exponential backoff (1s, 2s, 4s); pass max_retries=3 to the OpenAI client constructor.
400 Bad RequestMalformed body, bad model ID, or an unsupported parameter comboValidate JSON, confirm the model string from the pricing page, and drop parameters the schema rejects (e.g., FIM params in a chat call).
Concurrency capped at 500Account-level parallel-request ceilingQueue batch jobs, add backoff, and parallelize cautiously (see below).

The engineering implication of the 500-concurrent-request limit deserves emphasis, because it differs from the Flash tier (2,500 concurrent). With a reasoning flagship that emits long outputs at ~83 tokens/s, one in-flight thinking request can occupy a concurrency slot for tens of seconds — so a handful of parallel agents can consume the ceiling far faster than your intuition from the Flash tier suggests. Practical mitigations:

  1. Build a queue for batch work rather than firing unbounded parallel loops — this is where most teams hit 429 despite being "nowhere near" a big number.
  2. Use context caching aggressively. DeepSeek's official pricing lists cache-hit input at $0.003625 per 1M — a ~99% discount off the $0.435 cache-miss rate — and cached prefixes also speed up repeated calls with shared system prompts and few-shot context, which directly relieves the concurrency pressure on multi-turn agents.
  3. Treat the ceiling as a design constraint, not a fact. DeepSeek's official note warns that pricing will rise significantly in the near future; concurrency limits are account-dependent too, so budget against the live pages, not a cached number.

When GLM 5.2 Is Worth a Look

If you chose V4 Pro because you need flagship-class reasoning and coding, you are paying flagship prices for it — and that is exactly the moment to benchmark the alternative in the same bracket. GLM 5.2 is Zhipu AI's flagship: a ~750B-parameter Mixture-of-Experts model with ~40B active per token, a 1M-token context window, MIT open weights, and a design tuned hard for coding and agentic workflows. The comparison is honest: V4 Pro's ~1.6T total parameters make it the larger raw model, while GLM 5.2's leaner active footprint targets the same frontier-quality tier with different economics.

Where V4 Pro costs you more on every token and every reasoning preamble — and the official pricing page warns of a significant near-term price increase — GLM 5.2 is free to try before you commit anything. Run your exact production prompts — the same messages array, the same tools, the same streaming code — against both and keep whichever wins your evals. Try GLM 5.2 in the browser at glm5.app/chat with no API key, then wire it through the same OpenAI-compatible pattern shown above. If your workload is heavy agentic tool use or multi-file coding, the comparison is worth the five minutes.

FAQ

Where do I get a DeepSeek V4 Pro API key?

From the developer platform at platform.deepseek.com, under API Keys. The consumer chat app does not issue API credentials; the platform also handles balance top-ups.

What is the DeepSeek V4 Pro endpoint and model ID?

Base URL https://api.deepseek.com (OpenAI format) or https://api.deepseek.com/anthropic (Anthropic format), model ID deepseek-v4-pro — confirm the exact string in your dashboard, since the current release is DeepSeek-V4-Pro-0813.

Is the DeepSeek V4 Pro API OpenAI-compatible?

Yes. You change base_url and model; everything else — messages, stream, tools, response_format — follows the OpenAI chat-completions format, and the same key works against the Anthropic-format endpoint.

Is thinking mode on by default? How do I turn it off?

Yes, V4 Pro defaults to thinking mode. Pass the non-thinking toggle (for example thinking={"type": "disabled"}) per request to switch to the fast path — check the official Thinking Mode guide for the exact schema on your release.

Why am I getting 429 errors so fast?

V4 Pro's concurrency ceiling is 500 concurrent requests — far below the Flash tier's 2,500 — and long thinking-mode outputs occupy slots for longer. Add a queue, exponential backoff, and context caching to cut both cost and concurrency pressure.

What does the V4 Pro API cost?

DeepSeek's official pricing is $0.435 per 1M cache-miss input tokens, $0.003625 per 1M cache-hit input, and $0.87 per 1M output tokens. DeepSeek has announced a significant price increase coming soon — budget against the live pricing page.

Bottom Line

The DeepSeek V4 Pro API is a three-step setup: issue a key at platform.deepseek.com, point an OpenAI-format client at https://api.deepseek.com with the deepseek-v4-pro model ID (or the /anthropic URL for Anthropic-format stacks), and paste the quickstart above — remembering that thinking mode is on by default, the 500-concurrency ceiling needs a queue, and caching drops input cost by ~99%. It is a flagship-tier API with flagship-tier reasoning, and flagship-tier prices to match. If you are already willing to pay that premium, benchmark GLM 5.2 — free at glm5.app/chat on the same prompts before you lock in your provider.

By the GLM 5 Team. Written August 2026 against DeepSeek's official API documentation (captured 2026-08-13) and Artificial Analysis benchmarks; verify current model IDs, parameters, and pricing in your DeepSeek dashboard before shipping.

Sources

Start Using GLM 5 Today

Try GLM 5 free — reasoning, coding, agents, and image generation in one platform.