Skip to navigation

Migrating from Together AI: Overview

View as Markdown

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.

from openai import OpenAI
client = OpenAI(
api_key="YOUR_TOGETHER_API_KEY",
base_url="https://api.together.ai/v1",
)
response = client.chat.completions.create(
model="moonshotai/Kimi-K3",
messages=[{"role": "user", "content": "Hello!"}],
)

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

curl https://api.together.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zai-org/GLM-5.3-Flash",
"messages": [{"role": "user", "content": "Explain UPI in two sentences."}],
"max_tokens": 1000
}'

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:

export OPENAI_BASE_URL="https://api.sarvam.ai/v2"
export OPENAI_API_KEY="YOUR_SARVAM_API_KEY"
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. 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

Together AISarvam
Base URLhttps://api.together.ai/v1 (formerly api.together.xyz)https://api.sarvam.ai/v2
Chat CompletionsPOST /chat/completionsPOST /chat/completions
ResponsesNot availablePOST /responses (stateless)
Auth headerAuthorization: Bearer <key>api-subscription-key: <key> or Authorization: Bearer <key>
Auth failure status401403

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

Together modelSarvam modelStatus on Sarvam
zai-org/GLM-5.3glm5.3GA
zai-org/GLM-5.3-Flashglm5.3-flashGA
google/gemma-4-31B-it (dedicated endpoints only on Together)gemma4GA
deepseek-ai/DeepSeek-V4.1-Flashdeepseekv4.1-flash-1017Beta
deepseek-ai/DeepSeek-V4.1-Flash-1017deepseekv4.1-flash-1017Beta
deepseek-ai/DeepSeek-V4-Pro-0813 (deepseek-ai/DeepSeek-V4-Pro is dedicated only on Together)deepseekv4-pro (same 0813 snapshot)Beta
moonshotai/Kimi-K3kimi-k3Beta
Not offered on Togethermimo-v2.6-flashBeta
Not offered on Togethermimo-v2.6-proBeta

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.

If you useTry on SarvamWhy
GLM-5.3 Primeglm5.3Same GLM-5.3 generation.
GLM-5.3 FlashXglm5.3-flashSame fast GLM-5.3 variant family, with image input.
Earlier GLM (GLM-5.2, GLM-5.1, GLM-5, GLM-4.x)glm5.3Newer generation of the same family. For image input, use glm5.3-flash.
DeepSeek V4 Flash (any snapshot), DeepSeek V3.xdeepseekv4.1-flash-1017The DeepSeek Flash model Sarvam serves.
DeepSeek V4 Pro (April 2026 snapshot), DeepSeek R1deepseekv4-proSarvam serves the newer 0813 snapshot.
Kimi K2, K2.5, K2.6, K2.7 Code, K2 Thinkingkimi-k3Newer Kimi generation, with a longer 1M context.
MiMo V2.5, MiMo V2.6 Pro UltraSpeed, MiMo V2.6 Pro-RLmimo-v2.6-pro or mimo-v2.6-flashCurrent MiMo generation, with image, audio, and video input.
Gemma 3, Gemma 4 26Bgemma4Gemma 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 needTry on Sarvam
Indian-language qualitysarvam-105b
The lowest costmimo-v2.6-flash
Image inputglm5.3-flash, kimi-k3, gemma4, or the MiMo models
Audio inputmimo-v2.6-flash or mimo-v2.6-pro
Video inputmimo-v2.6-flash or mimo-v2.6-pro (chat only)
The hardest coding and agent tasksglm5.3 or deepseekv4-pro
Fast answers without reasoningmimo-v2.6-flash with thinking off, or gemma4

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.

MediaModelsChat CompletionsResponses
ImageModels with image input, such as gemma4, glm5.3-flash, kimi-k3, and the MiMo modelsimage_url partinput_image part
Audiomimo-v2.6-flash, mimo-v2.6-proinput_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)
Videomimo-v2.6-flash, mimo-v2.6-pro, and kimi-k3 (beta, short clips)video_url partNot supported
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

StatusTogether AISarvam
401Invalid or missing keyNot used
402Monthly spend limit reachedNo credits remain
403Prompt plus max_tokens exceeds the context lengthInvalid or missing key
429Rate limitedRate limited
503OverloadedModel overloaded

Retry 429 and 503 with backoff. Limits apply per API key. See Errors & Troubleshooting and Credits & Rate Limits.

See also