Z.ai (GLM)
Add Z.ai's API as a provider, call GLM models such as glm-5.3 and turn their reasoning on or off.
Connect Z.ai's API using your API key to serve GLM models such as glm-5.3. Adding a provider requires Owner or LLM Gateway Admin on the organization, or on a project for a project-scoped provider.
Add Z.ai
- Create an API key on Z.ai.
- In your organization, click LLM Gateway, then Providers, then Add a provider, then Z.ai under Model providers.
- Paste the key into API key, select which projects can create models with this provider, click Test and click Add provider.
See Add a provider for adding a project provider, sharing and key rotation.
This provider calls Z.ai's general API, so it doesn't use a GLM Coding Plan (which uses a separate endpoint) and doesn't accept keys from Zhipu's China platform (bigmodel.cn).
What kosem uses
- API: Chat Completions at
https://api.z.ai/api/paas/v4. kosem translates calls with Anthropic's Messages or OpenAI's Responses to it. - Type, for the API:
providerTypes/zai, with no settings. - Models to start with:
glm-5.3andglm-5.3-flash. - Prices: Z.ai's list prices, for usage and spend limits.
Reasoning and tool calls
GLM models return their reasoning in reasoning_content and build on reasoning returned in earlier turns.
- Agents and translated calls: kosem passes each model's reasoning back only to that model.
- Direct Chat Completions calls: preserve each full assistant message (including
reasoning_content), such as by appendingresponse.choices[0].message.
thinking turns reasoning on or off on GLM-5.2 and earlier, and GLM-5.2 and later accept reasoning_effort (low, high or max on GLM-5.3; high or max on GLM-5.2). kosem forwards these fields as sent; with OpenAI's SDK, pass thinking in extra_body:
import os
from openai import OpenAI
client = OpenAI(
base_url=f"https://api.kosem.ai/v1/projects/{os.environ['KOSEM_PROJECT']}/llm/openai/v1",
api_key=os.environ["KOSEM_API_KEY"],
)
response = client.chat.completions.create(
model="glm",
messages=[{"role": "user", "content": "Write a commit message for a typo fix."}],
reasoning_effort="low",
)
print(response.choices[0].message.content)If a call fails
| Error | What it means | What to do |
|---|---|---|
400 about tool_choice | GLM models accept only auto | Omit tool_choice, or send auto |
Related
- Add a provider
- Call models from your code
- Compatible servers, to move a GLM model off an OpenAI-compatible provider