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

# Migrating from Fireworks AI: Overview

> Base URL, auth, model ID mapping, and SDK changes for teams moving open-weight model traffic from Fireworks AI to Sarvam's OpenAI-compatible /v2 API.

*Last updated: October 23, 2026*

Fireworks AI and Sarvam's `/v2` API both speak the OpenAI Chat Completions format, so most
migrations are a base URL, key, and model ID change. This page covers those setup changes.
The [Chat Completion](/api/token-factory/migrations/from-fireworks/chat-completion) and
[Responses API](/api/token-factory/migrations/from-fireworks/responses-api) guides cover request fields, reasoning, tools, and the
Fireworks-only features to remove.

## Quick start

Change the client and the model ID. Use the `openai` package you already have, or Sarvam's own
SDK ([SDKs & Libraries](/api/getting-started/sdks)). If you use the Fireworks SDK, the **Before (Fireworks SDK)** option shows that version; the request shape is the same, so you can move to either the `openai` package or Sarvam's SDK.

#### Python

#### Before (Fireworks)

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_FIREWORKS_API_KEY",
    base_url="https://api.fireworks.ai/inference/v1",
)

response = client.chat.completions.create(
    model="accounts/fireworks/models/kimi-k3",
    messages=[{"role": "user", "content": "Hello!"}],
)
```

#### Before (Fireworks SDK)

```python
from fireworks import Fireworks

client = Fireworks(api_key="YOUR_FIREWORKS_API_KEY")

response = client.chat.completions.create(
    model="accounts/fireworks/models/kimi-k3",
    messages=[{"role": "user", "content": "Hello!"}],
)
```

#### After (OpenAI SDK)

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_SARVAM_API_KEY",
    base_url="https://api.sarvam.ai/v2",
)

response = client.chat.completions.create(
    model="kimi-k3",
    messages=[{"role": "user", "content": "Hello!"}],
)
```

#### After (Sarvam SDK)

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.chat.completions_v2(
    model="kimi-k3",
    messages=[{"role": "user", "content": "Hello!"}],
)
```

#### JavaScript

#### Before (Fireworks)

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_FIREWORKS_API_KEY",
  baseURL: "https://api.fireworks.ai/inference/v1",
});

const response = await client.chat.completions.create({
  model: "accounts/fireworks/models/kimi-k3",
  messages: [{ role: "user", content: "Hello!" }],
});
```

#### After (OpenAI SDK)

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_SARVAM_API_KEY",
  baseURL: "https://api.sarvam.ai/v2",
});

const response = await client.chat.completions.create({
  model: "kimi-k3",
  messages: [{ role: "user", content: "Hello!" }],
});
```

#### After (Sarvam SDK)

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

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

const response = await client.chat.completionsV2({
  model: "kimi-k3",
  messages: [{ role: "user", content: "Hello!" }],
});
```

For requests made directly over HTTP, change the URL, the auth header, and the model ID:

#### Before (Fireworks)

```bash
curl https://api.fireworks.ai/inference/v1/chat/completions \
  -H "Authorization: Bearer YOUR_FIREWORKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "accounts/fireworks/models/glm-5p3-flash",
    "messages": [{"role": "user", "content": "Explain UPI in two sentences."}],
    "max_tokens": 1000
  }'
```

#### After (Sarvam)

```bash
curl https://api.sarvam.ai/v2/chat/completions \
  -H "api-subscription-key: YOUR_SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm5.3-flash",
    "messages": [{"role": "user", "content": "Explain UPI in two sentences."}],
    "max_tokens": 1000
  }'
```

> **Note**
>
> Sarvam also accepts `Authorization: Bearer <key>`, which is what the `openai` package sends,
> so you don't need to change how your client authenticates. Create a key in the
> [Sarvam dashboard](https://indus.sarvam.ai/key-management?ref=docs).

## Zero-code switch

The `openai` package for Python and JavaScript reads its endpoint and key from the
`OPENAI_BASE_URL` and `OPENAI_API_KEY` environment variables when you create the client without
them. If your app does that, and reads the model ID from configuration, you can switch without
changing code:

```bash
export OPENAI_BASE_URL="https://api.sarvam.ai/v2"
export OPENAI_API_KEY="YOUR_SARVAM_API_KEY"
```

```python
from openai import OpenAI

client = OpenAI()  # picks up OPENAI_BASE_URL and OPENAI_API_KEY
```

Then set your configured model to a [Sarvam model ID](#model-ids). If your requests send
Fireworks-only fields, remove them as described in the
[Chat Completion guide](/api/token-factory/migrations/from-fireworks/chat-completion).

This works with the `openai` package only. If your code uses the Fireworks SDK, switch to the `openai` package first, as in the [quick start](#quick-start).

## Base URL and auth

|                     | Fireworks AI                                                                            | Sarvam                                                         |
| ------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| Base URL            | `https://api.fireworks.ai/inference/v1` (or `https://us.api.fireworks.ai/inference/v1`) | `https://api.sarvam.ai/v2`                                     |
| Chat Completions    | `POST /chat/completions`                                                                | `POST /chat/completions`                                       |
| Responses           | `POST /responses`                                                                       | `POST /responses` (stateless)                                  |
| Auth header         | `Authorization: Bearer <key>`                                                           | `api-subscription-key: <key>` or `Authorization: Bearer <key>` |
| Auth failure status | `401`                                                                                   | `403`                                                          |

## Model IDs

Sarvam has one ID per model. Fireworks' Fast and US router variants, and your own
dedicated deployments of these models, map to the same Sarvam ID.

| Fireworks `model`                                                                                    | Sarvam `model`                                                                  | Status on Sarvam |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ---------------- |
| `accounts/fireworks/models/glm-5p3` (also `routers/glm-5p3-fast`, `routers/glm-5p3-us`)              | [`glm5.3`](/api/token-factory/models/glm-5-3)                                   | GA               |
| `accounts/fireworks/models/glm-5p3-flash` (also `routers/glm-5p3-flash-us`)                          | [`glm5.3-flash`](/api/token-factory/models/glm-5-3-flash)                       | GA               |
| `accounts/fireworks/models/gemma-4-31b-it` (on-demand deployment on Fireworks)                       | [`gemma4`](/api/token-factory/models/gemma-4-31b)                               | GA               |
| `accounts/fireworks/models/deepseek-v4p1-flash` (also `routers/deepseek-v4p1-flash-us`)              | [`deepseekv4.1-flash-1017`](/api/token-factory/models/deepseek-v4.1-flash-1017) | Beta             |
| `accounts/fireworks/routers/deepseek-v4p1-flash-1017-us` (US-only router on Fireworks)               | [`deepseekv4.1-flash-1017`](/api/token-factory/models/deepseek-v4.1-flash-1017) | Beta             |
| `accounts/fireworks/models/deepseek-v4-pro` (April 2026 snapshot; on-demand deployment on Fireworks) | [`deepseekv4-pro`](/api/token-factory/models/deepseek-v4-pro) (0813 snapshot)   | Beta             |
| `accounts/fireworks/models/kimi-k3` (also `routers/kimi-k3-fast`, `routers/kimi-k3-us`)              | [`kimi-k3`](/api/token-factory/models/kimi-k3)                                  | Beta             |
| Not offered on Fireworks                                                                             | [`mimo-v2.6-flash`](/api/token-factory/models/mimo-v2.6-flash)                  | Beta             |
| Not offered on Fireworks (only the MiMo V2.6 Pro-RL variant is listed)                               | [`mimo-v2.6-pro`](/api/token-factory/models/mimo-v2.6-pro)                      | Beta             |

Sarvam's `deepseekv4-pro` is the newer 0813 snapshot of DeepSeek V4 Pro, so outputs can differ
from the April 2026 snapshot on Fireworks.

Gemma 4 31B and DeepSeek V4 Pro need a dedicated deployment on Fireworks. On Sarvam, call
them by model ID like any other model, with no deployment to create or manage.

Model IDs are case-sensitive. An unknown ID returns `404 not_found_error`.
[`GET /v2/models`](/api-reference/chat/models-v2) lists the available models. Beta models
need per-key access: without it, they return `400 invalid_request_error`, even though the list shows them.
[Contact us](/api/getting-started/help) to request access.

## Models not on Sarvam

If you use a model that Sarvam doesn't serve, start with the closest one below, then test it on
your own prompts before switching traffic. These are suggestions, not drop-in equivalents.

| If you use                                            | Try on Sarvam                                                                                                                | Why                                                                              |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| GLM-5.3 Prime                                         | [`glm5.3`](/api/token-factory/models/glm-5-3)                                                                                | Same GLM-5.3 generation.                                                         |
| GLM-5.3 FlashX                                        | [`glm5.3-flash`](/api/token-factory/models/glm-5-3-flash)                                                                    | Same fast GLM-5.3 variant family, with image input.                              |
| Earlier GLM (GLM-5.2, GLM-5.1, GLM-5, GLM-4.x)        | [`glm5.3`](/api/token-factory/models/glm-5-3)                                                                                | Newer generation of the same family. For image input, use `glm5.3-flash`.        |
| DeepSeek V4 Flash (any snapshot), DeepSeek V3.x       | [`deepseekv4.1-flash-1017`](/api/token-factory/models/deepseek-v4.1-flash-1017)                                              | The DeepSeek Flash model Sarvam serves.                                          |
| DeepSeek V4 Pro (April 2026 snapshot), DeepSeek R1    | [`deepseekv4-pro`](/api/token-factory/models/deepseek-v4-pro)                                                                | Sarvam serves the newer 0813 snapshot.                                           |
| Kimi K2, K2.5, K2.6, K2.7 Code, K2 Thinking           | [`kimi-k3`](/api/token-factory/models/kimi-k3)                                                                               | Newer Kimi generation, with a longer 1M context.                                 |
| MiMo V2.5, MiMo V2.6 Pro UltraSpeed, MiMo V2.6 Pro-RL | [`mimo-v2.6-pro`](/api/token-factory/models/mimo-v2.6-pro) or [`mimo-v2.6-flash`](/api/token-factory/models/mimo-v2.6-flash) | Current MiMo generation, with image, audio, and video input.                     |
| Gemma 3, Gemma 4 26B                                  | [`gemma4`](/api/token-factory/models/gemma-4-31b)                                                                            | Gemma 4 31B: image input, a 256K context window, and reasoning (off by default). |

For other model families, such as Qwen, Llama, gpt-oss, or MiniMax, choose by what you need:

| If you need                        | Try on Sarvam                                                                                                                                                                    |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Indian-language quality            | [`sarvam-105b`](/api/api-guides-tutorials/models/sarvam-105b)                                                                                                                    |
| The lowest cost                    | [`mimo-v2.6-flash`](/api/token-factory/models/mimo-v2.6-flash)                                                                                                                   |
| Image input                        | [`glm5.3-flash`](/api/token-factory/models/glm-5-3-flash), [`kimi-k3`](/api/token-factory/models/kimi-k3), [`gemma4`](/api/token-factory/models/gemma-4-31b), or the MiMo models |
| Audio input                        | [`mimo-v2.6-flash`](/api/token-factory/models/mimo-v2.6-flash) or [`mimo-v2.6-pro`](/api/token-factory/models/mimo-v2.6-pro)                                                     |
| Video input                        | [`mimo-v2.6-flash`](/api/token-factory/models/mimo-v2.6-flash) or [`mimo-v2.6-pro`](/api/token-factory/models/mimo-v2.6-pro) (chat only)                                         |
| The hardest coding and agent tasks | [`glm5.3`](/api/token-factory/models/glm-5-3) or [`deepseekv4-pro`](/api/token-factory/models/deepseek-v4-pro)                                                                   |
| Fast answers without reasoning     | [`mimo-v2.6-flash`](/api/token-factory/models/mimo-v2.6-flash) with thinking off, or [`gemma4`](/api/token-factory/models/gemma-4-31b)                                           |

## Media input and request size

Sarvam accepts images, audio, and video only as **inline base64 data URIs**. Remote `http(s)`
URLs return `400` on every model, even where your current provider fetches them for you, so
download the file and encode it before sending.

| Media | Models                                                                                    | Chat Completions                                                                                        | Responses                           |
| ----- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| Image | Models with image input, such as `gemma4`, `glm5.3-flash`, `kimi-k3`, and the MiMo models | `image_url` part                                                                                        | `input_image` part                  |
| Audio | `mimo-v2.6-flash`, `mimo-v2.6-pro`                                                        | `input_audio` part (`wav` or `mp3`), or an `audio_url` part with a data URI (WAV, MP3, FLAC, OGG, Opus) | `input_audio` part (`wav` or `mp3`) |
| Video | `mimo-v2.6-flash`, `mimo-v2.6-pro`, and `kimi-k3` (beta, short clips)                     | `video_url` part                                                                                        | Not supported                       |

```python
import base64

def data_uri(path: str, mime: str) -> str:
    with open(path, "rb") as f:
        return f"data:{mime};base64," + base64.b64encode(f.read()).decode()

image_part = {"type": "image_url", "image_url": {"url": data_uri("chart.png", "image/png")}}
video_part = {"type": "video_url", "video_url": {"url": data_uri("clip.mp4", "video/mp4")}}
```

Request bodies, including base64 media, are limited to **40 MiB** on `kimi-k3` and the MiMo
models, and **10 MiB** on other models. Larger requests
return `413` with the limit in the message. Base64 adds about 33%, so about 30 MB of raw media
fits in a 40 MiB request.

## Errors and rate limits

Sarvam returns `403` (not `401`) for a missing or invalid key, `429` when you exceed a rate
limit, and `503` when a model is overloaded. Retry `429` and `503` with backoff. Limits apply
per API key, as requests per minute rather than Fireworks' adaptive tokens-per-minute limits.
See [Errors & Troubleshooting](/api/getting-started/errors-troubleshooting) and
[Credits & Rate Limits](/api/getting-started/pricing#rate-limits).

## See also

* [Migrating Chat Completion from Fireworks](/api/token-factory/migrations/from-fireworks/chat-completion)
* [Migrating the Responses API from Fireworks](/api/token-factory/migrations/from-fireworks/responses-api)
* [Open-Weight Models](/api/token-factory/models)
* [Beta models](/api-reference/beta-apis)
* [Errors & Troubleshooting](/api/getting-started/errors-troubleshooting)