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

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

Sarvam serves a curated set of **open-weight models** using your existing Sarvam API key
and credits. Open-weight models are available on **`/v2`**.

**Available in beta.** GLM-5.3, Gemma 4 31B, and DeepSeek V4 Flash are rolling out
gradually. Your API key must be [whitelisted for beta access](/api-reference/beta-apis)
before these models respond. [Contact us](/api/getting-started/help) to request access.

## Available models

All three models support tool calling and produce text output. GLM-5.3 and DeepSeek V4 Flash expose reasoning output.

| Model                                                                         |   Context window | Modality            | Reasoning |
| ----------------------------------------------------------------------------- | ---------------: | ------------------- | :-------: |
| [GLM-5.3](/api/getting-started/models/openweight/glm-5-3)                     | 1,048,576 tokens | Text → text         |    Yes    |
| [Gemma 4 31B](/api/getting-started/models/openweight/gemma-4-31b)             |   131,072 tokens | Text + image → text |     No    |
| [DeepSeek V4 Flash](/api/getting-started/models/openweight/deepseek-v4-flash) | 1,048,576 tokens | Text → text         |    Yes    |

## Reasoning (`glm5.3`, `deepseekv4-flash`)

Three levels: **`low`**, **`high`**, and **`max`**. **Default when omitted is `max`.**

| Route                                                         | Field              | Values                                                                                  |
| ------------------------------------------------------------- | ------------------ | --------------------------------------------------------------------------------------- |
| [Chat Completion V2](/api-reference/chat/chat-completions-v2) | `reasoning_effort` | `low`, `high`, or `max` — omit or pass **`max`** for maximum                            |
| [Responses](/api-reference/responses/create)                  | `reasoning.effort` | `low`, `high`, or **omit** for **`max`** — do **not** send the string **`max`** (`400`) |

Chat: `choices[].message.reasoning_content`. Responses (`glm5.3`): reasoning item in
`output`, `summary[0].text`. Reasoning tokens count toward **`max_tokens`** / **`max_output_tokens`**
(default **`2048`** when omitted on `glm5.3`). [Gemma 4 31B](/api/getting-started/models/openweight/gemma-4-31b)
does not expose reasoning.

## Using open-weight models

### Chat Completion

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.chat.completions_v2(
    model="glm5.3",
    messages=[
        {"role": "user", "content": "Summarise the causes of the 2008 financial crisis."}
    ],
    temperature=1,
    top_p=0.95,
    max_tokens=1000,
)

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: "glm5.3",
        messages: [
            {
                role: "user",
                content: "Summarise the causes of the 2008 financial crisis.",
            },
        ],
        temperature: 1,
        top_p: 0.95,
        max_tokens: 1000,
    });

    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": "Summarise the causes of the 2008 financial crisis."}
    ],
    "model": "glm5.3",
    "temperature": 1,
    "top_p": 0.95,
    "max_tokens": 1000
  }'
```

## Shared behaviour

* **Endpoint** — `POST https://api.sarvam.ai/v2/chat/completions`. See the
  [Chat Completion V2 API Reference](/api-reference/chat/chat-completions-v2).
* **Responses API** — the same models support
  [`POST /v2/responses`](/api-reference/responses/create).
* **Model discovery** — [`GET /v2/models`](/api-reference/chat/models-v2) lists the
  model IDs currently available.
* **Authentication** — pass `api-subscription-key: sk_xxx`. See
  [Authentication](/api-reference/authentication).
* **Beta access** — access is granted per API key. See
  [Access to Beta APIs](/api-reference/beta-apis).
* **Streaming** — set `"stream": true` to receive server-sent events.
* **Billing** — usage is metered per token against your Sarvam credits. See
  [Pricing](/api/getting-started/pricing).
* **Rate limits** — limits are applied per API key. See
  [Credits & Rate Limits](/api/getting-started/ratelimits).