Related ToolsClaude CodeClaude

How to Run Claude Code with Multiple Provider Accounts on One Machine

Claude by Anthropic
Image: Anthropic

Developers juggling multiple Claude Code accounts, say a team subscription and a personal z.ai gateway, typically end up swapping config files or storing credentials globally where they can leak across sessions. There is a cleaner way.

The approach uses a single Claude Code installation with a provider-neutral global config in ~/.claude/settings.json (no API keys stored there), plus two thin wrapper scripts that set the right environment variables before launching Claude:

  • claude-team clears all provider-specific env vars (ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, etc.) and launches the standard Claude binary. This ensures no gateway overrides bleed in.
  • claude-zai pulls the z.ai token from a secure source (the pass password manager, a local file, or an env var) and sets the base URL to https://api.z.ai/api/anthropic along with model mappings.

The critical security rule: never put third-party tokens in settings.json. That file is too easy to accidentally commit or share. Keep credentials in pass, a local secrets file, or scoped environment variables.

You can verify each path works by running claude-team auth status (should show no gateway) and claude-zai auth status (should show the z.ai endpoint). The same pattern extends to any alternative Anthropic-compatible provider, not just z.ai.

This is a niche setup, but for developers billing against multiple orgs or testing against different backends, it removes the friction of context-switching without any security compromises.