Have multiple instances of the same provider #3895

Open
opened 2026-02-16 17:41:52 -05:00 by yindo · 9 comments
Owner

Originally created by @raymelon on GitHub (Dec 26, 2025).

Originally assigned to: @thdxr on GitHub.

Question

Curious if it's possible to have multiple instances of the same provider from the same provider?

One user group that will benefit this are people managing multiple OpenRouter accounts plus their personal ones.

The idea is this: on Select model, instead of single OpenRouter group:

OpenRouter
Claude Haiku 3.5
Claude Haiku 4.5

It will be:

<Custom name 1> (OpenRouter)
Claude Haiku 3.5
Claude Haiku 4.5

<Custom name 2> (OpenRouter)
Claude Haiku 3.5
Claude Haiku 4.5

--
Meanwhile, on Connect provider, instead of asking for the key right away, a custom name will be asked optionally

The idea is there can be multiple instances of the same provider

Originally created by @raymelon on GitHub (Dec 26, 2025). Originally assigned to: @thdxr on GitHub. ### Question Curious if it's possible to have multiple instances of the same provider from the same provider? One user group that will benefit this are people managing multiple OpenRouter accounts plus their personal ones. The idea is this: on Select model, instead of single OpenRouter group: OpenRouter Claude Haiku 3.5 Claude Haiku 4.5 It will be: <Custom name 1> (OpenRouter) Claude Haiku 3.5 Claude Haiku 4.5 <Custom name 2> (OpenRouter) Claude Haiku 3.5 Claude Haiku 4.5 -- Meanwhile, on Connect provider, instead of asking for the key right away, a custom name will be asked optionally The idea is there can be multiple instances of the same provider
Author
Owner

@github-actions[bot] commented on GitHub (Dec 26, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5391: [FEATURE]: multiple auth profiles per provider - Requests the ability to have multiple profiles per provider that can be switched between in the provider picker
  • #5748: Proposal: Provider Auth v2 (encrypted credential vault + multi-account OAuth + same-request rotation) - Comprehensive proposal for multi-account support per provider with encrypted credential vault
  • #1326: Support multiple API keys per provider with fallback logic - Requests multiple API keys per provider with automatic fallback

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 26, 2025): This issue might be a duplicate of existing issues. Please check: - #5391: [FEATURE]: multiple auth profiles per provider - Requests the ability to have multiple profiles per provider that can be switched between in the provider picker - #5748: Proposal: Provider Auth v2 (encrypted credential vault + multi-account OAuth + same-request rotation) - Comprehensive proposal for multi-account support per provider with encrypted credential vault - #1326: Support multiple API keys per provider with fallback logic - Requests multiple API keys per provider with automatic fallback Feel free to ignore if none of these address your specific case.
Author
Owner

@spenceforce commented on GitHub (Jan 7, 2026):

+1 for this. From a billing standpoint, allowing multiple API keys would be a quality of life improvement. For people who mix work and personal on one computer (#7188) or want separate billing on a per project basis this would make that a lot easier.

Edit: I see you can configure per project API keys in the config section, which solves my problem :)

@spenceforce commented on GitHub (Jan 7, 2026): +1 for this. From a billing standpoint, allowing multiple API keys would be a quality of life improvement. For people who mix work and personal on one computer (#7188) or want separate billing on a per project basis this would make that a lot easier. Edit: I see you can configure per project API keys in the config section, which solves my problem :)
Author
Owner

@patriksimms commented on GitHub (Jan 7, 2026):

@spenceforce Do you have a link to the docs where this is possible?

I also have the feeling that this works for API-key based providers, but not the oauth ones (e.g. anthropic)

Edit: Nevermind, found it. For reference: https://opencode.ai/docs/config/#env-vars. But as said, looks like it only works for api key based auth

@patriksimms commented on GitHub (Jan 7, 2026): @spenceforce Do you have a link to the docs where this is possible? I also have the feeling that this works for API-key based providers, but not the oauth ones (e.g. anthropic) Edit: Nevermind, found it. For reference: https://opencode.ai/docs/config/#env-vars. But as said, looks like it only works for api key based auth
Author
Owner

@patriksimms commented on GitHub (Jan 7, 2026):

Digged a little in the source code. It looks like oauth credentials are stored globally in /Users/patriksimms/.local/share/opencode/auth.json with following schema:

{
  "anthropic": {
    "type": "oauth",
    "refresh": "sk-ant-ort01-eA...",
    "access": "sk-ant-oat01-5t...",
    "expires": 1234
  }
}
@patriksimms commented on GitHub (Jan 7, 2026): Digged a little in the source code. It looks like oauth credentials are stored globally in `/Users/patriksimms/.local/share/opencode/auth.json` with following schema: ```json { "anthropic": { "type": "oauth", "refresh": "sk-ant-ort01-eA...", "access": "sk-ant-oat01-5t...", "expires": 1234 } } ```
Author
Owner

@spenceforce commented on GitHub (Jan 7, 2026):

I only see references to API keys and not oauth credentials. I primarily work with API keys, so didn't even think about that use case when I made my comment. That would still be a pain point then.

@spenceforce commented on GitHub (Jan 7, 2026): I only see references to API keys and not oauth credentials. I primarily work with API keys, so didn't even think about that use case when I made my comment. That would still be a pain point then.
Author
Owner

@mathisdev7 commented on GitHub (Jan 17, 2026):

ran into this exact problem with my two $20 codex subs so i ended up building a tui that supports multiple accounts or api key per provider and rotates automatically
sharing in case it helps: https://github.com/arctic-cli/interface

@mathisdev7 commented on GitHub (Jan 17, 2026): ran into this exact problem with my two $20 codex subs so i ended up building a tui that supports multiple accounts or api key per provider and rotates automatically sharing in case it helps: https://github.com/arctic-cli/interface
Author
Owner

@clowa commented on GitHub (Feb 1, 2026):

Would be awesome to see support for using OAuth together with API Key for the same (or a duplicated) provider.

In my case we are using OpenAI with a Business Subscription which includes access to codex. However, connecting with OpenAI via OAuth only grant access to a small subset of modules, therefore every time I want to use a none included module I have to reconfigure the OpenAI provider to use a API Key. It would be awesome if OpenCode would be capable of configuring both OAuth and API Key to connect to OpenAI (or others as well) to have access to all available models.
It would be totally fine if there would be simply two connections to OpenAI, one with OAuth, one with API Key.

Perhaps someone already knows a trick on how to do this?

@clowa commented on GitHub (Feb 1, 2026): Would be awesome to see support for using OAuth together with API Key for the same (or a duplicated) provider. In my case we are using OpenAI with a Business Subscription which includes access to codex. However, connecting with OpenAI via OAuth only grant access to a small subset of modules, therefore every time I want to use a none included module I have to reconfigure the OpenAI provider to use a API Key. It would be awesome if OpenCode would be capable of configuring both OAuth and API Key to connect to OpenAI (or others as well) to have access to all available models. It would be totally fine if there would be simply two connections to OpenAI, one with OAuth, one with API Key. Perhaps someone already knows a trick on how to do this?
Author
Owner

@raymelon commented on GitHub (Feb 9, 2026):

Digged a little in the source code. It looks like oauth credentials are stored globally in /Users/patriksimms/.local/share/opencode/auth.json with following schema:

{
"anthropic": {
"type": "oauth",
"refresh": "sk-ant-ort01-eA...",
"access": "sk-ant-oat01-5t...",
"expires": 1234
}
}

This is smart. Given this information, a workaround is to just have two or more of the same provider, suffixed when unused. Easy to switch imo.

  "openrouter_work": { // unused. to use, rename this to openrouter and suffix the unused to change its name
    "type": "api",
    "key": "work key"
  },
  "openrouter": { // the one used
    "type": "api",
    "key": "main key"
  },

Cool stuff @patriksimms . Thanks for sharing.

@raymelon commented on GitHub (Feb 9, 2026): > Digged a little in the source code. It looks like oauth credentials are stored globally in `/Users/patriksimms/.local/share/opencode/auth.json` with following schema: > > { > "anthropic": { > "type": "oauth", > "refresh": "sk-ant-ort01-eA...", > "access": "sk-ant-oat01-5t...", > "expires": 1234 > } > } This is smart. Given this information, a workaround is to just have two or more of the same provider, suffixed when unused. Easy to switch imo. ```jsonc "openrouter_work": { // unused. to use, rename this to openrouter and suffix the unused to change its name "type": "api", "key": "work key" }, "openrouter": { // the one used "type": "api", "key": "main key" }, ``` Cool stuff @patriksimms . Thanks for sharing.
Author
Owner

@florianbellmann commented on GitHub (Feb 16, 2026):

@raymelon This sounds exactly like what I need 😄 ! how do you switch between the keys in the TUI then?

@florianbellmann commented on GitHub (Feb 16, 2026): @raymelon This sounds exactly like what I need 😄 ! how do you switch between the keys in the TUI then?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3895