You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Have multiple instances of the same provider #6217
This issue might be a duplicate of existing issues. Please check:
[FEATURE]: multiple auth profiles per provider #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
+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 :)
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:
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.
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
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?
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:
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"
},
@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.
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 bashset -euo pipefail
AUTH_PROFILES_DIR="$HOME/.config/opencode/auth-profiles"
TARGET_LINK="$HOME/.local/share/opencode/auth.json"if [ $#-ne 1 ];thenecho"Available profiles:"if [ -d"$AUTH_PROFILES_DIR" ];then
ls -1 "$AUTH_PROFILES_DIR"| sed 's/\.json$//'elseecho"(directory not found: $AUTH_PROFILES_DIR)"fiechoecho"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" ];thenecho"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}"
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)
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.
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
OpenRouter — API key
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.
Activity
github-actions commentedon 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 commentedon 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 :)
patriksimms commentedon 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 commentedon 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.jsonwith following schema:{ "anthropic": { "type": "oauth", "refresh": "sk-ant-ort01-eA...", "access": "sk-ant-oat01-5t...", "expires": 1234 } }spenceforce commentedon 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 commentedon 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
clowa commentedon 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 commentedon Feb 9, 2026
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.
Cool stuff @patriksimms . Thanks for sharing.
florianbellmann commentedon Feb 16, 2026
@raymelon This sounds exactly like what I need 😄 ! how do you switch between the keys in the TUI then?
raymelon commentedon Feb 17, 2026
@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 commentedon 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.
nateshmbhat commentedon 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
krshock commentedon 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 commentedon Mar 15, 2026
PR #17664 should in theory work with other providers and not just copilot. Just need to specify the auth used...
onionhammer commentedon May 12, 2026
This seems very important for people who aren't just hobbyists
MythicSorcerer commentedon 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 commentedon 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 commentedon 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 commentedon 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
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 commentedon 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.