On this page
To call GLM from Python, you need a Z.ai API key, a compatible model identifier, and the endpoint for your entitlement. A subscription that works in a coding client does not establish access to the standard API.
This guide compares Z.ai’s general quickstart with the GLM-5.3 model-specific instructions, rechecked November 8, 2026. We have not executed a billable request or measured model quality. The goal is a verifiable connection, not a claim that GLM is the best model for your project.
Pick the API before installing a client
The general quickstart and model-specific instructions can expose different routes. As checked November 8, the GLM-5.3 page lists https://api.z.ai/api/coding/paas/v4 for OpenAI Chat Completions, alongside separate Responses and Anthropic routes. It also describes account-history restrictions for current or former Coding Plan subscribers. Do not assume that a general API endpoint is valid for every model and entitlement.
For this Chat Completions example, copy the base URL for your exact model and entitlement from its current documentation. Do not supply a Responses base URL to a Chat Completions client. GLM-5.3 requires reasoning enabled; this example requests low effort for a small connection check.
Record three non-secret values before proceeding: the console you used, the entitlement name, and the selected model ID. Keep the key itself out of this note. A headline about a model release is not an API configuration.
Build the smallest useful request
Create a fresh Python virtual environment and install openai with python -m pip install openai. Save this as glm_connection.py and run it with that environment’s Python:
import getpass
from openai import OpenAI
base = input("Verified Chat Completions base URL for your account: ").strip()
if not base.startswith("https://api.z.ai/"):
raise SystemExit("Use the documented Z.ai HTTPS endpoint for this example.")
client = OpenAI(
api_key=getpass.getpass("Z.ai API key: "),
base_url=base,
timeout=60.0,
max_retries=0,
)
result = client.chat.completions.create(
model="glm-5.3",
reasoning_effort="low",
extra_body={"thinking": {"type": "enabled"}},
messages=[{"role": "user", "content": (
"Return only these three words, in order: cedar amber linen"
)}],
)
print("Model:", result.model)
print("Answer:", result.choices[0].message.content)
print("Usage:", result.usage)
The prompt is intentionally easy to inspect. A useful result follows the instruction, has nonempty content, and includes a response you can associate with this request. Different wording or extra explanation is a task failure even if the HTTP request succeeded. Usage may incur charges; check your console rather than assuming a free allowance.
max_retries=0 makes one attempted call easier to account for while debugging. It is not a production resilience policy. A production integration needs bounded retries, request tracking, and a decision about which failures are safe to retry.
Diagnose the layer that failed
| Symptom | First check |
|---|---|
| Authentication rejected | Key origin, entitlement, and base URL belong together |
| Model unavailable | Exact model ID and permissions in your console |
| Connection timeout | Network reachability and service status before changing prompts |
| Successful response, unusable answer | Message content and task requirements, not credentials |
Do not copy a mainland Zhipu endpoint or a third-party hosting URL into this Z.ai example. They may expose related model families while using different accounts, billing, and identifiers.
Decide what the connection proves
A successful three-word response proves very little about coding or long-document analysis. Next, prepare a small set of your own representative inputs with expected properties. Save the model ID, date, prompt, output, and usage for each run. Compare total workflow success before comparing headline token prices.
If you are still choosing between a hosted API and a local model, our model, app, and API explainer separates those decisions. This connection test should come after that choice, not substitute for it.
Sources & references
Written by Modelrovia Editorial. Our standards distinguish official claims from observed results.
How we research and test →

