Using z.ai with Claude Code for Cheaper

Boon aka Hwee-Boon Yar September 7, 2025
Source

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. I also wrote about my complete agentic coding setup.

There's now Z.ai, which provides a model (currently GLM-4.6) and an Anthropic-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 $6/month (Lite), $30/month (Pro), $60/month (Max). It's a steal if you can get it to work for you.

The model itself (as of GLM-4.6) is not multimodal — it doesn't support images; it has support for reading images via an MCP. This is only available with Pro and Max plans.

USE Z.AI'S ANTHROPIC ENDPOINT

Set up is easy and it's relatively cheap, so it's worth trying. Check the official docs, but this is the whole setup:

  1. Get an API key
  2. I use fish shell, so I run: ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic ANTHROPIC_AUTH_TOKEN= claude
  3. (optional) if you have access to the image reading MCP, do: claude mcp add -s user zai-mcp-server --env Z_AI_API_KEY= Z_AI_MODE=ZAI -- npx -y "@z_ai/mcp-server"

You don't need to set ANTHROPIC_MODEL (or anything) 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.

I keep this as a separate command instead of changing my normal Claude Code setup:

function claude-zai ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
ANTHROPIC_AUTH_TOKEN=$Z_AI_API_KEY
claude $argv end

That lets me run claude-zai when I want Z.ai and plain claude when I want Claude Max. It also makes it obvious which provider I am paying for in that terminal session.

Z.AI VS CLAUDE CODE DIRECTLY

I still prefer Claude Code with Claude Max for serious work. The model quality and tool behavior are more predictable.

Z.ai is useful when I want a cheaper coding model to kick the tires on a task, or when I want to keep paid provider calls down. The tradeoff is that I treat it as a separate mode. I don't expect it to behave exactly like Claude through Anthropic's own endpoint.

The practical differences I watch:

  • model quality on larger refactors
  • image support through MCP instead of native multimodal input
  • whether CLI behavior changes after authentication
  • how often I need to fall back to Claude Max

The biggest practical check is whether the task needs screenshots or UI inspection. If it does, I either use the MCP image path or switch back to Claude Max. For text-only code cleanup, small refactors, and quick experiments, z.ai is good enough often enough that the cheaper plan is worth keeping around.

If you want to try it out, consider my referral link for a 10% discount.

Discussion in the ATmosphere

Loading comments...