GLM-5.2 is live on RouterBase. If you already use the OpenAI Python SDK, you do not need another client library. Keep the SDK, change the base URL, and use the exact live model ID.
Prerequisites
- Python 3.9 or later
- A RouterBase API key stored as
ROUTERBASE_API_KEY - The current
openaipackage
pip install openai
Make the call
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ROUTERBASE_API_KEY"],
base_url="https://routerbase.com/v1",
)
response = client.chat.completions.create(
model="zai/glm-5-2/chat",
messages=[
{
"role": "system",
"content": "You are a careful software engineering assistant.",
},
{
"role": "user",
"content": "Give me a five-point review checklist for a risky database migration.",
},
],
max_tokens=800,
)
print(response.choices[0].message.content)
The two RouterBase-specific values are:
base_url = https://routerbase.com/v1
model = zai/glm-5-2/chat
Do not shorten the model name to glm-5.2. RouterBase's live model page currently exposes the full ID zai/glm-5-2/chat, and exact IDs prevent an integration from silently pointing at the wrong route.
Before sending a million-token prompt
Z.ai documents a 1M-token context window for GLM-5.2. That is a ceiling, not a recommended starting prompt.
Start with a smaller baseline, then increase context while recording:
- Time to first token and total wall-clock time.
- Whether the answer uses the right evidence from the prompt.
- Tool-call failures and retry behavior.
- Whether tool state survives a long, multi-step run.
- Cost per successful task, not only cost per token.
A longer context window reduces some chunking pressure, but it does not replace retrieval tests, observability, or a fallback path.
Scope and limitations
This quickstart verifies the current RouterBase base URL and model ID. It does not claim a benchmark ranking, a latency target, or a fixed price. Those values can change, so check the live model page before a production rollout.
Top comments (0)