> This page is for Model APIs.

> Sarvam Voice Agents (Samvaad) is a voice AI agent platform for Indian languages: build, test and deploy AI calling agents on your own phone numbers, from ₹3 a minute. Start here: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> 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 a section index, append `/llms.txt` to any section URL (for example https://docs.sarvam.ai/voice-agents/llms.txt).
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# DeepSeek V4.1 Flash 1017

> DeepSeek V4.1 Flash 1017 is a general-purpose open-weight reasoning model with text and image input and text output, a 1,048,576-token context window, and tool calling.

DeepSeek V4.1 Flash 1017 is a general-purpose [open-weight model](/api/token-factory/models) served on Sarvam infrastructure. It
accepts **text and image** input and has a **1,048,576-token context window**.

> **Note**
>
> DeepSeek V4.1 Flash 1017 is in **beta**. Its behaviour, limits, and availability may change before general availability. Beta models must be enabled for your API key; without access, requests return `400 invalid_request_error` ("This model is currently in beta"). [Contact us](/api/getting-started/help) to request access. See [Beta models](/api-reference/beta-apis).

## At a glance

|                    |                                                                                                                                    |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
| **Model ID**       | `deepseekv4.1-flash-1017`                                                                                                          |
| **Best for**       | Long-document analysis and agentic workflows                                                                                       |
| **Context window** | 1,048,576 tokens                                                                                                                   |
| **Input → output** | Text + image (inline only) → text                                                                                                  |
| **Reasoning**      | **`low`**, **`high`** (default when omitted), or **`max`**; can be turned off. See [Reasoning](#reasoning)                         |
| **Tool calling**   | Supported, including `tool_choice: "required"`                                                                                     |
| **APIs**           | [`POST /v2/chat/completions`](/api-reference/chat/chat-completions-v2) and [`POST /v2/responses`](/api-reference/responses/create) |
| **Pricing**        | ₹25 input · ₹0.5 cached input · ₹105 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.

#### Image input

Send images inline as base64 data URIs alongside text.

#### 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.

> **Tip**
>
> Moving from [OpenRouter](/api/token-factory/migrations/from-openrouter/overview), [Fireworks AI](/api/token-factory/migrations/from-fireworks/overview), or [Together AI](/api/token-factory/migrations/from-together/overview)? The migration guides map model IDs and request fields to Sarvam.

## Quickstart

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.chat.completions_v2(
    model="deepseekv4.1-flash-1017",
    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.1-flash-1017",
        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.1-flash-1017",
    "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
  }'
```

## Supported parameters

`model: "deepseekv4.1-flash-1017"` on [Chat Completion V2](/api-reference/chat/chat-completions-v2)
and [Responses](/api-reference/responses/create). Full request/response schemas live on
those API reference pages; this table covers what's actually accepted for this model.

| Parameter                                             |                               Chat Completion V2                               |                                               Responses                                               |
| ----------------------------------------------------- | :----------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------: |
| Streaming (`stream`)                                  |                                                                                |                                                                                                       |
| Tool calling (`tools`, `tool_choice`)                 |                                                                                |                                                                                                       |
| `parallel_tool_calls: false` enforced                 |                                                                                |                                                                                                       |
| Structured output (`response_format` / `text.format`) |                                                                                |                                                                                                       |
| Log probabilities (`logprobs`, `top_logprobs`)        |                                                                                |  send `top_logprobs` with `include: ["message.output_text.logprobs"]`; `logprobs: true` returns `400` |
| Multiple choices (`n` > 1)                            |                           requires `temperature` > `0`                         |                                                  `400`                                                |
| Reasoning control                                     | `reasoning_effort`: `low`, `high` (default), or `max`, or an integer `1`–`100` |                                    `reasoning.effort`: same values                                    |
| Turn reasoning off                                    |                            `reasoning_effort: "none"`                          |                                       `reasoning.effort: "none"`                                      |

`400` is `invalid_request_error`.

## Reasoning

DeepSeek V4.1 Flash 1017 has three reasoning modes, `low`, `high`, and `max`, and accepts all
three directly on both APIs. It reasons at `high` when the field is omitted. `minimal` is
served as `low`, and `medium` and `xhigh` are served as `high`.

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

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

Read the reasoning trace from `choices[].message.reasoning_content` on chat, or from the
reasoning item's `content[0].text` in `output` on Responses (`summary` is filled only when you
set `reasoning.summary`). Reasoning tokens are billed as output tokens either way, and count
against `max_tokens` on chat or `max_output_tokens` on Responses. Neither has a small
default, so set them explicitly.

To turn reasoning off, set `reasoning_effort: "none"` on chat or `reasoning.effort: "none"` on
Responses. On chat, `thinking: {"type": "disabled"}` and
`chat_template_kwargs: {"enable_thinking": false}` (through `extra_body` in the SDKs) also work.
Integer effort values from `1` to `100` are accepted as well.

## Image input

Send images **inline as base64 data URIs** only. Remote image URLs are rejected:

```python
import base64

with open("chart.png", "rb") as f:
    data_uri = "data:image/png;base64," + base64.b64encode(f.read()).decode()

response = client.chat.completions_v2(
    model="deepseekv4.1-flash-1017",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Summarise this chart."},
                {"type": "image_url", "image_url": {"url": data_uri}},
            ],
        }
    ],
    max_tokens=2000,
)
```

## Known limitations

* Reasoning and the final answer share the **`max_tokens`** / **`max_output_tokens`**
  budget. Raise the cap, or turn thinking off with `reasoning_effort: "none"`, when needed.

## Limits and errors

| Area           | Limit or condition                                | API response                                               | Recommended action                                                        |
| -------------- | ------------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------- |
| Context        | Prompt tokens plus `max_tokens` exceed 1,048,576  | `400 invalid_request_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 MiB (10,485,760 bytes)    | `413 invalid_request_error`, with the limit in the message | Reduce the request body; base64 images count toward the limit.            |
| Image input    | Image sent by URL instead of inline base64        | `400 invalid_request_error`                                | Send the image as a base64 data URI.                                      |
| Modality       | Request includes audio or video input             | `400 invalid_request_error`                                | Send text or inline image input.                                          |
| Reasoning      | Reasoning consumes the full `max_tokens` budget   | `200` with `content: null` and `finish_reason: "length"`   | Raise `max_tokens` or set `reasoning_effort: "none"`.                     |
| Tools          | A named `tool_choice` is provided without `tools` | `400 invalid_request_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.                                  |
| 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://indus.sarvam.ai/billing?ref=docs). |
| 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.                                                              |