The official GLM-5.2 migration checklist and parameter configuration: change the model ID to glm-5.2; use the default temperature of 1.0 or default top_p of 0.95 (tune only one of the two); enable thinking by default; use high or max for reasoning_effort; configure streaming and streaming tool calls (stream=true + tool_stream=true) as specified by the official guidance; and use the included Python migration example directly.
Suitable tasks: Migrating existing applications from GLM-5.1, GLM-5, GLM-4.7/4.6/4.5, and other older models to GLM-5.2; Agent or coding products that need streaming output, streaming tool calls, or access to thinking content; and backend integrations that need explicit sampling parameters and thinking levels.
Unsuitable tasks: Legacy logic that relies on "turning off thinking to save tokens" (thinking is enabled by default in GLM-5.2, so use reasoning_effort to control cost instead); assumptions from the GLM-4.7 era that thinking is "forced" (GLM-5.2 automatically determines whether thinking is needed).
Applicable model version: GLM-5.2 (the parameters in this note also apply to the GLM-5.1/GLM-5 series, with the same default thinking behavior).
Applicable client, Agent, or API: Z.ai Chat Completions API (OpenAI-compatible); streaming clients that use delta.reasoning_content / delta.content / delta.tool_calls.
Recommended reasoning levels and parameters: thinking: {"type": "enabled"} (recommended for complex reasoning/coding); reasoning_effort: high (enhanced reasoning) or max (deep reasoning, default); tune only one of temperature and top_p; set max_tokens according to the task (maximum 128K).
Change the model identifier to glm-5.2
Sampling parameters: temperature defaults to 1.0 and top_p defaults to 0.95; tuning only one is recommended
Deep thinking: use thinking={"type": "enabled"} as needed for complex reasoning/coding
Reasoning level: choose between high (enhanced reasoning) and max (deep reasoning, default) for reasoning_effort
Streaming response: stream=true; correctly process delta.reasoning_content and delta.content
Streaming tool calls: stream=true + tool_stream=true; concatenate delta.tool_calls[*].function.arguments across chunks
Maximum output and context: set max_tokens as needed (GLM-5.2 supports up to 128K output and 1M context)
Prompt optimization: use clearer instructions and constraints together with deep thinking
Development environment validation: regression tests should focus on randomness, latency, and the completeness of streaming tool parameters
# Plan A: Use temperature (recommended)
resp = client.chat.completions.create(
model="glm-5.2",
messages=[{"role": "user", "content": "Write a more creative brand introduction"}],
temperature=1.0
)
# Plan B: Use top_p
resp = client.chat.completions.create(
model="glm-5.2",
messages=[{"role": "user", "content": "Generate more stable technical documentation"}],
top_p=0.8
)resp = client.chat.completions.create(
model="glm-5.2",
messages=[{"role": "user", "content": "Design a three-tier microservice architecture for me"}],
thinking={"type": "enabled"},
reasoning_effort="max"
)response = client.chat.completions.create(
model="glm-5.2",
messages=[{"role": "user", "content": "How's the weather in Beijing"}],
tools=[
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather conditions for a specified location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City, eg: Beijing, Shanghai"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
}
],
stream=True,
tool_stream=True,
)
# Initialize streaming collection variables
reasoning_content = ""
content = ""
final_tool_calls = {}
reasoning_started = False
content_started = False
# Process streaming response
for chunk in response:
if not chunk.choices:
continue
delta = chunk.choices[0].delta
# Streaming reasoning process output
if hasattr(delta, 'reasoning_content') and delta.reasoning_content:
if not reasoning_started and delta.reasoning_content.strip():
print("\n🧠 Thinking Process:")
reasoning_started = True
reasoning_content += delta.reasoning_content
print(delta.reasoning_content, end="", flush=True)
# Streaming answer content output
if hasattr(delta, 'content') and delta.content:
if not content_started and delta.content.strip():
print("\n\n💬 Answer Content:")
content_started = True
content += delta.content
print(delta.content, end="", flush=True)
# Streaming tool call information (parameter concatenation)
if delta.tool_calls:
for tool_call in delta.tool_calls:
idx = tool_call.index
if idx not in final_tool_calls:
final_tool_calls[idx] = tool_call
final_tool_calls[idx].function.arguments = tool_call.function.arguments
else:
final_tool_calls[idx].function.arguments += tool_call.function.arguments
# Output final tool call information
if final_tool_calls:
print("\n📋 Function Calls Triggered:")
for idx, tool_call in final_tool_calls.items():
print(f" {idx}: Function Name: {tool_call.function.name}, Parameters: {tool_call.function.arguments}")Maximum context: 1M; maximum output: 128K.
Added streaming output for the tool-calling process (tool_stream=true), allowing tool-call parameters to be received in real time.
Deep thinking thinking={"type":"enabled"}: once enabled, the model automatically determines whether to think (unlike GLM-4.7's forced thinking).
Added the reasoning_effort parameter to control the thinking level.
Stronger coding and reasoning capabilities.
The official source describes "deep thinking enabled by default": thinking is activated by default in the GLM-5.2/5.1/5/4.7 series (see the thinking-mode documentation), unlike the default hybrid-thinking behavior of GLM-4.6.
Post-migration regression priorities: whether output randomness is excessive or overly conservative, whether streaming tool-call concatenation works correctly, and latency and cost under long contexts and deep thinking.
GLM-5.2