Integrate official Z.AI GLM configuration into automation scripts
- Add GLM model mappings (glm-4.5-air, glm-4.7) to settings.json - Update both new and existing file creation paths - Add version verification guidance (2.0.14+ recommended) - Reference official Z.AI documentation (https://docs.z.ai/devpack/tool/claude) - Add troubleshooting steps from official docs - Add /status command verification instructions - Display GLM configuration summary after setup - Update API help text to include official docs link
This commit is contained in:
@@ -640,7 +640,7 @@ install_settings() {
|
||||
if [ "$USE_ZAI_MODELS" = true ]; then
|
||||
API_BASE="https://api.z.ai/api/anthropic"
|
||||
API_NAME="Z.AI / GLM Coding Plan"
|
||||
API_HELP="Get your API key from: https://open.bigmodel.cn/usercenter/apikeys"
|
||||
API_HELP="Get your API key from: https://z.ai/ (Official docs: https://docs.z.ai/devpack/tool/claude)"
|
||||
API_TOKEN_NAME="Z.AI API Key"
|
||||
else
|
||||
API_BASE="https://api.anthropic.com"
|
||||
@@ -672,6 +672,22 @@ install_settings() {
|
||||
done
|
||||
|
||||
# Update existing file
|
||||
if [ "$USE_ZAI_MODELS" = true ]; then
|
||||
cat > "$settings_file" << EOF
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_AUTH_TOKEN": "$API_TOKEN",
|
||||
"ANTHROPIC_BASE_URL": "$API_BASE",
|
||||
"API_TIMEOUT_MS": "3000000",
|
||||
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
|
||||
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
|
||||
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
|
||||
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7"
|
||||
},
|
||||
"enabledPlugins": {}
|
||||
}
|
||||
EOF
|
||||
else
|
||||
cat > "$settings_file" << EOF
|
||||
{
|
||||
"env": {
|
||||
@@ -683,6 +699,7 @@ install_settings() {
|
||||
"enabledPlugins": {}
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
log_success "API token updated"
|
||||
fi
|
||||
else
|
||||
@@ -692,6 +709,22 @@ EOF
|
||||
read -p "Enter your $API_TOKEN_NAME: " API_TOKEN
|
||||
done
|
||||
|
||||
if [ "$USE_ZAI_MODELS" = true ]; then
|
||||
cat > "$settings_file" << EOF
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_AUTH_TOKEN": "$API_TOKEN",
|
||||
"ANTHROPIC_BASE_URL": "$API_BASE",
|
||||
"API_TIMEOUT_MS": "3000000",
|
||||
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
|
||||
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
|
||||
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
|
||||
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7"
|
||||
},
|
||||
"enabledPlugins": {}
|
||||
}
|
||||
EOF
|
||||
else
|
||||
cat > "$settings_file" << EOF
|
||||
{
|
||||
"env": {
|
||||
@@ -703,6 +736,7 @@ EOF
|
||||
"enabledPlugins": {}
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
log_success "API token configured"
|
||||
fi
|
||||
|
||||
@@ -722,6 +756,32 @@ EOF
|
||||
fi
|
||||
|
||||
log_success "Settings configured for $API_NAME"
|
||||
|
||||
# Version verification and Z.AI documentation reference
|
||||
if [ "$USE_ZAI_MODELS" = true ]; then
|
||||
echo ""
|
||||
echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${BOLD}Z.AI GLM Configuration${NC}"
|
||||
echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ GLM Models Configured:${NC}"
|
||||
echo " • glm-4.5-air (Haiku equivalent - fast, efficient)"
|
||||
echo " • glm-4.7 (Sonnet/Opus equivalent - high quality)"
|
||||
echo ""
|
||||
echo -e "${YELLOW}📖 Official Documentation:${NC}"
|
||||
echo " https://docs.z.ai/devpack/tool/claude"
|
||||
echo ""
|
||||
echo -e "${YELLOW}🔍 Verify Installation:${NC}"
|
||||
echo " 1. Check version: ${CYAN}claude --version${NC} (recommended: 2.0.14+)"
|
||||
echo " 2. Start Claude: ${CYAN}claude${NC}"
|
||||
echo " 3. Check status: ${CYAN}/status${NC} (when prompted)"
|
||||
echo ""
|
||||
echo -e "${YELLOW}🔧 Troubleshooting:${NC}"
|
||||
echo " • Close all Claude Code windows and reopen"
|
||||
echo " • Or delete ~/.claude/settings.json and reconfigure"
|
||||
echo " • Verify JSON format is correct (no missing/extra commas)"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
install_local_settings() {
|
||||
|
||||
Reference in New Issue
Block a user