Migrating from OpenRouter: Overview
Last updated: October 23, 2026
OpenRouter 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 and
Responses API guides cover request fields, reasoning, tools, and the
OpenRouter-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).
Python
JavaScript
For requests made directly over HTTP, change the URL, the auth header, and the model ID:
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.
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:
Then set your configured model to a Sarvam model ID. If your requests send OpenRouter-only fields, remove them as described in the Chat Completion guide.
Base URL and auth
Model IDs
Sarvam serves each model directly, so there are no provider prefixes, :free, :nitro, or
:floor suffixes, or dated slugs to choose between.
Sarvam’s deepseekv4-pro is the 0813 snapshot. OpenRouter’s plain deepseek/deepseek-v4-pro is the
earlier 0423 snapshot, so outputs can differ after you switch.
Model IDs are case-sensitive. An unknown ID returns 404 not_found_error.
GET /v2/models 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 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.
For other model families, such as Qwen, Llama, gpt-oss, or MiniMax, choose by what you need:
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.
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. See Errors & Troubleshooting and
Credits & Rate Limits.