Skip to main content

Z.ai

Use this when your team already runs on Z.ai and you want that vendor family to stay explicit in Loong config instead of disappearing behind a generic compatibility route.

At A Glance

FieldValue
Built-in kindzai
Provider groupDirect Hosted Providers
Protocol familyopenai_chat_completions
Feature familyopenai_compatible
Auth schemebearer
Credential envsZAI_API_KEY
Aliaseszai_compatible, z.ai
Default base URLhttps://api.z.ai
Request endpointhttps://api.z.ai/api/paas/v4/chat/completions
Models endpointhttps://api.z.ai/api/paas/v4/models

Minimal Config

active_provider = "zai"

[providers.zai]
kind = "zai"
api_key = { env = "ZAI_API_KEY" }
model = "auto"

Verify It

loong doctor
loong list-models
loong ask --message "Say hello and name the active provider."
If list-models is unreliable for this account or region, pin an explicit provider.model or add preferred_models instead of leaving recovery implicit.

Auth And Routing Contract

ContractValue
Auth optionalno
Model probe auth optionalno
Default API key envZAI_API_KEY
OAuth envnone
Primary request routehttps://api.z.ai/api/paas/v4/chat/completions
Primary model-catalog routehttps://api.z.ai/api/paas/v4/models

Region Endpoints

VariantBase URL
Globalhttps://api.z.ai
CNhttps://open.bigmodel.cn
Z.ai / BigModel region endpoint: Global default (https://api.z.ai); switch provider.base_url to https://open.bigmodel.cn for CN accounts