GeezerVison is showing github.com — Have multiple instances of the same provider · Issue #6217 · anomalyco/opencode
Have multiple instances of the same provider #6217DescriptionQuestion
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 Reacted by Alex Fanthome, Daniel Sticker , Leonardo D'Ippolito, Jason Bouffard, MiroshnykovDaniil, Cedric Ahlers, Mattwmaster58, Anurag, Martin Wernstål, rockingdice and 11 more Activitygithub-actions commented on Dec 26, 2025 This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case. spenceforce commented on 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 :) Reacted by patriksimms, Raymel and Erik O'Leary patriksimms commented on 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 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
}
}Reacted by Raymel, krshock and Oliver W. spenceforce commented on 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. mathisdev7 commented on 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 Reacted by rockingdice Reacted by Raymel and rockingdice clowa commented on 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? raymelon commented on 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. Reacted by patriksimms, Florian Bellmann, Frederik Bosch, Oliver W. and Francisco Ruiz Reacted by Erik O'Leary and Oliver W. florianbellmann commented on Feb 16, 2026 @raymelon This sounds exactly like what I need 😄 ! how do you switch between the keys in the TUI then? raymelon commented on Feb 17, 2026
@raymelon This sounds exactly like what I need 😄 ! how do you switch between the keys in the TUI then?
@florianbellmann I have to dig into the source to see. Also depends if it is something that the team will merge.
But I'm good with editing the json to use the key for the provider. Only caveat is only one key is available per provider. Another is restarting OpenRouter after switching. For a multi-window setup, it's a bit of a hassle. quarkcore commented on Feb 25, 2026 I wrote a small Bash script that sets auth.json as a symlink, and I have a directory with different auth settings. I am just going to share it here. Maybe it will work for someone else too.
#!/usr/bin/env bash
set -euo pipefail
AUTH_PROFILES_DIR="$HOME/.config/opencode/auth-profiles"
TARGET_LINK="$HOME/.local/share/opencode/auth.json"
if [ $# -ne 1 ]; then
echo "Available profiles:"
if [ -d "$AUTH_PROFILES_DIR" ]; then
ls -1 "$AUTH_PROFILES_DIR" | sed 's/\.json$//'
else
echo "(directory not found: $AUTH_PROFILES_DIR)"
fi
echo
echo "Usage: opencode-auth <profile>"
exit 1
fi
PROFILE="$1"
PROFILE_FILE="${PROFILE%.json}.json"
SOURCE_FILE="$AUTH_PROFILES_DIR/$PROFILE_FILE"
if [ ! -f "$SOURCE_FILE" ]; then
echo "Error: Profile '$PROFILE' not found in $AUTH_PROFILES_DIR"
exit 1
fi
mkdir -p "$(dirname "$TARGET_LINK")"
ln -sfn "$SOURCE_FILE" "$TARGET_LINK"
echo "✅ Switched opencode auth to: ${PROFILE_FILE%.json}"Reacted by Thomas Orgeval Reacted by Raymel nateshmbhat commented on Feb 28, 2026 really really need this feature, i'm having to juggle between many different providers and accounts as i keep running out of credits Reacted by Paweł Borecki, krshock and Erik O'Leary Reacted by Raymel krshock commented on Mar 15, 2026 I have 3 "cost centers": two unrelated projects (work) and one for personal use.
Opencode doesnt know about ZEN workspaces (i created 3 different ones, only to learn opencode doesnt care: one provider, one key)
At least needs to support selecting opencode/zen workspaces for different runing instances of opencode because it just makes sense.
This is ideal for people who wants to manage their per-project usage, because in some case i can pass my llm costs directly to my client) raf1hh commented on Mar 15, 2026 PR #17664 should in theory work with other providers and not just copilot. Just need to specify the auth used... onionhammer commented on May 12, 2026 This seems very important for people who aren't just hobbyists MythicSorcerer commented on May 14, 2026 Sigh.... I don't want to have to change my auth.json every time I need to switch. This is so annoying. raf1hh commented on May 14, 2026 I had a PR that solved it but it was ignored. I have a fork of OC where this is implemented:
https://github.com/raf1hh/opencode/tree/feat/auth-provider-alias
I build the binary of that branch, rename and then copy it to bin. Then use OCX to launch OC with a specific profile and specific binary.
{ "$schema": "https://ocx.kdco.dev/schemas/profile.json", "bin": "/Users/raf1hh/bin/opencode_with_auth_provider_1.4.25", "registries": {}, "renameWindow": true, "exclude": [ // "**/AGENTS.md" — Commented out = project AGENTS.md files are INCLUDED. // Uncomment this line to exclude all project instruction files. "**/CLAUDE.md", "**/CONTEXT.md", "**/.opencode/**", "**/opencode.jsonc", "**/opencode.json", "**/.env" ], "include": [ "**/.env.example" ] }
joeldrapper commented on Jun 2, 2026 I often need to switch between my work and personal OpenAI accounts, deepening on what project I’m working on. It would be great if there was a way to configure multiple OpenAI accounts and label them. rwxce commented on Jun 3, 2026 I think this would be useful beyond just supporting multiple API keys for the same provider.
One possible UX improvement could be to make provider connections more explicit in the UI, maybe grouped under a user-defined profile or account group.
For example:
Work
- OpenRouter — API key
- ChatGPT — headless browser
- Anthropic — API key
Personal
That way, the model picker would only show the providers/models available for the currently selected environment. It would avoid long labels with too many properties, while still making it clear which account, credentials, or auth method are being used.
Not sure what the maintainers prefer from a data-model/UI perspective, but from a user point of view the key thing is visibility: when selecting a model, it should be obvious which environment and provider connection it belongs to.
Visual Example:
 rekram1-node commented on Jun 23, 2026 Automated: closing question issues.
GitHub Issues are for bug reports and feature requests only — questions / support are no longer tracked here.
If this is a bug or feature request, please open a new issue with the appropriate template. Reacted by Erik O'Leary, Von, Marc Cerutti, Wolfgang Moser, Genex36 and Hubert Pietrusiak
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|