Skip to navigation

Open-Weight Models

Beta
View as Markdown

Run leading open-weight models on Sarvam infrastructure through the same OpenAI-compatible /v2 API, with your existing Sarvam API key and credits. Switching models is a one-line change to the model field.

Available in beta. Your API key must be whitelisted for beta access before these models respond. Contact us to request access.

Choose a model

GLM-5.3Gemma 4 31BDeepSeek V4.1 Flash
Best forCoding and long-horizon agentsImages and low-latency answersLong documents and cost-sensitive reasoning
Model IDglm5.3gemma4deepseekv4.1-flash
Context window1,048,576131,0721,048,576
InputTextText + imageText
Reasoninglow · high · maxlow · high · max
Tool calling
Streaming
Log probabilities
Multiple choices (n)1 only
Disable parallel tool calls
Input / output price (per 1M tokens)₹126 / ₹390₹35 / ₹90₹25 / ₹105

Which model should I use?

If you need…UseWhy
Hardest coding and multi-step agent tasksglm5.3Strongest reasoning, 1M context
Cheapest reasoning over long documentsdeepseekv4.1-flashLowest per-token price, 1M context
Image input, or the lowest latencygemma4No reasoning pass, accepts images
Log probabilities or n > 1 with fast answersgemma4Not supported on glm5.3

Quickstart

1

Get access

Create an API key in the dashboard and request beta access for it.

2

Set your key

export SARVAM_API_KEY="your-api-key"
3

Make your first call

Open-weight models are served on POST /v2/chat/completions. Pick your SDK:

import os
from sarvamai import SarvamAI
client = SarvamAI(api_subscription_key=os.environ["SARVAM_API_KEY"])
response = client.chat.completions_v2(
model="glm5.3", # or "gemma4", "deepseekv4.1-flash"
messages=[
{"role": "user", "content": "Summarise the causes of the 2008 financial crisis."}
],
max_tokens=1000,
)
print(response.choices[0].message.content)

Already use the OpenAI SDK? Point base_url at https://api.sarvam.ai/v2 and pass your Sarvam key as api_key. The endpoint also accepts Authorization: Bearer <key>. Native Sarvam clients use the api-subscription-key header. See Authentication.

Common patterns

Set stream=True to receive server-sent events. Reasoning models stream reasoning_content deltas first, then the final content.

stream = client.chat.completions.create(
model="glm5.3",
messages=[{"role": "user", "content": "What is 17 * 23?"}],
reasoning_effort="low",
max_tokens=1000,
stream=True,
)
for chunk in stream:
if not chunk.choices:
continue
delta = chunk.choices[0].delta
if getattr(delta, "reasoning_content", None):
print(delta.reasoning_content, end="", flush=True) # thinking
if delta.content:
print(delta.content, end="", flush=True) # answer

Reasoning

glm5.3 and deepseekv4.1-flash think before answering. When reasoning_effort is omitted, the default is max.

APIFieldValues
Chat Completion V2reasoning_effortlow, high, max (omit for max)
Responsesreasoning.effortlow, high, or omit for max

On the Responses API, do not send the string "max" to glm5.3. It returns 400. Omit the reasoning field instead.

Reasoning tokens count toward max_tokens and are billed as output. If you see empty content with finish_reason: "length", the model spent the whole budget thinking. Raise max_tokens or lower the effort. On glm5.3, max_tokens defaults to 2048.

Troubleshooting

SymptomLikely causeFix
400 invalid_request_error before the model runsKey not whitelisted for betaRequest access
403 invalid_api_key_errorMissing or wrong key headerCheck api-subscription-key or the Bearer token
404 not_found_errorUnknown or wrongly cased model IDIDs are case-sensitive. List them with GET /v2/models
Empty content, finish_reason: "length"Reasoning used the token budgetRaise max_tokens or lower reasoning_effort
400 on logprobs or n > 1Unsupported on glm5.3See the comparison table above
402 insufficient_quota_errorNo credits leftAdd credits in the dashboard
429 rate_limit_exceeded_error or 503Rate limit or overloadRetry with exponential backoff

Production tips

Rate limits and temporary overload are retryable. The OpenAI SDK retries these automatically with backoff when you raise max_retries:

client = OpenAI(
base_url="https://api.sarvam.ai/v2",
api_key=os.environ["SARVAM_API_KEY"],
max_retries=4,
timeout=120, # reasoning at high effort can take a while
)

Set max_tokens well above your expected answer length, at least a few thousand for high or max effort, because thinking tokens share the same budget.

Use low for extraction, classification and chat. Reserve high and max for math, debugging and multi-step planning, where extra thinking improves quality at higher latency and cost.

Read the model ID from configuration, for example model=os.environ.get("SARVAM_MODEL", "glm5.3"), so you can compare models on your own prompts. Only change parameters the target model supports, see the comparison table above.

Platform details

  • Chat: POST https://api.sarvam.ai/v2/chat/completions, see the API reference.
  • Responses: POST https://api.sarvam.ai/v2/responses, see the API reference.
  • Models: GET /v2/models lists the IDs enabled for your key.

Usage is metered per token against your Sarvam credits, see Pricing. Reasoning is billed as output. Limits apply per API key, see Credits & Rate Limits.

Access is granted per API key. See Access to Beta APIs.

Next steps