How to use Z.AI GLM models with OpenClaw
I know how it feels to get stuck in configuration loops. You find a model you want to try, but then you have to figure out the specific API format and authentication method for yet another provider. It takes the fun out of building when the setup is more work than the actual project.
If you want to use GLM models through Z.AI, I recommend following this path. It keeps your keys organized and gets the models running in a few minutes.
What You’ll Need
Section titled “What You’ll Need”- A Z.AI API key created in the Z.AI console.
- OpenClaw installed on your system.
Quick Start
Section titled “Quick Start”You can set this up using the CLI or by updating your config file manually.
1. Configure the CLI
Section titled “1. Configure the CLI”Run the onboarding command to link your account. You can do this interactively:
openclaw onboard --auth-choice zai-api-keyOr use the non-interactive version if you have your key ready:
openclaw onboard --zai-api-key "$ZAI_API_KEY"2. Update your config
Section titled “2. Update your config”Add the zai provider to your configuration file. Here is the snippet you need to set GLM as your primary model:
{ env: { ZAI_API_KEY: "sk-..." }, agents: { defaults: { model: { primary: "zai/glm-4.7" } } },}Troubleshooting
Section titled “Troubleshooting”If you run into issues, check these common points:
- Authentication errors: Z.AI uses Bearer auth. Make sure your API key is active in the Z.AI console and correctly copied into your environment settings.
- Model naming: GLM models must be called with the
zai/prefix. For example, usezai/glm-4.7to ensure the provider is recognized.
If you still have questions, talk to the AI Setup Assistant.
What’s Next
Section titled “What’s Next”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.