A powerful CLI tool and Agent SDK wrapper for seamless management of Z.AI (GLM) and MiniMax API providers. Switch between providers, manage multiple accounts, track usage, rotate API keys, and use with Claude Code or Claude Agent SDK directly from your code.
coding-helper is a developer utility that enables Claude Code users to switch between Z.AI (GLM) and MiniMax API providers without code changes. It provides:
- Provider switching - Toggle between Z.AI and MiniMax instantly
- Multi-account management - Configure and switch between multiple API accounts
- API key rotation - Automatic rotation with configurable strategies
- Usage tracking - Monitor quotas, costs, and consumption in real-time
- Agent SDK integration - Use auto-rotation directly in your code
- Claude Code wrapper - Spawn Claude with automatic provider switching
| Feature | Description |
|---|---|
| Unified CLI | Configure and switch providers with simple commands |
| Interactive Setup | Guided configuration wizard |
| Multi-Account Support | Manage multiple accounts per provider |
| API Key Rotation | Round-robin, least-used, priority, or random strategies |
| Feature | Description |
|---|---|
| Real-time Usage | Monitor API consumption from provider APIs |
| Usage History | Visualize patterns over last 30 days |
| Cost Estimation | Calculate costs for different models |
| Alert System | Get notified when approaching limits |
| Feature | Description |
|---|---|
Agent SDK Wrapper - Use auto-rotation in your code with @imbios/coding-helper/sdk |
|
Claude Code Integration - Spawn claude command with auto-rotation |
|
| Shell Completion - Full tab completion for bash, zsh, fish | |
| Web Dashboard - Visual monitoring on port 3456 |
# Install via npm
npm install -g @imbios/coding-helper
# Or via bun (recommended)
bun install -g @imbios/coding-helper
# Run directly with npx
npx @imbios/coding-helper config# Add API accounts (uses provider's default model automatically)
cohe account add
# Switch between accounts
cohe account switch <account-id>
# Check status
cohe status
# View usage
cohe usageThe cohe claude command spawns Claude Code with automatic provider/account rotation:
# Run claude with auto-rotation
cohe claude
# Pass through any claude arguments
cohe claude --continue
cohe claude --helpBehind the scenes, this sets all required environment variables according to official documentation:
For Z.AI:
ANTHROPIC_AUTH_TOKEN=<zai_api_key>
ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
ANTHROPIC_DEFAULT_OPUS_MODEL=GLM-4.7
ANTHROPIC_DEFAULT_SONNET_MODEL=GLM-4.7
ANTHROPIC_DEFAULT_HAIKU_MODEL=GLM-4.5-Air
ANTHROPIC_SMALL_FAST_MODEL=GLM-4.5-AirFor MiniMax:
ANTHROPIC_AUTH_TOKEN=<minimax_api_key>
ANTHROPIC_BASE_URL=https://api.minimax.io/anthropic
ANTHROPIC_DEFAULT_OPUS_MODEL=MiniMax-M2.1
ANTHROPIC_DEFAULT_SONNET_MODEL=MiniMax-M2.1
ANTHROPIC_DEFAULT_HAIKU_MODEL=MiniMax-M2.1
ANTHROPIC_SMALL_FAST_MODEL=MiniMax-M2.1Use the auto-rotation feature directly in your code with the Agent SDK wrapper:
npm install @imbios/coding-helper @anthropic-ai/claude-agent-sdkimport { query } from "@imbios/coding-helper/sdk";
// Automatically rotates between accounts on each call
for await (const message of query({
prompt: "Fix the bug in auth.py",
options: {
allowedTools: ["Read", "Edit", "Bash"],
logRotation: true // Log when rotation occurs
}
})) {
if (message.type === "result") {
console.log(message.result);
}
}import {
getAutoRotatedEnv,
performAutoRotation,
getActiveCredentials
} from "@imbios/coding-helper/sdk";
import { query as sdkQuery } from "@anthropic-ai/claude-agent-sdk";
// Option 1: Get rotated environment and use with original SDK
async function runWithRotation() {
await performAutoRotation(); // Manually trigger rotation
const env = await getAutoRotatedEnv(); // Get env vars for active account
for await (const message of sdkQuery({
prompt: "Write a React component",
options: { env }
})) {
// Handle messages...
}
}
// Option 2: Check current credentials before running
function checkBeforeRun() {
const creds = getActiveCredentials();
if (!creds) {
console.error("No accounts configured!");
return;
}
console.log(`Using: ${creds.provider} - ${creds.accountName}`);
console.log(`Model: ${creds.model}`);
}Configure rotation strategy with:
# Enable rotation with specific strategy
cohe auto enable round-robin
cohe auto enable least-used --cross-provider
cohe auto enable random
cohe auto enable priority
# Disable rotation
cohe auto disable
# Check rotation status
cohe auto statusAvailable strategies:
round-robin- Cycle through accounts in orderleast-used- Pick account with lowest API usage (fetches real data from provider)priority- Pick highest priority accountrandom- Randomly select an account
| Model | Tier | Use Case |
|---|---|---|
GLM-4.7 |
Opus | Most capable, complex tasks |
GLM-4.5-Air |
Haiku | Fast, efficient responses |
| Model | Tier | Use Case |
|---|---|---|
MiniMax-M2.1 |
All | Latest flagship model |
| Command | Description |
|---|---|
cohe account add |
Add new API account (auto-selects default model) |
cohe account list |
List all configured accounts |
cohe account switch <id> |
Switch to specific account |
cohe account remove <id> |
Remove an account |
cohe status |
Show current provider and status |
cohe usage |
Query usage statistics from API |
cohe history |
Show usage history (30 days) |
cohe test |
Test API connection |
| Command | Description |
|---|---|
cohe auto enable [strategy] |
Enable auto-rotation |
cohe auto disable |
Disable auto-rotation |
cohe auto status |
Show rotation status |
cohe auto rotate |
Manually trigger rotation |
| Command | Description |
|---|---|
cohe config |
Interactive provider configuration |
cohe switch <provider> |
Switch active provider (zai/minimax) |
| Command | Description |
|---|---|
cohe claude [args...] |
Spawn Claude with auto-rotation |
cohe dashboard start [port] |
Start web dashboard |
cohe alert list |
List usage alerts |
cohe doctor |
Diagnose configuration issues |
cohe completion <shell> |
Generate shell completion |
All accounts and settings are stored in ~/.claude/imbios.json:
{
"version": "2.0.0",
"accounts": {
"acc_123": {
"id": "acc_123",
"name": "my-zai-account",
"provider": "zai",
"apiKey": "sk-...",
"baseUrl": "https://api.z.ai/api/anthropic",
"defaultModel": "GLM-4.7",
"priority": 0,
"isActive": true,
"createdAt": "2025-01-01T00:00:00.000Z",
"usage": {
"used": 0.5,
"limit": 100,
"lastUpdated": "2025-01-01T12:00:00.000Z"
}
}
},
"activeAccountId": "acc_123",
"rotation": {
"enabled": true,
"strategy": "round-robin",
"crossProvider": true
}
}coding-helper respects the following environment variables:
ZAI_API_KEY- Z.AI API key (for legacy provider config)MINIMAX_API_KEY- MiniMax API key (for legacy provider config)IMBIOS_CONFIG_PATH- Custom path to config file
# Add multiple accounts
cohe account add
# Enter name: work-zai
# Select provider: Z.AI (zai)
# Enter API key: sk-...
# (Model is auto-selected based on provider)
cohe account add
# Enter name: personal-minimax
# Select provider: MiniMax
# Enter API key: sk-...
# Enable cross-provider rotation
cohe auto enable random --cross-provider
# Use with Claude Code
cohe claude// my-script.ts
import { query } from "@imbios/coding-helper/sdk";
async function main() {
for await (const message of query({
prompt: "Analyze this codebase and suggest improvements",
options: {
allowedTools: ["Read", "Grep", "Bash"],
logRotation: true
}
})) {
if (message.type === "result") {
console.log(message.result);
}
}
}
main();Run with:
bun run my-script.ts# Add accounts with different priorities
cohe account add # priority 0 (default)
# Edit ~/.claude/imbios.json to set priorities:
# "priority": 10 # High priority account
# "priority": 1 # Medium priority account
# "priority": 0 # Low priority (fallback)
# Enable priority-based rotation
cohe auto enable priority
# Now it will always use the highest priority account- Runtime: Bun 1.2.0+ or Node.js 18+
- Shell: Bash, Zsh, or Fish
- OS: Linux, macOS, Windows (WSL)
- Language: TypeScript (ES2022)
- Runtime: Bun (primary), Node.js (fallback)
- UI Framework: Ink (React for CLI)
- Code Quality: Biome with Ultracite preset
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature-amazing-feature) - Open a Pull Request
- NPM Package: @imbios/coding-helper
- Issues: GitHub Issues
- Author: ImBIOS
anthropic-api, claude-code, claude-agent-sdk, glm, minimax, api-client, cli-tool, provider-management, api-key-rotation, usage-tracking, auto-rotation, multi-account, developer-tools, ai-assistant, terminal-tool, zai-api, glmmodel, bun, typescript