Skip to navigation

Migrating Chat Completion from Together AI to Sarvam

View as Markdown

Last updated: October 23, 2026

This guide covers moving Together AI Chat Completions calls for open-weight models to Sarvam’s /v2 API.

In short: change base_url, api_key, and model. Replace reasoning: {"enabled": false} with reasoning_effort: "none", send logprobs as true instead of a number, and remove Together-only fields such as safety_model: Sarvam returns 400 for request fields it doesn’t support. Remember that 403 now means an auth error, not a context-length error.

Migration checklist

  1. Create an API key in the Sarvam dashboard.
  2. Change base_url to https://api.sarvam.ai/v2 and api_key to your Sarvam key.
  3. Replace each model ID using the model ID table.
  4. Replace reasoning: {"enabled": false} with reasoning_effort: "none" (Reasoning).
  5. Remove Together-only fields: safety_model, compliance, echo, and others (list).
  6. Send logprobs as true, with the count in top_logprobs.
  7. Update error handling: 403 now means an invalid key, not a prompt that’s too long.
  8. Set max_tokens explicitly, then run your tests and watch for 400 responses that name a field.

Quick start

Together AISarvam
Base URLhttps://api.together.ai/v1https://api.sarvam.ai/v2
Auth headerAuthorization: Bearer <key>api-subscription-key: <key> or Authorization: Bearer <key>
Model IDmoonshotai/Kimi-K3kimi-k3 (see the model ID table)
from together import Together
client = Together(api_key="YOUR_TOGETHER_API_KEY")
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro-0813",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Suggest a name for a coffee shop in Bengaluru."},
],
max_tokens=2000,
reasoning={"enabled": False},
)
print(response.choices[0].message.content)

Reasoning

Together AISarvamNote
reasoning_effort: "low" / "high" / "max"SameEach model’s default is listed under Reasoning.
reasoning_effort: "medium"Use "low", "high", or "max"Accepted on some models and returns 400 on others, such as glm5.3.
reasoning: {"enabled": false}reasoning_effort: "none"The reasoning object returns 400. "none" turns thinking off on deepseekv4-pro, mimo-v2.6-flash, and mimo-v2.6-pro. kimi-k3 and glm5.3-flash always think.
reasoning: {"enabled": true}RemoveReasoning models think by default.
chat_template_kwargsSamePassed to the model. {"enable_thinking": false} turns thinking off on the MiMo models.
choices[].message.reasoning (DeepSeek V4 Pro)choices[].message.reasoning_contentSarvam uses reasoning_content for every model, and delta.reasoning_content when streaming.
choices[].message.reasoning_content (Kimi K3, GLM)Same

Together-only fields to remove

Sarvam validates request fields and returns 400 invalid_request_error for fields it doesn’t support, so leftover Together options fail loudly instead of being ignored.

Together fieldWhat to do on Sarvam
reasoning objectReplace with reasoning_effort (see Reasoning).
safety_modelRemove. Run moderation as a separate step before or after the call.
complianceRemove.
context_length_exceeded_behaviorRemove. Sarvam returns an error when the prompt plus max_tokens is longer than the context window, as Together does by default.
echoRemove. Keep the prompt on your side.
response_format: {"type": "regex"}Use response_format with a json_schema, and put the pattern in a string property’s pattern.
logprobs: 5 (a number)Use logprobs: true with top_logprobs: 5.
functions, function_callUse tools and tool_choice. The legacy fields return 400.

Parameter concept map

Together AISarvamNote
messages, max_tokens, temperature, top_p, top_k, stop, seedSameSet max_tokens explicitly: when it’s omitted, generation isn’t capped at a small default.
repetition_penalty, frequency_penalty, presence_penaltySame
min_pNot supportedRemove it. The open-weight models accept only 0, which is the same as leaving it out.
tools, tool_choice, parallel_tool_callsSameparallel_tool_calls: false is enforced on every model; see V2 feature support.
response_format (json_schema, json_object)Same
nSameSupported on most models. temperature must be above 0 when n > 1.
stream: trueSameAs on Together, the last chunk before [DONE] carries usage with an empty choices array; keep skipping it.
image_url content partsSameSarvam accepts inline base64 data URIs only, not remote image URLs, on models with image input. See each model page.
video_url content partsSame, as a base64 data URIOn the MiMo models and kimi-k3 (beta, short clips). Sarvam doesn’t fetch video URLs.
input_audio content partsSame, on the MiMo modelswav or mp3. For FLAC, OGG, or Opus, send an audio_url part with a data URI. See Media input.
finish_reason: "eos"finish_reason: "stop"

Responses API

Together doesn’t offer a Responses API. Sarvam does: if you want the OpenAI Responses format, see the Responses API guide. It’s stateless, like Chat Completions.

What’s different by design

  • No dedicated endpoints to manage. Models that are dedicated-only on Together, such as Gemma 4 31B, are called by model ID on Sarvam.
  • Strict request validation. Unsupported fields return 400 with the field named, instead of being dropped silently. gemma4 is less strict: it accepts some fields, such as prediction and logit_bias, and ignores them.
  • One reasoning field. Reasoning comes back in reasoning_content for every model.
  • Different meaning for 403. On Sarvam it’s an auth error. See the status code table.

Platform features without a direct equivalent

Together featureOn Sarvam
Batch APINot available. Send requests concurrently within your rate limits.
Fine-tuning and LoRA adaptersNot available on the /v2 API.
Dedicated endpoints and provisioned throughputNot needed for these models. Contact Sarvam for capacity needs.
Llama Guard moderation (safety_model)Not available. Run moderation separately.

Full example

A wrapper that turns thinking off, asks for log probabilities, and maps status codes:

from together import Together
client = Together(api_key="YOUR_TOGETHER_API_KEY")
def ask(prompt: str) -> str:
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro-0813",
messages=[{"role": "user", "content": prompt}],
max_tokens=2000,
reasoning={"enabled": False},
logprobs=3,
)
return response.choices[0].message.content

Common mistakes

On Sarvam, 403 means the API key is missing or invalid. Don’t trim the prompt and retry on 403; check the key instead.

moonshotai/Kimi-K3 returns 404 on Sarvam. Use kimi-k3. Model IDs are case-sensitive. See the model ID table.

Sarvam returns 400. Use reasoning_effort: "none" on models that can turn thinking off.

Sarvam expects logprobs: true and the count in top_logprobs.

Sarvam accepts images, audio, and video only as inline base64 data URIs; URLs return 400. Download the file and encode it before sending. See Media input.

See also