Skip to content

[FEATURE]: multi-account OpenAI support — account pool, /account commands, interactive picker #23620

Description

@lNimien

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Context

I'm aware of previous requests for this feature (#8591, #9068, #11830)
but none received maintainer feedback. I'm opening this one because
I have a working implementation ready.

Problem

Currently, /connect overwrites the previous OpenAI account every time it's used.
There is no way to have multiple ChatGPT accounts connected simultaneously.
This is a significant limitation for users who manage several accounts and want to
distribute usage across them without manually reconnecting every time.

Scope

This implementation is OpenAI-only — specifically for users running
ChatGPT Plus with Codex quota. No generic multi-provider abstraction,
no over-engineering. Just the problem I actually had.

Proposed Solution

We implemented a multi-account pool for OpenAI in a fork. The approach is minimal,
backwards compatible, and OpenAI-specific (no over-engineered generic abstraction).

What We Built

  • /connect now accumulates accounts instead of overwriting — each new login adds
    a new entry to the pool
  • /account list — shows all connected accounts with email and status (enabled/disabled/active)
  • /account use — interactive picker with arrow keys + Enter to switch active account
  • /account disable — interactive picker to disable an account from the pool
  • /account remove — interactive picker to remove an account from the pool
  • Visual indicator in the TUI showing the active account email next to the model indicator
  • Full backwards compatibility with existing single-account auth.json format —
    existing users are not affected

Technical Approach

  • Extended auth.json with an accounts[] array under the OpenAI key
  • Old single-account format is auto-migrated on first read
  • /account commands are local TUI commands, not model prompts
  • Token refresh updates only the selected account entry, never touches others
  • New backend endpoints: GET/DELETE/POST /provider/openai/account/...

Status

We have a working fork validated on Windows 11. All features above are functional.

Fork

https://github.com/lNimien/opencode

Question for Maintainers

Would you be interested in a PR for this? If so, do you have preferences on:

  • The storage approach (auth.json extension vs separate file)
  • Whether session affinity (pinning a session to a specific account) should be
    included in the same PR or as a follow-up
  • Any specific test coverage requirements

Happy to polish and submit a proper PR if there's interest.

Metadata

Metadata

Assignees

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