{
  "$type": "site.standard.document",
  "description": "How I run Claude Code through Z.ai's Anthropic-compatible endpoint, with the exact environment variables, MCP image support, model notes, and logout fix.",
  "path": "/using-z-ai-with-claude-code-for-cheaper/",
  "publishedAt": "2025-09-07T02:32:00.000Z",
  "site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
  "tags": [
    "Tools",
    "AI"
  ],
  "textContent": "Claude Code is my tool of choice for AI coding. I wrote about using Claude Code here.\n\nPart 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.\n\nThere'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.\n\nThe 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.\n\nUSE Z.AI'S ANTHROPIC ENDPOINT\n\nSet up is easy and it's relatively cheap, so it's worth trying. Check the official docs, but this is the whole setup:\n\n 1. Get an API key\n 2. I use fish shell, so I run: ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic ANTHROPIC_AUTH_TOKEN=<API TOKEN> claude\n 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=<API TOKEN> Z_AI_MODE=ZAI -- npx -y \"@z_ai/mcp-server\"\n\nYou don't need to set ANTHROPIC_MODEL (or anything) in ~/.claude/settings.json.\n\nIn Claude Code, if you get errors after sending any prompts, run /logout with just claude first and then run claude with env set again.\n\nI keep this as a separate command instead of changing my normal Claude Code setup:\n\nfunction claude-zai\n  ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic \\\n    ANTHROPIC_AUTH_TOKEN=$Z_AI_API_KEY \\\n    claude $argv\nend\n\nThat 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.\n\nZ.AI VS CLAUDE CODE DIRECTLY\n\nI still prefer Claude Code with Claude Max for serious work. The model quality and tool behavior are more predictable.\n\nZ.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.\n\nThe practical differences I watch:\n\n * model quality on larger refactors\n * image support through MCP instead of native multimodal input\n * whether CLI behavior changes after authentication\n * how often I need to fall back to Claude Max\n\nThe 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.\n\nIf you want to try it out, consider my referral link for a 10% discount.",
  "title": "Using z.ai with Claude Code for Cheaper",
  "updatedAt": "2026-06-04T00:00:00.000Z"
}