Using z.ai with Claude Code for Cheaper
Claude Code is my tool of choice for AI coding. I wrote about using Claude Code here.
Part of why it’s great is the agentic nature of it along with how Claude Opus (the model) supports that.
There’s now z.ai which provides a model (currently GLM-4.5) and compatible endpoint so that you can use it from within Claude Code. It lets you do quite a bit; the thing is, compared to Claude Max which costs ~$100/month or ~$200/month, the GLM Coding plans only cost $3/month and $15/month. It’s a steal if you can get it to work for you.
The big catch is it doesn’t support images. While it works in their Chat, dropping images via drag and drop or a filename or absolute filepath doesn’t work in Claude Code.
Set up is easy and it’s relatively cheap, so it’s worth trying. Check the official docs, but it’s easy:
- Get an API key
- I use fish shell, so I run:
ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic ANTHROPIC_AUTH_TOKEN=<API TOKEN> claude
You don’t need to set ANTHROPIC_MODEL
in ~/.claude/settings.json
.
In Claude Code, if you get errors after sending any prompts, run /logout with just claude
first and then run claude
with env set again.