{"slug": "launcher-to-run-glm-5-2-in-claude-code-harness", "title": "Launcher to run GLM 5.2 in Claude Code harness", "summary": "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.", "body_md": "| #!/usr/bin/env bash | |\n| set -euo pipefail | |\n| # --- Your GLM API key, kept OUT of this script ----------------------------- | |\n| # Put the key in a private file once (readable only by you), and this launcher | |\n| # loads it at runtime. That way the key never lives in this script, so you can | |\n| # copy, share, or post the launcher without leaking it. | |\n| # mkdir -p ~/.config/glm | |\n| # printf '%s\\n' 'YOUR_ZAI_API_KEY' > ~/.config/glm/api_key | |\n| # chmod 600 ~/.config/glm/api_key # 0600 = only you can read it | |\n| KEY_FILE=\"${HOME}/.config/glm/api_key\" | |\n| [[ -r \"$KEY_FILE\" ]] || { echo \"claude-glm: missing $KEY_FILE (see comment above)\" >&2; exit 1; } | |\n| # --- Connection --- | |\n| export ANTHROPIC_BASE_URL=\"https://api.z.ai/api/anthropic\" | |\n| export ANTHROPIC_AUTH_TOKEN=\"$(< \"$KEY_FILE\")\" | |\n| # --- Model mapping --- | |\n| export ANTHROPIC_MODEL=\"glm-5.2\" | |\n| export ANTHROPIC_DEFAULT_OPUS_MODEL=\"glm-5.2\" | |\n| export ANTHROPIC_DEFAULT_SONNET_MODEL=\"glm-5.2\" | |\n| export ANTHROPIC_DEFAULT_HAIKU_MODEL=\"glm-5.2\" | |\n| export CLAUDE_CODE_SUBAGENT_MODEL=\"glm-5.2\" | |\n| # --- Separate config dir so this runs next to a normal `claude` ------------ | |\n| # Claude Code keeps its auth, settings, and chat history under one directory | |\n| # (default: ~/.claude). Giving GLM its own directory lets you run `claude` and | |\n| # `claude-glm` at the same time, even in the same folder, without the two | |\n| # sessions sharing state. Change the path, or delete this line to share ~/.claude. | |\n| export CLAUDE_CONFIG_DIR=\"${HOME}/.claude-glm\" | |\n| # Path to your real claude binary (find yours with: command -v claude). | |\n| exec \"${HOME}/.local/bin/claude\" --bare \"$@\" |", "url": "https://wpnews.pro/news/launcher-to-run-glm-5-2-in-claude-code-harness", "canonical_source": "https://gist.github.com/phase3dev/b7c341d63f666479be0aff847a5bd018", "published_at": "2026-06-24 03:17:16+00:00", "updated_at": "2026-06-25 23:03:20.702297+00:00", "lang": "en", "topics": ["large-language-models", "developer-tools"], "entities": ["GLM 5.2", "Claude Code", "Anthropic", "Z.AI"], "alternates": {"html": "https://wpnews.pro/news/launcher-to-run-glm-5-2-in-claude-code-harness", "markdown": "https://wpnews.pro/news/launcher-to-run-glm-5-2-in-claude-code-harness.md", "text": "https://wpnews.pro/news/launcher-to-run-glm-5-2-in-claude-code-harness.txt", "jsonld": "https://wpnews.pro/news/launcher-to-run-glm-5-2-in-claude-code-harness.jsonld"}}