[PR #13218] feat: multi-account profile support per provider #14562

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

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

State: open
Merged: No


What does this PR do?

Closes #13038

Adds multi-account profile support so users can manage multiple credentials per provider (e.g. work and personal OpenRouter accounts) without manually editing auth.json.

Please provide a description of the issue (if there is one), the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.

Currently, users must manually edit auth.json to switch between accounts on providers. This is not a good UX for users who have work/personal accounts. To fix, I adjusted auth.json to store credentials in a profile-based manner.

//before
{
  "openrouter": { "type": "api", "key": "..." }
}

//after
{
  "openrouter": {
    "profiles": {
      "personal": { "type": "api", "key": "..." },
      "work": { "type": "api", "key": "..." }
    },
    "currentProfile": "personal"
  }
}

Added CLI Commands:

  • auth profile create
  • auth profile use
  • auth profile list [provider]
  • auth profile remove
  • auth profile rename

Modified CLI Commands:

  • auth login --profile
  • auth logut --profile
  • auth list --profiles
  • run --profile

Also reworked profileID to flow through end to end and added active profile to show in prompt bar of TUI, as well as a dialog option to switch profile. This PR is backwards compatible as auth.json is rewritten when the user runs his first profile command.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

  • Tested locally with multiple OpenRouter API Keys across all CLI commands.
  • Tested migration from old auth format by manually writing legacy format and running profile command to verfiy auto-upgrade
  • bun typecheck passes clean

UI Changes SC attached below
image
image
image
image
image
image

This is a fairly large PR, happy to rework and make changes. Thanks for the opportunity!

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13218 **State:** open **Merged:** No --- ### What does this PR do? Closes #13038 Adds multi-account profile support so users can manage multiple credentials per provider (e.g. work and personal OpenRouter accounts) without manually editing auth.json. Please provide a description of the issue (if there is one), the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR. Currently, users must manually edit auth.json to switch between accounts on providers. This is not a good UX for users who have work/personal accounts. To fix, I adjusted auth.json to store credentials in a profile-based manner. ``` //before { "openrouter": { "type": "api", "key": "..." } } //after { "openrouter": { "profiles": { "personal": { "type": "api", "key": "..." }, "work": { "type": "api", "key": "..." } }, "currentProfile": "personal" } } ``` Added CLI Commands: - auth profile create <provider> - auth profile use <provider> - auth profile list [provider] - auth profile remove <provider> - auth profile rename <provider> Modified CLI Commands: - auth login --profile <name> - auth logut --profile <name> - auth list --profiles - run --profile <name> Also reworked profileID to flow through end to end and added active profile to show in prompt bar of TUI, as well as a dialog option to switch profile. This PR is backwards compatible as auth.json is rewritten when the user runs his first profile command. **If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!** ### How did you verify your code works? - Tested locally with multiple OpenRouter API Keys across all CLI commands. - Tested migration from old auth format by manually writing legacy format and running profile command to verfiy auto-upgrade - bun typecheck passes clean UI Changes SC attached below <img width="865" height="620" alt="image" src="https://github.com/user-attachments/assets/cbf44796-4759-474a-8d1c-cd232553db07" /> <img width="846" height="539" alt="image" src="https://github.com/user-attachments/assets/d764adab-afd1-4154-91b5-999a0bb978c7" /> <img width="855" height="620" alt="image" src="https://github.com/user-attachments/assets/b011ff38-f81c-429f-b24d-3732dd478de4" /> <img width="837" height="610" alt="image" src="https://github.com/user-attachments/assets/4bd76461-e029-440d-9cf0-176a32a7a7fe" /> <img width="752" height="657" alt="image" src="https://github.com/user-attachments/assets/3d72115d-09f4-45e2-96b0-31eb36d2109e" /> <img width="846" height="532" alt="image" src="https://github.com/user-attachments/assets/45f861b6-95d1-4ed2-a916-c6c75e8fea58" /> This is a fairly large PR, happy to rework and make changes. Thanks for the opportunity!
yindo added the pull-request label 2026-02-16 18:19:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14562