> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt.
> For full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# DeepSeek V4 Flash

> DeepSeek V4 Flash is an open-source model served on Sarvam infrastructure. 1M token context window with tool calling and visible reasoning.

DeepSeek V4 Flash is an [open-source model](/api/getting-started/models/open-source) served
by Sarvam in **beta**, and is **not tuned for Indian languages**. Beta access is granted per
API key — [contact us](/api/getting-started/help) to request whitelisting. For Indian
language workloads use [Sarvam-105B](/api/getting-started/models/sarvam-105b) instead.

A general-purpose open-source reasoning model. Its distinguishing feature on Sarvam is a
**1M token context window** — the largest of the open-source models Sarvam serves — paired
with visible chain-of-thought and tool calling, at a lower cost per token than
[GLM-5.2](/api/getting-started/models/open-source/glm-5-2).

## At a Glance

|                  |                                                                                                                                                                                                                                                                   |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Model ID**     | `deepseekv4-flash`                                                                                                                                                                                                                                                |
| **What it does** | General-purpose chat LLM; very long context, tool calling, and visible reasoning                                                                                                                                                                                  |
| **Languages**    | Not tuned for Indian languages by Sarvam                                                                                                                                                                                                                          |
| **APIs**         | [Open-Source Models API Reference](/api-reference/open-source/chat-completions) (`POST /v2/chat/completions`, OpenAI-compatible, streaming supported) — also see [using an open-source model](/api/getting-started/models/open-source#using-an-open-source-model) |
| **Input limits** | 1,048,576-token context window; 10 MB request cap — [all limits](#limits-and-errors)                                                                                                                                                                              |
| **Benchmarks**   | None published by Sarvam                                                                                                                                                                                                                                          |
| **Pricing**      | **₹19.8 / ₹0.63 / ₹59.4 per 1M tokens** — Chat completion (beta). Input ₹19.8 · Cached input ₹0.63 · Output ₹59.4 — per 1M tokens; reasoning billed as output ([Pricing](/api/getting-started/pricing))                                                           |
| **Best for**     | Long-document analysis and agentic workflows that need both a huge context window and a lower cost per token                                                                                                                                                      |
| **Not for**      | Indian language workloads — use [Sarvam-105B](/api/getting-started/models/sarvam-105b); image input — use [Gemma 4 31B](/api/getting-started/models/open-source/gemma-4-31b)                                                                                      |

## Why you might use it

#### 1M token context

A 1,048,576 token context window — twice GLM-5.2's — for entire codebases, long
transcripts, or large document sets in a single request.

#### Tool calling

Supports the OpenAI-compatible `tools` and `tool_choice` parameters, so it works with
agentic loops and function-calling frameworks.

## Model Specifications

#### Key Considerations

* Model ID: `deepseekv4-flash`
* Context window: 1,048,576 tokens (1M)
* Tool calling: supported
* Image input: **not supported** — text only
* Reasoning: **always on** — the chain-of-thought arrives in a separate `reasoning_content` field and counts against `max_tokens`; disable via `extra_body` (see below)
* Maximum request size: 10 MB
* Temperature range: 0 to 2 (unset uses the model's own default)
* Top-p range: greater than 0, up to 1
* Supports streaming and non-streaming responses
* OpenAI-compatible chat completions format

## DeepSeek V4 Flash vs GLM-5.2

| Feature                     | DeepSeek V4 Flash                            | GLM-5.2                                                  |
| --------------------------- | -------------------------------------------- | -------------------------------------------------------- |
| **Context window**          | 1,048,576                                    | 524,288                                                  |
| **Tool calling**            | ✅                                            | ✅                                                        |
| **Image input**             | ❌                                            | ❌                                                        |
| **Reasoning**               | ✅ always on                                  | ✅ always on                                              |
| **Pricing (per 1M tokens)** | **₹19.8 / ₹0.63 / ₹59.4**                    | ₹128.1 / ₹23.79 / ₹402.6                                 |
| **Best for**                | Widest context at the lowest cost of the two | Long-context tasks where you already standardised on GLM |

Pick DeepSeek V4 Flash when you want the largest context window Sarvam serves alongside
reasoning and tool calling, at a lower per-token cost than GLM-5.2. For anything touching
Indian languages, a Sarvam model will still serve you better.

## Key Capabilities

#### Basic Chat Completion

A single-turn request. Only the `model` field differs from a Sarvam chat completion call.

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.open_source_models.chat_completions_v2(
    model="deepseekv4-flash",
    messages=[
        {"role": "user", "content": "Explain the difference between a B-tree and a B+ tree index."}
    ],
    temperature=0.2,
    top_p=1,
    max_tokens=2000,
)

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

#### JavaScript

```javascript
import { SarvamAIClient } from "sarvamai";

const client = new SarvamAIClient({
    apiSubscriptionKey: "YOUR_SARVAM_API_KEY",
});

async function main() {
    const response = await client.openSourceModels.chatCompletionsV2({
        model: "deepseekv4-flash",
        messages: [
            {
                role: "user",
                content: "Explain the difference between a B-tree and a B+ tree index.",
            },
        ],
        temperature: 0.2,
        top_p: 1,
        max_tokens: 2000,
    });

    console.log(response.choices[0].message.content);
}

main();
```

#### cURL

```bash
curl -X POST https://api.sarvam.ai/v2/chat/completions \
  -H "api-subscription-key: $SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "Explain the difference between a B-tree and a B+ tree index."}
    ],
    "model": "deepseekv4-flash",
    "temperature": 0.2,
    "top_p": 1,
    "max_tokens": 2000
  }'
```

The answer is in `message.content`. The model's chain-of-thought arrives separately
in `message.reasoning_content` — see [Reasoning](#reasoning) below for how to budget
for it or turn it off.

#### Long-Context Analysis

DeepSeek V4 Flash's main advantage. Pass a large document directly in the prompt
instead of chunking it — up to 1M tokens of context, minus whatever you reserve for
`max_tokens`.

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

with open("annual_report.txt", encoding="utf-8") as f:
    document = f.read()

response = client.open_source_models.chat_completions_v2(
    model="deepseekv4-flash",
    messages=[
        {"role": "system", "content": "You are a financial analyst. Answer only from the document provided."},
        {"role": "user", "content": f"{document}\n\nList every material risk disclosed, with the page or section it appears in."},
    ],
    temperature=0.1,
    max_tokens=4000,
)

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

#### cURL

```bash
# Build the payload with a file so large documents do not hit shell argument limits.
python3 - <<'PY' > payload.json
import json
document = open("annual_report.txt", encoding="utf-8").read()
json.dump({
    "model": "deepseekv4-flash",
    "messages": [
        {"role": "system", "content": "You are a financial analyst. Answer only from the document provided."},
        {"role": "user", "content": document + "\n\nList every material risk disclosed."},
    ],
    "temperature": 0.1,
    "max_tokens": 4000,
}, open("payload.json", "w"))
PY

curl -X POST https://api.sarvam.ai/v2/chat/completions \
  -H "api-subscription-key: $SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @payload.json
```

Requests are capped at **10 MB** regardless of the context window. A document that
fits in 1M tokens can still exceed the byte cap and return `413 Payload Too Large`.

#### Tool Calling

DeepSeek V4 Flash supports OpenAI-compatible function calling.

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.open_source_models.chat_completions_v2(
    model="deepseekv4-flash",
    messages=[
        {"role": "user", "content": "What is the weather in Bengaluru right now?"}
    ],
    tools=[
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "Get the current weather for a city.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {"type": "string", "description": "City name"}
                    },
                    "required": ["city"],
                },
            },
        }
    ],
    tool_choice="auto",
    max_tokens=1000,
)

print(response.choices[0].message.tool_calls)
```

#### cURL

```bash
curl -X POST https://api.sarvam.ai/v2/chat/completions \
  -H "api-subscription-key: $SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseekv4-flash",
    "messages": [
      {"role": "user", "content": "What is the weather in Bengaluru right now?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get the current weather for a city.",
          "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"]
          }
        }
      }
    ],
    "tool_choice": "auto",
    "max_tokens": 1000
  }'
```

#### Streaming

Set `stream` to `true` to receive tokens as server-sent events. Because DeepSeek V4
Flash reasons before answering, the stream delivers `delta.reasoning_content` chunks
first and `delta.content` chunks after — read both, or the wait before the first
`content` chunk looks like a stall.

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

stream = client.open_source_models.chat_completions_v2(
    model="deepseekv4-flash",
    messages=[
        {"role": "user", "content": "Write a short note on database normalisation."}
    ],
    max_tokens=1000,
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta
    reasoning = getattr(delta, "reasoning_content", None)
    if reasoning:
        pass  # the chain-of-thought — show it, log it, or skip it
    if delta.content:
        print(delta.content, end="", flush=True)
```

#### cURL

```bash
curl -N -X POST https://api.sarvam.ai/v2/chat/completions \
  -H "api-subscription-key: $SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseekv4-flash",
    "messages": [
      {"role": "user", "content": "Write a short note on database normalisation."}
    ],
    "max_tokens": 1000,
    "stream": true
  }'
```

## Reasoning

DeepSeek V4 Flash thinks before every answer — **by default**, not only when
`reasoning_effort` is set. The chain-of-thought arrives in a separate `reasoning_content`
field on the message (`delta.reasoning_content` when streaming); `content` carries only
the final answer. Two practical consequences:

* **Reasoning tokens are billed and count against `max_tokens`.** A small budget can be
  consumed entirely by reasoning, returning `content: null` with
  `finish_reason: "length"`. If your answers come back empty, raise `max_tokens` or
  turn thinking off.
* **Turn thinking off when you set `response_format`.** With reasoning active, a
  JSON-constrained request returns `content: null` instead of JSON.

The off-switch goes through `extra_body`:

```json
{
  "model": "deepseekv4-flash",
  "messages": [{ "role": "user", "content": "..." }],
  "extra_body": {
    "chat_template_kwargs": { "enable_thinking": false }
  }
}
```

With thinking off, responses are faster, the whole `max_tokens` budget goes to the answer,
and Structured Outputs work reliably.

## Parameters

DeepSeek V4 Flash accepts the standard OpenAI-compatible parameter set — `temperature`,
`top_p`, `max_tokens`, `stream`, `stop`, `n`, `seed`, `frequency_penalty`,
`presence_penalty`, `reasoning_effort`, `response_format` (Structured Outputs), `tools`,
`tool_choice`, and `extra_body`.
See the [full parameter table](/api/getting-started/models/open-source#supported-parameters)
for types, defaults, and ranges.

Model-specific exceptions:

* **`image_url` content parts are rejected** (`400`) — DeepSeek V4 Flash is text only.
* **`response_format` requires thinking off** — see [Reasoning](#reasoning) above.
* **`seed` is not currently reproducible** on this model — identical seeds return
  different completions. Use `temperature: 0` where you need stability.

## Limits and errors

Common errors for every model on `/v2/chat/completions` are documented on the
[Open-Source Models overview](/api/getting-started/models/open-source#errors).
DeepSeek V4 Flash-specific cases:

| Condition                                                              | Status | Code                         | What it means                                                                                                        |
| ---------------------------------------------------------------------- | ------ | ---------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| API key lacks beta access                                              | `400`  | `invalid_request_error`      | Request whitelisting — see [Beta APIs](/api-reference/beta-apis).                                                    |
| Missing or invalid API key                                             | `403`  | `invalid_api_key_error`      | Check the `api-subscription-key` header.                                                                             |
| No credits remaining                                                   | `402`  | `insufficient_quota_error`   | Top up on the [dashboard](https://dashboard.sarvam.ai).                                                              |
| Unknown or unavailable model id                                        | `404`  | `not_found_error`            | Confirm the id with [`GET /v2/models`](/api-reference/open-source/models).                                           |
| Message contains an image part                                         | `400`  | `invalid_request_error`      | DeepSeek V4 Flash is text only. Use [`gemma4`](/api/getting-started/models/open-source/gemma-4-31b) for image input. |
| `max_tokens` above 1,048,576                                           | `400`  | `invalid_request_error`      | `max_tokens` cannot exceed the context window.                                                                       |
| Estimated prompt tokens + `max_tokens` above 1,048,576                 | `422`  | `unprocessable_entity_error` | Shorten the prompt or lower `max_tokens`.                                                                            |
| Request body above the model's size cap                                | `413`  | `invalid_request_error`      | The byte cap is independent of the token window.                                                                     |
| `tool_choice` naming a function with no `tools`                        | `422`  | `unprocessable_entity_error` | Provide the `tools` array alongside `tool_choice`.                                                                   |
| Invalid tool schema (`$ref`, recursion, size)                          | `400`  | `invalid_request_error`      | See [Tool schemas](/api/getting-started/models/open-source#tool-schemas).                                            |
| Rate limit exceeded                                                    | `429`  | `rate_limit_exceeded_error`  | Back off and retry; see [Rate Limits](/api/getting-started/ratelimits).                                              |
| Model overloaded after retries                                         | `503`  | `model_overloaded`           | Retry later.                                                                                                         |
| `content: null` with `finish_reason: "length"`                         | `200`  | —                            | Reasoning consumed the whole `max_tokens` budget — raise it, or turn thinking off. See [Reasoning](#reasoning).      |
| `content: null` with `finish_reason: "stop"` and `response_format` set | `200`  | —                            | Thinking + Structured Outputs conflict — turn thinking off. See [Reasoning](#reasoning).                             |

## Support

Sarvam supports the serving layer — auth, billing, rate limits, availability. Sarvam does
not tune or evaluate this model, so its output quality, reasoning, and language coverage
are properties of the model itself. See
[Open-Source Models](/api/getting-started/models/open-source) for the full support
boundary, and [Talk to us](/api/getting-started/help) for serving issues.