GLM-5.2

View as Markdown

GLM-5.2 is an open-source model served by Sarvam in beta, and is not tuned for Indian languages. Beta access is granted per API key — contact us to request whitelisting. For Indian language workloads use Sarvam-105B instead.

A general-purpose open-source model. Its distinguishing feature on Sarvam is a very large 512K token context window — four times the 128K offered by Sarvam’s own chat models — which makes it a reasonable choice for reasoning over long documents or large codebases in a single request.

At a Glance

Model IDglm5.2
What it doesGeneral-purpose chat LLM; very long context and tool calling
LanguagesNot tuned for Indian languages by Sarvam
APIsOpen-Source Models API Reference (POST /v2/chat/completions, OpenAI-compatible, streaming supported) — also see using an open-source model
Input limits524,288-token context window; 10 MB request cap — all limits
BenchmarksNone published by Sarvam
Pricing₹128.1 input · ₹23.79 cached input · ₹402.6 output — per 1M tokens; reasoning billed as output (Pricing)
Best forLong-document and large-codebase analysis in a single request
Not forIndian language workloads — use Sarvam-105B

Why you might use it

Very long context

A 524,288 token context window lets you pass entire books, long transcripts, or large code repositories in one request without chunking or retrieval.

Tool calling

Supports the OpenAI-compatible tools and tool_choice parameters, so it works with agentic loops and function-calling frameworks.

Model Specifications

Key Considerations
  • Model ID: glm5.2
  • Context window: 524,288 tokens (512K)
  • Tool calling: supported
  • Image input: not supported — text only
  • Reasoning: always on — the chain-of-thought arrives in a separate reasoning_content field and counts against max_tokens; disable via extra_body (see below)
  • Maximum request size: 10 MB
  • Temperature range: 0 to 2 (unset uses the model’s own default)
  • Top-p range: greater than 0, up to 1
  • Supports streaming and non-streaming responses
  • OpenAI-compatible chat completions format

GLM-5.2 vs Sarvam’s chat model

FeatureGLM-5.2Sarvam-105B
Context window524,288128,000
Tool calling
Image input
Indian language tuningNone23 languages
Best forVery long-context tasksMaximum quality reasoning & agentic workflows

Pick GLM-5.2 only when your task genuinely needs more than 128K of context. For everything else — and especially for anything touching Indian languages — a Sarvam model will serve you better and comes with Sarvam’s own evaluation behind it.

Key Capabilities

A single-turn request. Only the model field differs from a Sarvam chat completion call.

1from sarvamai import SarvamAI
2
3client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
4
5response = client.open_source_models.chat_completions_v2(
6 model="glm5.2",
7 messages=[
8 {"role": "user", "content": "Explain the difference between a B-tree and a B+ tree index."}
9 ],
10 temperature=0.2,
11 top_p=1,
12 max_tokens=2000,
13)
14
15print(response.choices[0].message.content)

The answer is in message.content. The model’s chain-of-thought arrives separately in message.reasoning_content — see Reasoning below for how to budget for it or turn it off.

Reasoning

GLM-5.2 thinks before every answer — by default, not only when reasoning_effort is set. The chain-of-thought arrives in a separate reasoning_content field on the message (delta.reasoning_content when streaming); content carries only the final answer. Two practical consequences:

  • Reasoning tokens are billed and count against max_tokens. A small budget can be consumed entirely by reasoning, returning content: null with finish_reason: "length". If your answers come back empty, raise max_tokens or turn thinking off.
  • Turn thinking off when you set response_format. With reasoning active, a JSON-constrained request returns content: null instead of JSON.

The off-switch goes through extra_body:

1{
2 "model": "glm5.2",
3 "messages": [{ "role": "user", "content": "..." }],
4 "extra_body": {
5 "chat_template_kwargs": { "enable_thinking": false }
6 }
7}

With thinking off, responses are faster, the whole max_tokens budget goes to the answer, and Structured Outputs work reliably.

Parameters

GLM-5.2 accepts the standard OpenAI-compatible parameter set — temperature, top_p, max_tokens, stream, stop, n, seed, frequency_penalty, presence_penalty, reasoning_effort, response_format (Structured Outputs), tools, tool_choice, and extra_body. See the full parameter table for types, defaults, and ranges.

Model-specific exceptions:

  • image_url content parts are rejected (400) — GLM-5.2 is text only.
  • response_format requires thinking off — see Reasoning above.
  • seed is not currently reproducible on this model — identical seeds return different completions. Use temperature: 0 where you need stability.

Limits and errors

Common errors for every model on /v2/chat/completions are documented on the Open-Source Models overview. GLM-5.2-specific cases:

ConditionStatusCodeWhat it means
API key lacks beta access400invalid_request_errorRequest whitelisting — see Beta APIs.
Missing or invalid API key403invalid_api_key_errorCheck the api-subscription-key header.
No credits remaining402insufficient_quota_errorTop up on the dashboard.
Unknown or unavailable model id404not_found_errorConfirm the id with GET /v2/models.
Message contains an image part400invalid_request_errorGLM-5.2 is text only. Use gemma4 for image input.
max_tokens above 524,288400invalid_request_errormax_tokens cannot exceed the context window.
Estimated prompt tokens + max_tokens above 524,288422unprocessable_entity_errorShorten the prompt or lower max_tokens.
Request body above the model’s size cap413invalid_request_errorThe byte cap is independent of the token window.
tool_choice naming a function with no tools422unprocessable_entity_errorProvide the tools array alongside tool_choice.
Invalid tool schema ($ref, recursion, size)400invalid_request_errorSee Tool schemas.
Rate limit exceeded429rate_limit_exceeded_errorBack off and retry; see Rate Limits.
Model overloaded after retries503model_overloadedRetry later.
content: null with finish_reason: "length"200Reasoning consumed the whole max_tokens budget — raise it, or turn thinking off. See Reasoning.
content: null with finish_reason: "stop" and response_format set200Thinking + Structured Outputs conflict — turn thinking off. See Reasoning.

Support

Sarvam supports the serving layer — auth, billing, rate limits, availability. Sarvam does not tune or evaluate this model, so its output quality, reasoning, and language coverage are properties of the model itself. See Open-Source Models for the full support boundary, and Talk to us for serving issues.