Migrating from Together AI: Overview
Last updated: October 23, 2026
Together 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 guide covers request
fields, reasoning, error codes, and the Together-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). If you use the Together SDK, the Before (Together 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
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 Together AI-only fields, remove them as described in the Chat Completion guide.
This works with the openai package only. If your code uses the Together SDK, switch to the openai package first, as in the quick start.
Base URL and auth
Status 403 means something different on each platform. On Together it means the prompt
plus max_tokens is longer than the context window. On Sarvam it means a missing or
invalid API key. Update any error handling that branches on 403.
Model IDs
Gemma 4 31B is no longer on Together’s serverless API. On Sarvam, call it by model ID like any other model, with no endpoint to create or manage.
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
Retry 429 and 503 with backoff. Limits apply per API key. See
Errors & Troubleshooting and
Credits & Rate Limits.