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

# Open-Weight Models

> Open-weight models served on Sarvam infrastructure through the OpenAI-compatible chat completions API, using your existing Sarvam API key and credits.

Run leading **open-weight models** on Sarvam infrastructure through the same OpenAI-compatible
`/v2` API, with your existing Sarvam API key and credits. Switching models is a one-line
change to the `model` field.

> **Note**
>
> GLM-5.3, GLM-5.3 Flash, and Gemma 4 31B are generally available. DeepSeek V4.1 Flash 1017, DeepSeek V4 Pro, Kimi K3, MiMo V2.6 Flash, and MiMo V2.6 Pro
> are in [beta](/api-reference/beta-apis).

## Choose a model

Pick a use case, or filter by status and input type. Click a model ID to copy it.

Prices are in ₹ per 1M tokens; reasoning is billed as output. See [Pricing](/api/getting-started/pricing).
Each model's reasoning default, and how to turn it off, is under [Reasoning](#reasoning).

Every model supports tool calling, streaming, and structured output (`response_format`).
Support for log probabilities, multiple choices (`n` > 1), and other parameters varies by
model — see each model's own Supported Parameters table, or
[V2 feature support](/api/token-factory/chat-completions#v2-feature-support)
for the full matrix.

#### All models as a table

| Model                                                                                                           | Context | Input                     | ₹ per 1M in / out |
| --------------------------------------------------------------------------------------------------------------- | ------: | ------------------------- | ----------------: |
| [GLM-5.3](/api/token-factory/models/glm-5-3) `glm5.3`                                                           |      1M | Text                      |         126 / 390 |
| [GLM-5.3 Flash](/api/token-factory/models/glm-5-3-flash) `glm5.3-flash`                                         |      1M | Text, image               |         13.5 / 45 |
| [Gemma 4 31B](/api/token-factory/models/gemma-4-31b) `gemma4`                                                   |    256K | Text, image               |           35 / 90 |
| [DeepSeek V4.1 Flash 1017](/api/token-factory/models/deepseek-v4.1-flash-1017) (beta) `deepseekv4.1-flash-1017` |      1M | Text, image               |          25 / 105 |
| [DeepSeek V4 Pro](/api/token-factory/models/deepseek-v4-pro) (beta) `deepseekv4-pro`                            |      1M | Text                      |         115 / 350 |
| [Kimi K3](/api/token-factory/models/kimi-k3) (beta) `kimi-k3`                                                   |      1M | Text, image, video        |       270 / 1,350 |
| [MiMo V2.6 Flash](/api/token-factory/models/mimo-v2.6-flash) (beta) `mimo-v2.6-flash`                           |      1M | Text, image, audio, video |         12.5 / 25 |
| [MiMo V2.6 Pro](/api/token-factory/models/mimo-v2.6-pro) (beta) `mimo-v2.6-pro`                                 |      1M | Text, image, audio, video |           40 / 80 |

* **Coding and agents:** `glm5.3`, the strongest reasoning
* **Lowest cost:** `mimo-v2.6-flash`, the lowest per-token price
* **Fastest answers, with image input:** `gemma4`, which skips reasoning by default
* **Reasoning on images:** `glm5.3-flash` or `kimi-k3`

## Quickstart

#### Get an API key

Create an API key in the [dashboard](https://indus.sarvam.ai/key-management?ref=docs).

#### Set your key

```bash
export SARVAM_API_KEY="your-api-key"
```

#### Make your first call

Open-weight models are served on `POST /v2/chat/completions`. Pick your SDK:

#### Python (Sarvam SDK)

```python
import os
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key=os.environ["SARVAM_API_KEY"])

response = client.chat.completions_v2(
    model="glm5.3",  # or "gemma4", "deepseekv4.1-flash-1017", "kimi-k3", ...
    messages=[
        {"role": "user", "content": "Summarise the causes of the 2008 financial crisis."}
    ],
    max_tokens=1000,
)

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

#### Python (OpenAI SDK)

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.sarvam.ai/v2",
    api_key=os.environ["SARVAM_API_KEY"],
)

response = client.chat.completions.create(
    model="glm5.3",  # or "gemma4", "deepseekv4.1-flash-1017", "kimi-k3", ...
    messages=[
        {"role": "user", "content": "Summarise the causes of the 2008 financial crisis."}
    ],
    max_tokens=1000,
)

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

#### JavaScript

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

const client = new SarvamAIClient({
    apiSubscriptionKey: process.env.SARVAM_API_KEY,
});

const response = await client.chat.completionsV2({
    model: "glm5.3", // or "gemma4", "deepseekv4.1-flash-1017", "kimi-k3", ...
    messages: [
        { role: "user", content: "Summarise the causes of the 2008 financial crisis." },
    ],
    max_tokens: 1000,
});

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

#### 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": "glm5.3",
    "messages": [
      {"role": "user", "content": "Summarise the causes of the 2008 financial crisis."}
    ],
    "max_tokens": 1000
  }'
```

> **Info**
>
> **Already use the OpenAI SDK?** Point `base_url` at `https://api.sarvam.ai/v2` and pass your
> Sarvam key as `api_key`. The endpoint also accepts `Authorization: Bearer <key>`. Native
> Sarvam clients use the `api-subscription-key` header. See [Authentication](/api-reference/authentication).

## Common patterns

#### Streaming

Set `stream=True` to receive server-sent events. Reasoning models stream
`reasoning_content` deltas first, then the final `content`.

```python
stream = client.chat.completions.create(
    model="glm5.3",
    messages=[{"role": "user", "content": "What is 17 * 23?"}],
    reasoning_effort="low",
    max_tokens=1000,
    stream=True,
)

for chunk in stream:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    if getattr(delta, "reasoning_content", None):
        print(delta.reasoning_content, end="", flush=True)  # thinking
    if delta.content:
        print(delta.content, end="", flush=True)  # answer
```

#### Reasoning

Control thinking depth with `reasoning_effort`. Accepted values and the default vary
by model — see the [Reasoning](#reasoning) table below. The thinking is returned
separately in `reasoning_content`.

```python
response = client.chat.completions.create(
    model="glm5.3-flash",
    messages=[{"role": "user", "content": "Is 391 prime? Explain briefly."}],
    reasoning_effort="low",
    max_tokens=1500,
)

message = response.choices[0].message
print("Thinking:", message.reasoning_content)
print("Answer:", message.content)
```

#### Tool calling

Use OpenAI-style `tools`. When the model decides to call a function, the response has
`finish_reason: "tool_calls"`.

```python
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]

response = client.chat.completions.create(
    model="glm5.3-flash",
    messages=[{"role": "user", "content": "What's the weather in Pune?"}],
    tools=tools,
    max_tokens=1000,
)

call = response.choices[0].message.tool_calls[0]
print(call.function.name, call.function.arguments)
# get_weather {"city":"Pune"}
```

#### Images (Gemma)

`gemma4` accepts images as **base64 data URIs**. Remote `http(s)` URLs are rejected.

```python
import base64

with open("chart.png", "rb") as f:
    encoded = base64.b64encode(f.read()).decode()

response = client.chat.completions.create(
    model="gemma4",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What trend does this chart show?"},
            {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{encoded}"}},
        ],
    }],
    max_tokens=500,
)

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

## Reasoning

Most models think before answering; Gemma 4 does only when you set an effort. Defaults, and whether thinking can be turned off, differ by
model:

| Model                              | Default effort                                                         | Turn thinking off                                                                                                                                           |
| ---------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `glm5.3`                           | `max`                                                                  | Not supported                                                                                                                                               |
| `glm5.3-flash`                     | `high`                                                                 | Not supported                                                                                                                                               |
| `gemma4`                           | Off; turn it on with `reasoning_effort` (`low` or `high` on Responses) | Off by default                                                                                                                                              |
| `deepseekv4.1-flash-1017`          | `high`                                                                 | `reasoning_effort: "none"`                                                                                                                                  |
| `deepseekv4-pro`                   | `high`                                                                 | `reasoning_effort: "none"` or `thinking: {"type": "disabled"}`                                                                                              |
| `kimi-k3`                          | `max`                                                                  | Not supported; thinking is always on                                                                                                                        |
| `mimo-v2.6-flash`, `mimo-v2.6-pro` | On                                                                     | `reasoning_effort: "none"`, `thinking: {"type": "disabled"}`, or `chat_template_kwargs.enable_thinking: false`. Other effort values only switch thinking on |

Send `thinking` and `chat_template_kwargs` through `extra_body` in the SDKs. Accepted effort values
are listed on each [model page](/api/token-factory/models).

> **Warning**
>
> On the Responses API, do **not** send the string `"max"` to `glm5.3` or `glm5.3-flash`. It returns `400`.
> Omit `reasoning.effort` instead: that gives `max` on `glm5.3` and `high` on `glm5.3-flash`.

> **Tip**
>
> Reasoning tokens count toward `max_tokens` and are billed as output. If you see empty
> `content` with `finish_reason: "length"`, the model spent the whole budget thinking. Raise
> `max_tokens` or lower the effort. On `glm5.3`, `max_tokens` defaults to `2048`.

## Troubleshooting

| Symptom                                                                                        | Likely cause                            | Fix                                                                                                                 |
| ---------------------------------------------------------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `403 invalid_api_key_error`                                                                    | Missing or wrong key header             | Check `api-subscription-key` or the Bearer token                                                                    |
| `404 not_found_error`                                                                          | Unknown or wrongly cased model ID       | IDs are case-sensitive. List the models enabled for your key with [`GET /v2/models`](/api-reference/chat/models-v2) |
| `400` "This model is currently in beta"                                                        | Your key doesn't have beta access       | [Contact us](/api/getting-started/help) to enable beta models for your key                                          |
| Empty `content`, `finish_reason: "length"`                                                     | Reasoning used the token budget         | Raise `max_tokens` or lower `reasoning_effort`                                                                      |
| `400 invalid_request_error` on a specific parameter                                            | Parameter unsupported by this model     | Check the model's own Supported Parameters table                                                                    |
| `402 insufficient_quota_error`                                                                 | No credits left                         | Add credits in the [dashboard](https://indus.sarvam.ai/billing?ref=docs)                                            |
| `429 rate_limit_exceeded_error` / `model_rate_limit_exceeded_error`, or `503 model_overloaded` | Rate limit, model capacity, or overload | Retry with exponential backoff                                                                                      |

## Production tips

#### Retry on 429 and 503

Rate limits and temporary overload are retryable. The OpenAI SDK retries these automatically
with backoff when you raise `max_retries`:

```python
client = OpenAI(
    base_url="https://api.sarvam.ai/v2",
    api_key=os.environ["SARVAM_API_KEY"],
    max_retries=4,
    timeout=120,  # reasoning at high effort can take a while
)
```

#### Budget tokens for reasoning

Set `max_tokens` well above your expected answer length, at least a few thousand for
`high` or `max` effort, because thinking tokens share the same budget.

#### Match effort to the task

Use `low` for extraction, classification and chat. Reserve `high` and `max` for math,
debugging and multi-step planning, where extra thinking improves quality at higher latency and cost.

#### Switch models without code changes

Read the model ID from configuration, for example `model=os.environ.get("SARVAM_MODEL", "glm5.3")`,
so you can compare models on your own prompts. Only change parameters the target model supports,
see the comparison table above.

## Platform details

#### Endpoints and model discovery

* **Chat:** `POST https://api.sarvam.ai/v2/chat/completions`, see the [API reference](/api-reference/chat/chat-completions-v2).
* **Responses:** `POST https://api.sarvam.ai/v2/responses`, see the [API reference](/api-reference/responses/create).
* **Models:** [`GET /v2/models`](/api-reference/chat/models-v2) lists the models enabled for your key. Beta models appear only for keys that have beta access.

#### Billing and rate limits

Usage is metered per token against your Sarvam credits, see [Pricing](/api/getting-started/pricing).
Reasoning is billed as output. Limits apply per API key, see
[Credits & Rate Limits](/api/getting-started/pricing#rate-limits).

#### Beta models

DeepSeek V4.1 Flash 1017, DeepSeek V4 Pro, Kimi K3, MiMo V2.6 Flash, and MiMo V2.6 Pro are
in beta. See [Beta models](/api-reference/beta-apis).

## Next steps

#### [Chat Completions guide](/api/token-factory/chat-completions)

Streaming, tool calling and structured outputs.

#### [Responses API](/api-reference/responses/create)

Stateless responses with reasoning and tools.

#### [Pricing](/api/getting-started/pricing)

Per-token rates for every model.

#### [Migrate from another provider](/api/token-factory/migrations/from-openrouter/overview)

Move from OpenRouter, Fireworks AI, or Together AI.