# Launcher to run GLM 5.2 in Claude Code harness

> Source: <https://gist.github.com/phase3dev/b7c341d63f666479be0aff847a5bd018>
> Published: 2026-06-24 03:17:16+00:00

| #!/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 "$@" |
