Skip to main content
deepseek avatar

DeepSeek V4 Pro API

Open-weight (MIT) thinking model at 1.6T parameters for hard reasoning and competitive-grade coding, with a 1,000,000-token context, tool calling and streaming over an OpenAI-compatible chat endpoint.

Context window
1M tokens
Max output
393.2K tokens
Input
$2.4 / 1M tokens
Output
$4.8 / 1M tokens
Cached input
$0.2 / 1M tokens
Modalities
text → text
Features
reasoningtool callingjson modestreaming

Connect to DeepSeek V4 Pro

DeepSeek V4 Pro is served through an OpenAI-compatible chat completions API. Point any OpenAI SDK or OpenAI-compatible tool at the base URL below with a ModelRunner API key — no polling, the reply comes back in the response (or streams).

base_url
https://queue.modelrunner.run/deepseek/v4
model
deepseek/v4
auth
Authorization: Bearer <MODELRUNNER_API_KEY>get a key
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://queue.modelrunner.run/deepseek/v4",
    api_key=os.environ["MODELRUNNER_API_KEY"],
)

completion = client.chat.completions.create(
    model="deepseek/v4",
    messages=[
      {
        "role": "user",
        "content": "Explain what an API rate limit is in two sentences."
      }
    ],
    reasoning_effort="medium",  # low | medium | high — thinking bills as output tokens
)
print(completion.choices[0].message.content)

# Streaming: add stream=True and iterate the chunks
# for chunk in client.chat.completions.create(..., stream=True):
#     print(chunk.choices[0].delta.content or "", end="")
Works withCline · Continue · Claude Code · LangChain · Vercel AI SDK · LiteLLM · Aider

Cline → Settings → API Configuration (or the CLI line below)

API Provider:  OpenAI Compatible
Base URL:      https://queue.modelrunner.run/deepseek/v4
API Key:       <your ModelRunner API key>
Model ID:      deepseek/v4

# Cline CLI equivalent
cline auth --provider openai --baseurl https://queue.modelrunner.run/deepseek/v4 --modelid deepseek/v4 --apikey <your ModelRunner API key>

Streaming via SSE (stream: true; ends with data: [DONE]) · Non-streaming calls time out at ~290 s — stream long generations · 10 MB request body · Errors use the OpenAI error envelope · Optional metadata object for your own tags, never sent to the model · Many models, one provider entry: base_url https://queue.modelrunner.run/v1 (GET /v1/models lists ids; model field required)

From an MCP client (Claude Desktop, Cursor, Claude Code): connect the ModelRunner MCP server once and its run_model tool runs DeepSeek V4 Pro with a messages input — the reply comes back in the same call.

Machine-readable: OpenAPI schema · llms.txt

Example conversation

A real run of DeepSeek V4 Pro on ModelRunner · charged $0.0125 · 54 in / 2,578 out / 2,327 reasoning tokens

Given an array of n integers, find the length of the longest subsequence such that every two consecutive elements in the subsequence have an absolute difference of exactly 1. State the time and space complexity of your solution, then implement it in Python.

**Time Complexity:** O(n) – We iterate through the array once, performing constant-time hash map operations per element. **Space Complexity:** O(n) – In the worst case, the hash map stores one entry per unique element, which is bounded by n.

```python from typing import List

def longest_subsequence_diff_one(arr: List[int]) -> int: """ Returns the length of the longest subsequence where every two consecutive elements have an absolute difference of exactly 1. """ if not arr: return 0

# length_map[x] = length of longest valid subsequence ending with value x length_map = {} max_len = 0

for x in arr: # We can extend a subsequence that ended with x-1 or x+1 best = max(length_map.get(x - 1, 0), length_map.get(x + 1, 0)) + 1 # Keep the best length for subsequences ending with x length_map[x] = max(length_map.get(x, 0), best) max_len = max(max_len, length_map[x])

return max_len ```

Model Pricing

Pricing

This model is billed per token, at separate rates for what you send and what it produces.

Input tokens
$2.4
per 1M tokens
Cached input tokens
$0.2
per 1M tokens
Output tokens
$4.8
per 1M tokens

If a run reports no token usage, it bills a flat $0.02.

Real run: the example conversation above was charged $0.0125 for 54 input and 2,578 output tokens (of which 2,327 thinking).

Cost estimator

Estimate from the rates above — your bill is the model's reported usage × rate, exact to 6 decimals.

Per request$0.00720
Per day$7.201,000 requests

This model thinks before it answers. Thinking tokens bill at the output rate and are often several times the visible reply — count them in the output figure, or set a lower reasoning effort.

Compare tiers and related models

ModelInput / 1MOutput / 1MContextMax outputFeatures
DeepSeek V4 Prodeepseek/v4$2.4$4.81M393.2Kreasoning, tool calling, json mode
Gemini 3.5 Flashgoogle/gemini-3.5-flash$1.5$91M65.5Kreasoning, tool calling, json mode
Gemini 3.5 Flash-Litegoogle/gemini-3.5-flash-lite$0.3$2.51M65.5Ktool calling, json mode
Gemini 3.7 Flashgoogle/gemini-3.7-flash$0.75$3.751M65.5Kreasoning, tool calling, json mode
GLM-5.2z-ai/glm-5.2$1.4$4.41M131.1Kreasoning, tool calling, json mode
GLM-5.2 Fast Previewz-ai/glm-5.2-fast-preview$2.8$8.81M131.1Kreasoning, tool calling, json mode
Qwen3.8-Maxalibaba/qwen3.8-max$2$61M131.1Kreasoning, tool calling, json mode

Request parameters

The body follows OpenAI’s chat completions shape. Fields below are the ones this model documents; anything else the platform does not interpret is forwarded to the model unchanged, and the model is the authority on what it accepts.

Request parameters of DeepSeek V4 Pro
NameTypeRequiredDescription
messagesarrayyesOpenAI-style conversation history. Each item is an object with a role (system, user, assistant or tool) and content. Text only — this model accepts no image, audio or document parts.
streambooleannoReturn the reply as a Server-Sent Events stream of deltas terminated by data: [DONE]. The chain of thought arrives on the same stream in a reasoning_content delta field. Default: false.
reasoning_effortenumnoHow hard the model thinks before answering. Defaults to high. Lowering it does not cut cost on this endpoint: low and medium behave as high and xhigh behaves as max, so high is the cheapest reachable setting. Thinking tokens bill as output tokens. One of: low, medium, high, xhigh, max. Default: "high".
max_tokensintegernoUpper bound on generated tokens. max_tokens and the thinking budget share one 393,216-token ceiling, so a long chain of thought consumes the room left for the visible answer — allow generous headroom.
toolsarraynoOpenAI-format tool definitions the model may call.
tool_choicenoauto, none, required, or a specific tool.
response_formatobjectnoStructured-output control. Set its type to json_object to force a JSON reply.
stopnoUp to 4 stop sequences.
seedintegernoBest-effort determinism hint.

Response

An OpenAI ChatCompletion object: id, object, created, model, choices[] and usage. Cache hits surface at usage.prompt_tokens_details.cached_tokens; thinking, where the model reports it, at usage.completion_tokens_details.reasoning_tokens — thinking tokens are billed as output tokens. Streaming deltas additionally carry the chain of thought in a reasoning_content field beside content. The id is chatcmpl-<requestId>, and the same request appears in your dashboard.

About DeepSeek V4 Pro

DeepSeek V4 Pro is an open-weight **thinking model** — MIT-licensed, 1.6T total parameters with 49B active per token — built for hard reasoning and code. It reasons before answering, and the brand publishes frontier-tier numbers on the model's own weights repo: **93.5% on LiveCodeBench**, a **3206 Codeforces rating**, **87.5% MMLU-Pro**, **92.6% GSM8K** and **57.9% SimpleQA-Verified**. You send `messages`, you get a chat completion.

Best for

  • Competitive programming: solve a hard algorithm problem with complexity analysis
  • Long-context code review across a whole repository in a single 1M-token prompt
  • Deep multi-step reasoning and planning with a visible chain of thought
  • Tool calling and structured JSON output inside an autonomous agent loop
  • Open-weight MIT model when a closed frontier model is not an option

How it thinks

DeepSeek V4 Pro reasons before it answers. Set reasoning_effort to low, medium, high, xhigh or max (default high) to trade answer quality against latency and cost. Thinking tokens are billed at the output rate and reported as usage.completion_tokens_details.reasoning_tokens.

Notesshow the full description ›

The context window is 1,000,000 tokens, and the brand reports it is built to be worked in: at a million tokens the model needs 27% of the per-token inference FLOPs and 10% of the KV cache of the previous generation, which is what makes long-horizon work practical. One response is capped at **393,216 tokens**, and that ceiling is shared — `max_tokens` and the thinking budget draw from the same pool, so a long chain of thought eats the room left for the visible answer. Repeated prompt prefixes are cached automatically and bill at the reduced cached-input rate.

Thinking effort is set per request with `reasoning_effort`. The documented value set is `low`, `medium`, `high`, `xhigh` and `max`, defaulting to `high`; where a value is accepted, the levels collapse — `low` and `medium` behave exactly like `high`, and `xhigh` behaves like `max` — so there are only two real settings and **no cheap low-effort tier** either way, whether or not the lower values are accepted on this endpoint. Thinking tokens bill as output tokens, so effort and prompt size are both real cost levers.

## Choose another model when - Your input includes images, audio, video or PDFs — this model takes text only - You want the cheapest possible tokens for bulk classification, tagging or translation — every request here thinks at `high` or above, and thinking bills as output - A single reply plus its chain of thought has to exceed 393,216 tokens

## Tips - Budget `max_tokens` for the chain of thought as well as the answer — on a hard problem the thinking is the larger share - `usage.completion_tokens_details.reasoning_tokens` in the response reports how much of the reply went to thinking

Behaviour & limits

Context window
1M tokens (input + output)
Max output
393.2K tokens per reply — thinking counts against this budget
Structured calls
OpenAI-format tools + tool_choice · response_format JSON mode
Transport
OpenAI-compatible chat completions · SSE streaming · ~290 s non-stream ceiling · 10 MB body

FAQ

How do I connect to DeepSeek V4 Pro through the API?

DeepSeek V4 Pro is served by an OpenAI-compatible chat completions endpoint. Point any OpenAI SDK or OpenAI-compatible tool at base_url https://queue.modelrunner.run/deepseek/v4 with a ModelRunner API key (Authorization: Bearer <key>) and model deepseek/v4; the SDK appends /chat/completions itself. The call is synchronous — the reply comes back in the response body, or streams as Server-Sent Events with "stream": true. Do not submit it to the asynchronous queue path, which returns HTTP 400 for this model.

How much does DeepSeek V4 Pro cost?

DeepSeek V4 Pro is billed per token from the usage the model reports: $2.4 per 1M input tokens, $0.2 per 1M cached input tokens, $4.8 per 1M output tokens. Thinking (reasoning) tokens bill at the output rate. There is no per-request minimum — a short call bills a fraction of a cent, exact to six decimals.

What is DeepSeek V4 Pro's context window?

DeepSeek V4 Pro supports a 1M-token context window and up to 393.2K output tokens per reply — thinking tokens count against the output budget, so leave headroom in max_tokens.

Can I use DeepSeek V4 Pro in GitHub Copilot or another tool that requires a /models endpoint?

Yes. Custom-provider flows that probe GET {base_url}/models before first use (GitHub Copilot's BYOK flow does) work with either base URL: https://queue.modelrunner.run/deepseek/v4 self-describes at https://queue.modelrunner.run/deepseek/v4/models, and the platform base https://queue.modelrunner.run/v1 covers every public chat model with one provider entry — GET /v1/models lists the ids and the request's model field selects deepseek/v4.

Does DeepSeek V4 Pro support streaming?

Yes. Set "stream": true and the reply arrives as Server-Sent Events (data: frames ending with data: [DONE]); stream_options: {"include_usage": true} adds a final usage frame. Non-streaming calls are cut off at about 290 seconds, so stream long generations.

Does DeepSeek V4 Pro support tool calling or JSON mode?

DeepSeek V4 Pro supports function calling via an OpenAI-format tools array with tool_choice and JSON mode via response_format {"type": "json_object"}. Both are passed through to the model in the standard OpenAI chat completions shape, so existing client code works unchanged.

What happens if my ModelRunner balance runs out while calling DeepSeek V4 Pro?

The request is refused with HTTP 429 and an OpenAI-style error whose code is insufficient_quota — the convention OpenAI SDKs already understand — and nothing is charged. Top up in the dashboard and retry. (Disconnecting from a stream after output has started is not a refund — the platform finishes the upstream call and bills its exact usage.)