cd /news/large-language-models/launcher-to-run-glm-5-2-in-claude-co… · home topics large-language-models article
[ARTICLE · art-40073] src=gist.github.com ↗ pub= topic=large-language-models verified=true sentiment=· neutral

Launcher to run GLM 5.2 in Claude Code harness

A developer created a launcher script to run GLM 5.2 in the Claude Code harness, enabling the use of the GLM model via Anthropic's API. The script loads the API key from a private file, sets environment variables for the model and base URL, and uses a separate config directory to avoid state conflicts with the standard Claude installation.

read1 min views25 publishedJun 24, 2026

| #!/usr/bin/env bash | | | set -euo pipefail | | | # --- Your GLM API key, kept OUT of this script ----------------------------- | | | # Put the key in a private file once (readable only by you), and this launcher | | | # loads it at runtime. That way the key never lives in this script, so you can | | | # copy, share, or post the launcher without leaking it. | | | # mkdir -p ~/.config/glm | | | # printf '%s\n' 'YOUR_ZAI_API_KEY' > ~/.config/glm/api_key | | | # chmod 600 ~/.config/glm/api_key # 0600 = only you can read it | |

| KEY_FILE="${HOME}/.config/glm/api_key" | |
| [[ -r "$KEY_FILE" ]] || { echo "claude-glm: missing $KEY_FILE (see comment above)" >&2; exit 1; } | |
| # --- Connection --- | |

| export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic" | |

| export ANTHROPIC_AUTH_TOKEN="$(< "$KEY_FILE")" | |
| # --- Model mapping --- | |
| export ANTHROPIC_MODEL="glm-5.2" | |

| export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-5.2" | | | export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-5.2" | | | export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.2" | | | export CLAUDE_CODE_SUBAGENT_MODEL="glm-5.2" | | | # --- Separate config dir so this runs next to a normal claude ------------ | | | # Claude Code keeps its auth, settings, and chat history under one directory | | | # (default: ~/.claude). Giving GLM its own directory lets you run claude and | | | # claude-glm at the same time, even in the same folder, without the two | | | # sessions sharing state. Change the path, or delete this line to share ~/.claude. | |

| export CLAUDE_CONFIG_DIR="${HOME}/.claude-glm" | |
| # Path to your real claude binary (find yours with: command -v claude). | |
| exec "${HOME}/.local/bin/claude" --bare "$@" |
── more in #large-language-models 4 stories · sorted by recency
── more on @glm 5.2 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/launcher-to-run-glm-…] indexed:0 read:1min 2026-06-24 ·