Use GLM 5.2 with Claude Code
Claude Code doesn’t require a Claude model: it works with any backend that speaks the Anthropic Messages API. CheapestInference exposes GLM 5.2 through an Anthropic-compatible endpoint, so you can run Claude Code on GLM with unlimited usage during your reserved time blocks — a flat monthly fee instead of per-token billing.
Setup (2 minutes)
Section titled “Setup (2 minutes)”- Subscribe to the Frontier Pool and
copy your subscriber key (
sk-...) from the dashboard. - Export these variables in your shell (or put them in your shell profile):
export ANTHROPIC_BASE_URL="https://api.cheapestinference.com/anthropic"export ANTHROPIC_AUTH_TOKEN="sk-..." # your subscriber keyexport ANTHROPIC_MODEL="glm-5.2"export ANTHROPIC_SMALL_FAST_MODEL="glm-5.2"export CLAUDE_CODE_AUTO_COMPACT_WINDOW=198000 # GLM 5.2's 198K window- Start
claudeas usual. Every request now runs on GLM 5.2.
Why GLM 5.2 for Claude Code
Section titled “Why GLM 5.2 for Claude Code”- Built for coding and agentic work: GLM 5.2 is Zhipu’s frontier coding model — strong on multi-step tool use, exactly what Claude Code exercises.
- Flat price: coding agents are token-hungry; a long Claude Code session can burn millions of tokens. During your time blocks there is no per-token meter — see Unlimited Subscriptions.
- Thinking blocks: GLM’s reasoning surfaces through standard Anthropic
thinkingcontent blocks, so Claude Code renders it natively. See Reasoning for toggling it. - 198K context: set
CLAUDE_CODE_AUTO_COMPACT_WINDOW=198000(as above) so Claude Code compacts the session before hitting the window instead of erroring mid-task.
Per-project configuration
Section titled “Per-project configuration”Pin one project to GLM without touching your global shell profile with
.claude/settings.json in the project:
{ "env": { "ANTHROPIC_BASE_URL": "https://api.cheapestinference.com/anthropic", "ANTHROPIC_AUTH_TOKEN": "sk-...", "ANTHROPIC_MODEL": "glm-5.2", "ANTHROPIC_SMALL_FAST_MODEL": "glm-5.2", "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "198000" }}Can Claude Code use GLM?
Section titled “Can Claude Code use GLM?”Yes. Claude Code talks to any endpoint that implements the Anthropic Messages
API. Point ANTHROPIC_BASE_URL at
https://api.cheapestinference.com/anthropic, set ANTHROPIC_MODEL to
glm-5.2, and Claude Code runs on GLM — tool calls, streaming and thinking
blocks included. No plugin or proxy on your machine.
How does GLM 5.2 compare to Claude for coding agents?
Section titled “How does GLM 5.2 compare to Claude for coding agents?”GLM 5.2 is one of the strongest open-weights coding models and holds its own on multi-step agentic work; frontier closed models still lead on the hardest tasks. The practical difference is economics: a heavy Claude Code month on a per-token API bills every token, while a Frontier Pool subscription is a flat fee — see the numbers in the LLM API pricing comparison.
What does it cost to run Claude Code on GLM?
Section titled “What does it cost to run Claude Code on GLM?”A flat monthly subscription to the Frontier Pool — see current prices. Usage during your reserved time blocks is unlimited, so a heavy week costs the same as a light one.
- Your Frontier Pool subscription also covers
MiniMax M3 with its 1M window — switch models by
changing
ANTHROPIC_MODEL, no new key needed. - Lighter and cheaper: DeepSeek V4 Flash (Core Pool). Heavier: Kimi K3 (Flagship Pool).
- General setup, model table and troubleshooting: the main Claude Code guide.