> 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 a general-purpose open-weight reasoning model with text input and output, a 1,048,576-token context window, and tool calling.

DeepSeek V4 Flash is a general-purpose [open-weight model](/api/getting-started/models/openweight) served on Sarvam infrastructure. It
supports text input and output with a **1,048,576-token context window**.

DeepSeek V4 Flash is available in **beta**. Access is granted per API key —
[contact us](/api/getting-started/help) to request access.

## At a glance

|                    |                                                                                                                                        |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| **Model ID**       | `deepseekv4-flash`                                                                                                                     |
| **Best for**       | Long-document analysis and agentic workflows                                                                                           |
| **Context window** | 1,048,576 tokens                                                                                                                       |
| **Input → output** | Text → text                                                                                                                            |
| **Reasoning**      | **`low`**, **`high`**, or **`max`** (default when omitted) — see [Reasoning](#reasoning)                                               |
| **Tool calling**   | Supported                                                                                                                              |
| **APIs**           | [`POST /v2/chat/completions`](/api-reference/chat/chat-completions-v2) and [`POST /v2/responses`](/api-reference/responses/create)     |
| **Pricing**        | ₹19.8 input · ₹0.63 cached input · ₹59.4 output per 1M tokens; reasoning is billed as output ([Pricing](/api/getting-started/pricing)) |

## Key capabilities

#### Long context

Process up to 1,048,576 tokens across the prompt, reasoning, and generated output.

#### Reasoning

Receive reasoning in `reasoning_content` separately from the final answer in `content`.

#### Tool calling

Use OpenAI-compatible `tools` and `tool_choice` for agentic workflows.

#### Streaming

Receive reasoning and final-answer deltas as server-sent events.

## Quickstart

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.chat.completions_v2(
    model="deepseekv4-flash",
    messages=[
        {
            "role": "user",
            "content": "Explain the difference between a B-tree and a B+ tree index.",
        }
    ],
    temperature=1,
    top_p=0.95,
    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.chat.completionsV2({
        model: "deepseekv4-flash",
        messages: [
            {
                role: "user",
                content: "Explain the difference between a B-tree and a B+ tree index.",
            },
        ],
        temperature: 1,
        top_p: 0.95,
        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 '{
    "model": "deepseekv4-flash",
    "messages": [
      {
        "role": "user",
        "content": "Explain the difference between a B-tree and a B+ tree index."
      }
    ],
    "temperature": 1,
    "top_p": 0.95,
    "max_tokens": 2000
  }'
```

## API reference

Call [`POST /v2/chat/completions`](/api-reference/chat/chat-completions-v2) or
[`POST /v2/responses`](/api-reference/responses/create) with `model: "deepseekv4-flash"`.
Request fields are defined in those API references — not duplicated on this model page.

## Reasoning

DeepSeek V4 Flash has three reasoning modes — `low`, `high`, and `max` — and accepts all
three directly on both APIs:

| Route                                                         | Field              | Accepted values                                                    |
| ------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------ |
| [Chat Completion V2](/api-reference/chat/chat-completions-v2) | `reasoning_effort` | `"low"`, `"high"`, or `"max"`; omitting the field also gives `max` |
| [Responses](/api-reference/responses/create)                  | `reasoning.effort` | `"low"`, `"high"`, or `"max"`; omitting the field also gives `max` |

This is different from GLM-5.3, where the Responses API rejects the literal string
`"max"` — DeepSeek V4 Flash has no such restriction.

Read the reasoning trace from `choices[].message.reasoning_content` on chat, or from the
reasoning item's `summary[0].text` in `output` on Responses when one is returned.
Reasoning tokens are billed as output tokens either way, and count against `max_tokens`
on chat (defaults to `2048` when omitted) or `max_output_tokens` on Responses (no
default — omitting it means unbounded generation).

To turn reasoning off on chat, set `extra_body.chat_template_kwargs.enable_thinking` to
`false`.

## Known limitations

* Reasoning and the final answer share the **`max_tokens`** / **`max_output_tokens`**
  budget. Raise the cap or disable thinking via `extra_body.chat_template_kwargs.enable_thinking: false` when needed.
* **Structured output with reasoning enabled** can return `content: null` — disable thinking or raise the token cap.

## Limits and errors

| Area              | Limit or condition                                   | API response                                             | Recommended action                                                          |
| ----------------- | ---------------------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------------------------- |
| Context           | Prompt tokens plus `max_tokens` exceed 1,048,576     | `422 unprocessable_entity_error`                         | Shorten the prompt or reduce `max_tokens`.                                  |
| Output            | `max_tokens` exceeds 1,048,576                       | `400 invalid_request_error`                              | Set `max_tokens` within the context window.                                 |
| Request size      | Request body exceeds 10 MB                           | `413 invalid_request_error`                              | Reduce the request body; the byte limit is independent of the token window. |
| Modality          | Request includes image input                         | `400 invalid_request_error`                              | Send text input only.                                                       |
| Reasoning         | Reasoning consumes the full `max_tokens` budget      | `200` with `content: null` and `finish_reason: "length"` | Raise `max_tokens` or disable reasoning with `extra_body`.                  |
| Structured output | `response_format` is used while reasoning is enabled | `200` with `content: null`                               | Disable reasoning with `extra_body`.                                        |
| Tools             | A named `tool_choice` is provided without `tools`    | `422 unprocessable_entity_error`                         | Include the matching function in `tools`.                                   |
| Authentication    | API key is missing or invalid                        | `403 invalid_api_key_error`                              | Check the `api-subscription-key` header.                                    |
| Access            | API key does not have beta access                    | `400 invalid_request_error`                              | [Request beta access](/api-reference/beta-apis).                            |
| Model             | Model ID is unknown or unavailable                   | `404 not_found_error`                                    | Confirm the ID with [`GET /v2/models`](/api-reference/chat/models-v2).      |
| Quota             | No credits remain                                    | `402 insufficient_quota_error`                           | Add credits in the [dashboard](https://dashboard.sarvam.ai).                |
| Rate limit        | Request or concurrency limit is exceeded             | `429 rate_limit_exceeded_error`                          | Back off and retry.                                                         |
| Availability      | Model remains overloaded after retries               | `503 model_overloaded`                                   | Retry later.                                                                |