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