Open-Source Models

View as Markdown

Alongside its own models, Sarvam serves a small set of open-source models. You reach them through the same chat completions API, with the same API key, credits, and rate limits — only the model field changes.

Available in beta. GLM-5.3, Gemma 4 31B, and DeepSeek V4 Flash are rolling out gradually — your API key must be whitelisted for beta access before these models respond. A key without access is refused with 400 invalid_request_error before the model is called. Contact us to request access.

This page focuses on the open-source models on /v2. The same endpoint also serves sarvam-105b — see Sarvam-105B. sarvam-105b-conversations is on /v1 only. Call GET /v2/models to see which IDs your key can use.

These models are not tuned for Indian languages. For Indian languages, Indic scripts, or code-mixed input, use Sarvam’s own models — they are trained and evaluated for it. Reach for an open-source model when you need a capability Sarvam’s models do not offer, such as a very large context window or image input.

Available models

Capabilities at a glance

Model IDContext windowTool callingImage inputReasoning output
glm5.31,048,576 tokens✅ always on — see Reasoning output
gemma4131,072 tokens❌ answers directly
deepseekv4-flash1,048,576 tokens✅ always on — see Reasoning output

For comparison, Sarvam’s flagship chat model sarvam-105b supports tool calling with 128K context and is tuned for 23 languages (22 Indian + English).

Using an open-source model

Open-source models are served on /v2/chat/completions. The same models also accept the OpenAI Responses protocol at POST /v2/responses. The chat endpoint also accepts sarvam-105b. Sarvam chat models — including sarvam-105b-conversations — are on /v1; /v1 does not accept glm5.3, gemma4, or deepseekv4-flash.

Authentication uses the api-subscription-key header. A missing or invalid key is refused with 403 invalid_api_key_error. GET /v2/models and GET /v2/models/{model_id} are unauthenticated and list only the models available to you.

Use the Sarvam SDKclient.open_source_models.chat_completions_v2(...) in Python, or client.openSourceModels.chatCompletionsV2(...) in JavaScript.

from sarvamai import SarvamAI
client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
response = client.open_source_models.chat_completions_v2(
model="glm5.3",
messages=[
{"role": "user", "content": "Summarise the causes of the 2008 financial crisis."}
],
temperature=0.2,
max_tokens=1000,
)
print(response.choices[0].message.content)

Model selection

In most cases the answer is a Sarvam model — reach for an open-source model only when you need a capability Sarvam’s own models do not have.

If you need…UseWhy
Indian languages, Indic scripts, romanised or code-mixed inputsarvam-105bTrained and evaluated for it
Highest quality reasoning or agentic worksarvam-105bFlagship model, Sarvam-published benchmarks
Wikipedia-grounded factual answers (wiki_grounding)sarvam-105bSarvam models only — not available on the open-source models
More than 128K of context in one requestglm5.3 or deepseekv4-flashBoth 1,048,576 tokens — 8× the Sarvam chat models
The largest context window at the lowest costdeepseekv4-flash1M tokens, priced below glm5.3
Image input with a conversational answergemma4The only chat model here that accepts images
Document OCR or structured extractionSarvam VisionPurpose-built for documents — better than gemma4 for forms, invoices, PDFs
Visible chain-of-thought (reasoning_content)glm5.3 or deepseekv4-flashBoth reason before every answer and return the trace — see Reasoning output

The three are not interchangeable. glm5.3 and deepseekv4-flash reason before every answer but cannot see images; gemma4 sees images but never produces reasoning. All three support tool calling.

Supported parameters

These models accept the same OpenAI-compatible parameters as Sarvam’s chat models, with the exceptions called out below. Support differs per model where the model itself lacks the capability.

ParameterTypeDefaultglm5.3gemma4deepseekv4-flashNotes
messagesarray— (required)The conversation so far. At least one message. Roles: system, developer, user, assistant, tool.
modelstring— (required)glm5.3, gemma4, or deepseekv4-flash. Must be an id returned by GET /v2/models.
max_tokensinteger2048Must be ≤ the model’s context window. Estimated prompt tokens + max_tokens must fit inside the window, or the request is rejected with 422. On glm5.3 and deepseekv4-flash this budget also covers reasoning — see Reasoning output.
temperaturenumber0.5 if reasoning_effort is set, else 0.202. Prefer altering this or top_p, not both.
top_pnumber1>01. 0 currently fails as 503 model_overloaded rather than a clean 400. Prefer altering this or temperature, not both.
top_kintegernullnull or -1 disables. 0 is 400. Values ≥ 1 are accepted (no enforced cap at 100).
min_pnumbernull01. Outside that range is 400.
repetition_penaltynumbernullGreater than 0, at most 2. 0 is 400.
streambooleanfalseServer-sent events. The chat stream ends with [DONE]. Errors after the stream starts arrive as an SSE error frame before [DONE].
stream_optionsobjectnullTop-level only, and only with stream: true. {"include_usage": true} puts usage (including reasoning_tokens) on a later chunk. Inside extra_body is 400.
stopstring or arraynullUp to 4 stop sequences; not included in the output.
ninteger11128. You are billed for tokens across all choices — keep at 1 unless you need multiple completions.
seedintegernull⚠️⚠️Beta, best-effort determinism. In current serving gemma4 returns identical output for an identical seed and parameters; glm5.3 and deepseekv4-flash do not.
frequency_penaltynumber0-22. Penalises tokens by existing frequency, reducing verbatim repetition.
presence_penaltynumber0-22. Penalises tokens already present, encouraging new topics.
reasoning_effortstringnullChat accepts none, minimal, low, medium, high, xhigh, max. glm5.3 and deepseekv4-flash reason even when this is unset; gemma4 accepts the parameter but never produces reasoning. See Reasoning output.
response_formatobjectnull{type: "text"}, {type: "json_object"}, or {type: "json_schema", json_schema: {...}}. See Structured Outputs.
toolsarraynullOpenAI-compatible function calling. Max 128 tools; the model must support tools.
tool_choicestring or objectnullnone, auto, required, or a named function. Requires tools when set to required or a function name — otherwise 422.
parallel_tool_callsbooleannullAccepted. On glm5.3, false does not collapse two requested calls into one.
extra_bodyobject{}Model-specific options forwarded unchanged. Must not repeat any field in this table or carry stream_options; a collision is rejected with 400.
image_url content partobjectglm5.3 and deepseekv4-flash return 400. gemma4 accepts base64 data URIs only — remote URLs are rejected. See Image input.

Full request and response schema: Open-Source Models API Reference.

OpenAI-compatible fields not listed above — logit_bias, user, and similar — are accepted but ignored. logprobs: true currently fails as 503 model_overloaded rather than being ignored. Unknown fields inside extra_body that the model backend does not recognise are rejected.

wiki_grounding is not part of the /v2 schema. For Wikipedia grounding, use sarvam-105b on /v1.

Reasoning output

glm5.3 and deepseekv4-flash are reasoning models: they think before every answer, whether or not reasoning_effort is set. The chain-of-thought arrives in a separate reasoning_content field on the message — content holds only the final answer — and in streaming responses it arrives as delta.reasoning_content chunks before the answer starts. Reasoning tokens are billed as completion tokens and count against max_tokens, so a budget that is too small is consumed entirely by reasoning and the request returns content: null with finish_reason: "length".

Reasoning tokens are reported on usage.completion_tokens_details.reasoning_tokens (and, with stream_options.include_usage, on a later streaming chunk).

extra_body.chat_template_kwargs.enable_thinking: false is accepted but currently does not disable thinking on glm5.3. Use reasoning_effort: "low" to keep the trace short, or raise max_tokens so reasoning cannot consume the whole budget. On POST /v2/responses, text.format of json_object or json_schema skips the reasoning item.

gemma4 is not a reasoning model. It answers directly, never returns reasoning_content, and setting reasoning_effort on it has no effect.

Structured Outputs

response_format works on all three models. Use {"type": "json_schema", "json_schema": {...}} to constrain output to a JSON Schema, or {"type": "json_object"} for the older JSON mode, which guarantees valid JSON but not a specific shape.

On glm5.3 and deepseekv4-flash, keep max_tokens large enough for both reasoning and the JSON when you set response_format. With reasoning active and a small budget, a JSON-constrained request can return content: null. extra_body.chat_template_kwargs.enable_thinking: false is still accepted but does not currently disable glm5.3 thinking. For reliable JSON on glm5.3, POST /v2/responses with text.format json_object or strict json_schema skips the reasoning item.

import json
from sarvamai import SarvamAI
client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
response = client.open_source_models.chat_completions_v2(
model="glm5.3",
messages=[
{"role": "user", "content": "List two Indian cities with their populations."}
],
max_tokens=500,
extra_body={
"chat_template_kwargs": {"enable_thinking": False}
},
response_format={
"type": "json_schema",
"json_schema": {
"name": "city_list",
"strict": True,
"schema": {
"type": "object",
"properties": {
"cities": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"population": {"type": "integer"},
},
"required": ["name", "population"],
"additionalProperties": False,
},
}
},
"required": ["cities"],
"additionalProperties": False,
},
},
},
)
cities = json.loads(response.choices[0].message.content)
print(cities)

On the Python SDK, pass extra_body and response_format as direct keyword arguments to chat_completions_v2 (as above). On /v1/chat/completions, the chat client does not expose response_format as a typed parameter — use request_options={"additional_body_parameters": {"response_format": ...}} instead; see Structured Outputs.

Don’t also ask for JSON in the prompt. When response_format is set, an instruction like “Return JSON” in the message makes gemma4 emit whitespace until it exhausts max_tokens — you are billed for the full budget and get no usable output. State the task in the prompt and let response_format handle the shape.

Image input

Only gemma4 accepts images, and only as base64 data URIs. A remote http:// or https:// URL is rejected — the API does not fetch images on your behalf. Full example on the Gemma 4 31B page.

{
"type": "image_url",
"image_url": { "url": "data:image/png;base64,<encoded bytes>" }
}

Each image counts against the request-size cap once encoded. Prompt and request-size checks use estimates — text at roughly 4 bytes per token, plus a flat per-image allowance — rather than an exact tokenizer count.

Tool schemas

function.parameters must be a JSON Schema object; a property defined as a bare string is rejected. When tool_choice forces a call (required or a named function), schemas must be self-contained: non-local $ref, unresolved $ref, recursive schemas, or a combined expansion above 20,000 nodes across all tools in the request are rejected with 400.

Errors

Every error uses the same envelope — error.message, error.code, and error.request_id (empty when the error is raised before a request id is assigned):

{
"error": {
"message": "Model 'gpt-4' not found.",
"code": "not_found_error",
"request_id": "20260729_0f1e2d3c-…"
}
}
StatusCodeRaised when
400invalid_request_errorBody fails validation, the model lacks a requested capability, the key lacks beta access to this endpoint, or extra_body collides with a validated field
402insufficient_quota_errorNo credits available
403invalid_api_key_errorMissing or invalid API key
404not_found_errorUnknown model id, or a model not available to your key
413invalid_request_errorRequest size exceeds the model’s cap
422unprocessable_entity_errorPrompt + max_tokens exceeds the context window, tool_choice forced without tools, or the model rejected the request
429rate_limit_exceeded_errorRate or concurrency limit; may carry Retry-After
500internal_server_errorUnhandled failure
502model_call_failedThe model call failed and could not be retried
503model_overloadedTimeout, connection failure, or overload after automatic retries

Timeouts, connection failures, and overload are retried automatically before a 503 is returned. A request the model itself rejects is not retried and comes back as 422.

Support and expectations

Sarvam supports the serving layer: availability, authentication, billing, rate limits, and API compatibility. If a request fails with a Sarvam error — an auth failure, a rate limit, a credits problem, a malformed response from our gateway — contact us.

Sarvam does not tune, evaluate, or publish benchmarks for these models, and does not guarantee their output quality. A model’s reasoning, factual accuracy, language coverage, and refusals are properties of the model itself rather than of Sarvam’s serving.

These models may be updated, versioned, or withdrawn on a different schedule from Sarvam’s own models. Do not assume one of these model IDs is a long-term stable contract — check the changelog before depending on one in production.

Each model carries its own open-source licence and acceptable-use terms, which apply to you as the end user in addition to Sarvam’s terms. Review the model’s licence before using it in a commercial product.

Shared behaviour

Everything below applies to both models:

  • EndpointPOST https://api.sarvam.ai/v2/chat/completions. Full parameter reference: Open-Source Models API Reference. The same models also accept the OpenAI Responses protocol at POST /v2/responses. Create-only and stateless: replay input every turn. Omit store or pass false (OpenAI SDKs default true — that call is 400).
  • Model discoveryGET https://api.sarvam.ai/v2/models lists the model IDs the endpoint currently serves.
  • Authenticationapi-subscription-key: sk_xxx. Invalid keys return 403 invalid_api_key_error. See Authentication.
  • Beta access — granted per key. Without access, the endpoint returns 400 invalid_request_error before calling the model. See Access to Beta APIs.
  • Streaming — set "stream": true for server-sent events. Chat still sends [DONE]; Responses does not. Pass chat stream_options.include_usage for a usage chunk. Responses tool/reasoning streams use response.function_call_arguments.* and response.reasoning_text.*.
  • Billing — metered per token against your Sarvam credits, reasoning tokens included. Per 1M tokens (input / cached input / output): gemma4 ₹36.6 / ₹13.73 / ₹91.5, deepseekv4-flash ₹19.8 / ₹0.63 / ₹59.4, glm5.3 ₹126 / ₹23.4 / ₹396. The three are not priced alike — glm5.3 and deepseekv4-flash reason before every answer, so budget max_tokens deliberately, and glm5.3 costs roughly 6× deepseekv4-flash. See Pricing.
  • Rate limits — applied per API key. See Credits & Rate Limits.