Skip to content

Conversation

@Zorglub4242
Copy link

@Zorglub4242 Zorglub4242 commented Jan 18, 2026

Summary

Add support for GLM (z.ai / BigModel.cn) API through a new happy zai subcommand, similar to existing happy gemini and happy codex commands.

What It Does

  • happy zai - Start Claude with GLM API endpoint (redirects to https://open.bigmodel.cn/api/anthropic)
  • happy zai token set <key> - Save GLM API key to ~/.zai/config.json
  • happy zai token get - Show current API token
  • happy zai model set <model> - Set GLM model (glm-4.7, glm-4-plus, glm-4-flash, glm-4-air, glm-4-flashx)
  • happy zai model get - Show current model
  • happy zai base-url set <url> - Set custom API endpoint

How It Works

GLM is Anthropic-compatible, so this implementation sets environment variables before launching Claude:

  • ANTHROPIC_BASE_URLhttps://open.bigmodel.cn/api/anthropic
  • ANTHROPIC_AUTH_TOKEN → GLM API key
  • ANTHROPIC_MODEL → glm-4.7 (or specified model)

Configuration is stored in ~/.zai/config.json with support for environment variable overrides (ZAI_AUTH_TOKEN, ZAI_BASE_URL, ZAI_MODEL).

Files Changed

  • src/zai/runZai.ts - New module for Z.AI/GLM support
  • src/index.ts - Added zai subcommand handler with config subcommands

Usage Example

# Set API key
happy zai token set your-glm-api-key

# Start using GLM
happy zai

Add support for GLM (z.ai / BigModel.cn) API through a new `happy zai`
subcommand, similar to existing `happy gemini` and `happy codex` commands.

Features:
- `happy zai` - Start Claude with GLM API endpoint
- `happy zai token set <key>` - Save GLM API key to ~/.zai/config.json
- `happy zai token get` - Show current API token
- `happy zai model set <model>` - Set GLM model (glm-4.7, glm-4-plus, etc.)
- `happy zai model get` - Show current model
- `happy zai base-url set <url>` - Set custom API endpoint

Configuration is stored in ~/.zai/config.json with support for
environment variable overrides (ZAI_AUTH_TOKEN, ZAI_BASE_URL, ZAI_MODEL).

Co-Authored-By: Claude <noreply@anthropic.com>
Fix argument passing for `happy zai` so that flags like `--yolo`,
`--resume`, `--dangerously-skip-permissions` etc. are properly
passed through to the underlying claude command.

- Add claudeArgs parameter to runZai function
- Parse and collect unknown arguments in zai subcommand handler
- Pass claudeArgs through to runClaude

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant