[PR #8536] feat(openai-oauth) OpenAI OAuth multi account support #12781

Open
opened 2026-02-16 18:17:40 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8536

State: open
Merged: No


What does this PR do?

Features:

  • Store multiple Codex accounts with individual usage tracking
  • auth use <email> command to switch active account
  • auth list shows all accounts with 5h/weekly usage bars
  • Auto-rotate to next available account on 429 rate limit
  • TUI footer warning when approaching limit (>90%)
  • Status dialog displays all accounts with real-time usage

Technical:

  • New CodexMultiAccount auth type with accounts[] + activeIndex
  • /provider/codex/usage endpoint for fetching usage across accounts
  • Parse ChatGPT usage API response + rate limit headers
  • Persist usage data and rate limit state per account

How did you verify your code works?

  1. Login two different ChatGPT accounts via opencode auth login openai (or the plugin method).
  2. Run opencode auth list and confirm both accounts appear with the active marker, and that provider entries are shown correctly.
  3. Use opencode auth switch to change the active ChatGPT account; verify the active marker moves.
  4. Simulate or trigger a rate-limit on the active account (or temporarily mark account as rate limited in auth.json) and ensure the plugin switches to the next available account and shows a toast message.
  5. Confirm token refresh flows work: let a token expire or set expires in the past and ensure requests still succeed (refresh path used, tokens updated).
  6. Confirm legacy single-account auth (openai) still works and is migrated to codex on first use.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8536 **State:** open **Merged:** No --- ### What does this PR do? **Features:** - Store multiple Codex accounts with individual usage tracking - `auth use <email>` command to switch active account - `auth list` shows all accounts with 5h/weekly usage bars - Auto-rotate to next available account on 429 rate limit - TUI footer warning when approaching limit (>90%) - Status dialog displays all accounts with real-time usage **Technical:** - New `CodexMultiAccount` auth type with `accounts[]` + `activeIndex` - `/provider/codex/usage` endpoint for fetching usage across accounts - Parse ChatGPT usage API response + rate limit headers - Persist usage data and rate limit state per account ### How did you verify your code works? 1. Login two different ChatGPT accounts via opencode auth login openai (or the plugin method). 2. Run opencode auth list and confirm both accounts appear with the active marker, and that provider entries are shown correctly. 3. Use opencode auth switch to change the active ChatGPT account; verify the active marker moves. 4. Simulate or trigger a rate-limit on the active account (or temporarily mark account as rate limited in auth.json) and ensure the plugin switches to the next available account and shows a toast message. 5. Confirm token refresh flows work: let a token expire or set expires in the past and ensure requests still succeed (refresh path used, tokens updated). 6. Confirm legacy single-account auth (openai) still works and is migrated to codex on first use.
yindo added the pull-request label 2026-02-16 18:17:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12781