Skip to content

Instantly share code, notes, and snippets.

@duyet
Last active December 23, 2025 06:00
Show Gist options
  • Select an option

  • Save duyet/ad5971afe423cf992f519aa8a2ea10d5 to your computer and use it in GitHub Desktop.

Select an option

Save duyet/ad5971afe423cf992f519aa8a2ea10d5 to your computer and use it in GitHub Desktop.
Wrapper script to run Claude Code with custom Z.AI environment
#!/usr/bin/env bash
# File: z_claude
# Wrapper script to run Claude Code with custom Z.AI environment
# ---- CONFIG ----
ZAI_API_KEY="${ZAI_API_KEY:-your_zai_api_key_here}"
ZAI_BASE_URL="https://api.z.ai/api/anthropic"
# Optional: override models (comment out if not needed)
MODEL_HAIKU="glm-4.7"
MODEL_SONNET="glm-4.7"
MODEL_OPUS="glm-4.7"
# ---- SET ENV ----
export ANTHROPIC_AUTH_TOKEN="$ZAI_API_KEY"
export ANTHROPIC_BASE_URL="$ZAI_BASE_URL"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="$MODEL_HAIKU"
export ANTHROPIC_DEFAULT_SONNET_MODEL="$MODEL_SONNET"
export ANTHROPIC_DEFAULT_OPUS_MODEL="$MODEL_OPUS"
export API_TIMEOUT_MS=3000000
# ---- RUN CLAUDE ----
echo "⚡ Running Claude Code with Z.AI config..."
echo "Base URL: $ANTHROPIC_BASE_URL"
echo "Model Haiku: $MODEL_HAIKU | Model Sonnet: $MODEL_SONNET | Model Opus: $MODEL_OPUS"
echo
# Pass along any args
claude --dangerously-skip-permissions "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment