Skip to content

Feature: Multi-account support with automatic failover #23

@cvrt-jh

Description

@cvrt-jh

Feature Request

I've built a fork with multi-account support that I'd love to contribute back to this project.

Features Added

  • Multiple accounts: Add multiple Claude Pro/Max accounts with custom labels
  • Automatic failover: When one account hits rate limits (429), automatically switches to the next available account
  • Rate limit tracking: Tracks which accounts are rate-limited with expiry times
  • API key fallback: Falls back to ANTHROPIC_API_KEY env var when all OAuth accounts are exhausted
  • CLI management tool: Standalone multi-auth CLI for account management outside of OpenCode
  • Backwards compatible: Automatically migrates existing single-account auth to multi-account format

CLI Tool

Account management via multi-auth command (run before starting OpenCode):

multi-auth add [label]     # Add account (opens browser for OAuth)
multi-auth list            # List accounts with token status
multi-auth info            # Detailed info (expiry times, tokens)
multi-auth rename <n> <name>
multi-auth remove <n>
multi-auth status

Example output:

$ multi-auth list
📋 Connected Accounts

   1. "Personal" - 🟢 valid (7h 56m left)
   2. "Work" - 🟢 valid (7h 56m left)
   3. "Backup" - 🔴 expired (will auto-refresh)

Use Case

For users with multiple Claude subscriptions (personal + work, or team accounts), this allows seamless switching when hitting rate limits, maximizing productivity without manual intervention.

Implementation

The fork is available at: https://github.com/cvrt-gmbh/opencode-anthropic-multi-auth

Key changes:

  • Storage format changed from type: "oauth" to type: "multi-oauth" with accounts array
  • Config stored in ~/.config/opencode/multi-auth.json (shared between CLI and plugin)
  • Added rate limit tracking with retry-after header parsing
  • Automatic retry with next available account on 429
  • Standalone CLI tool for account management

Collaboration

I'm happy to:

  • Submit a PR with these changes
  • Adapt the code to match your project's style/conventions
  • Discuss alternative implementation approaches
  • Help maintain the feature going forward

Let me know if you're interested in incorporating this functionality!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions