Skip to navigation

Migrating Chat Completion from Fireworks AI to Sarvam

View as Markdown

Last updated: October 23, 2026

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

In short: change base_url, api_key, and model. Reasoning comes back in reasoning_content on both platforms. Remove Fireworks-only fields such as prompt_truncate_len and perf_metrics_in_response, because Sarvam returns 400 for request fields it doesn’t support. Set max_tokens explicitly, and send the full history on every Responses call.

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. Fast, US, and deployment IDs map to the same Sarvam ID.
  4. Use string values for reasoning_effort (low, high, max, or none) (Reasoning).
  5. Remove Fireworks-only fields: prompt_truncate_len, context_length_exceeded_behavior, perf_metrics_in_response, and others (list).
  6. Set max_tokens explicitly: only glm5.3 defaults to 2048 on Sarvam.
  7. Trim long conversations yourself: Sarvam doesn’t truncate prompts.
  8. If you use the Responses API, follow Migrating the Responses API.
  9. Run your tests and watch for 400 responses that name a field.

Quick start

Fireworks AISarvam
Base URLhttps://api.fireworks.ai/inference/v1https://api.sarvam.ai/v2
Auth headerAuthorization: Bearer <key>api-subscription-key: <key> or Authorization: Bearer <key>
Model IDaccounts/fireworks/models/kimi-k3kimi-k3 (see the model ID table)
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": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Suggest a name for a coffee shop in Bengaluru."},
],
reasoning_effort="low",
extra_body={"prompt_truncate_len": 100000},
)
print(response.choices[0].message.content)

Reasoning

FireworksSarvamNote
reasoning_effort: "low" / "high" / "max"SameEach model’s default is listed under Reasoning.
reasoning_effort: "medium" / "xhigh"Use "low", "high", or "max"Accepted on some models and returns 400 on others, such as glm5.3.
reasoning_effort: "none" or falsereasoning_effort: "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_effort as a token budget (1024 or more)Use an effort levelInteger budgets above 100 return 400.
thinking: {"type": "disabled"}Same, via extra_bodyWorks on the models that can turn thinking off. To control depth, use reasoning_effort.
reasoning_historyRemoveTo keep reasoning across turns, send the earlier assistant reasoning_content back in messages.
choices[].message.reasoning_contentSameAlso delta.reasoning_content when streaming.

On Fireworks, a json_schema response format turns reasoning off. On Sarvam, reasoning models keep reasoning when you use response_format, so leave room in max_tokens, or turn thinking off on models that support it.

Fireworks-only fields to remove

Sarvam validates request fields and returns 400 invalid_request_error with Unsupported parameter(s) for fields it doesn’t support, so leftover Fireworks options fail loudly instead of being ignored.

Fireworks fieldWhat to do on Sarvam
prompt_truncate_lenRemove. Trim old messages yourself before sending.
context_length_exceeded_behaviorRemove. Sarvam returns an error when the prompt plus max_tokens is longer than the context window, instead of truncating.
perf_metrics_in_responseRemove. Measure latency on your side. Sarvam returns token counts in usage.
response_format: {"type": "grammar"}Use response_format with a json_schema. Sarvam supports text, json_object, and json_schema.
typical_p, mirostat_target, mirostat_lrRemove. Use temperature, top_p, or top_k.
raw_output, echo, return_token_ids, prompt_token_ids, safe_tokenizationRemove. Not available.
prediction, logit_biasRemove. Not supported.
reasoning_historyRemove (see Reasoning).
Model IDs with accounts/.../deployments/...Use the Sarvam model ID. There are no deployments to manage.

Parameter concept map

FireworksSarvamNote
messages, temperature, top_p, top_k, stop, seedSame
max_tokens (defaults to 2048)max_tokensSet it explicitly. When it’s omitted on Sarvam, generation isn’t capped at 2048 (except on glm5.3).
frequency_penalty, presence_penalty, repetition_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_callsSametool_choice: "any" is Fireworks-only; use "required".
response_format (json_object, json_schema)Same
logprobs, top_logprobsSamelogprobs must be true or false. Not supported on glm5.3.
nSameSupported on most models. temperature must be above 0 when n > 1.
prompt_cache_key, userAccepted, except prompt_cache_key on gemma4, which returns 400For multi-turn caching on gemma4, send the x-session-affinity header.
service_tier: "priority", Fast routersNot neededSarvam has a single tier per model.
stream: trueSameUsage arrives in the final chunk.
image_url content partsSameInline base64 data URIs only, on models with image input. See each model page.
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.
video_url content partsSame, as a base64 data URIOn the MiMo models and kimi-k3 (beta, short clips). Sarvam doesn’t fetch video URLs.

Responses API

Fireworks stores responses and chains them with previous_response_id; Sarvam’s Responses API is stateless, so you send the history in input instead. For base URL and field changes, reasoning items, function tools, and server-side tools, see Migrating the Responses API from Fireworks.

What’s different by design

  • No deployments to manage. Models that need an on-demand deployment on Fireworks, such as Gemma 4 31B and DeepSeek V4 Pro, 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.
  • No silent truncation. Sarvam rejects a prompt that doesn’t fit, rather than cutting old messages or lowering max_tokens for you.
  • Stateless Responses. Your app keeps the conversation history, as with Chat Completions.

Platform features without a direct equivalent

Fireworks featureOn Sarvam
Batch inference jobsNot available. Send requests concurrently within your rate limits.
Fine-tuned and LoRA modelsNot available on the /v2 API.
On-demand deploymentsNot needed. Every model is served by ID.
US-only endpointNot available.

Full example

A wrapper with retries on 429 and 503, which Fireworks returns when it sheds load and Sarvam returns when a model is overloaded:

from openai import OpenAI
client = OpenAI(
api_key="YOUR_FIREWORKS_API_KEY",
base_url="https://api.fireworks.ai/inference/v1",
)
def ask(prompt: str) -> str:
response = client.chat.completions.create(
model="accounts/fireworks/models/deepseek-v4p1-flash",
messages=[{"role": "user", "content": prompt}],
reasoning_effort="low",
extra_body={"context_length_exceeded_behavior": "truncate"},
)
return response.choices[0].message.content

Common mistakes

accounts/fireworks/models/kimi-k3 returns 404 on Sarvam. Use kimi-k3. See the model ID table.

Fireworks caps output at 2048 tokens when max_tokens is omitted. On Sarvam only glm5.3 does, so long answers can run much longer. Set max_tokens explicitly, leaving room for reasoning tokens.

Sarvam returns an error instead of truncating. Trim the conversation before sending.

Sarvam doesn’t store responses. Keep the history in your app and send it in input, as in the Responses example.

Fields like prompt_truncate_len and perf_metrics_in_response are often passed through extra_body. Sarvam returns 400 with the field name; remove each one it names.

See also