Maintaining multiple auth profiles on the same provider #647

Closed
opened 2026-02-16 17:27:42 -05:00 by yindo · 4 comments
Owner

Originally created by @OneAbodFTW on GitHub (Jul 11, 2025).

I've two keys in use, for two separate projects both are from Open Router, but wants to keep costs seperate.

When I run

opencode auth login

Chose openrouter, add the API key. then run the auth flow again, and add another API.

After that I call:

opencode auth list

I only see the latest openrouter key added, and can not switch between different auth profiles per se.

If you can point me in the right direction with more details, might be able to implement this.

Originally created by @OneAbodFTW on GitHub (Jul 11, 2025). I've two keys in use, for two separate projects both are from Open Router, but wants to keep costs seperate. When I run ```shell opencode auth login ``` Chose openrouter, add the API key. then run the auth flow again, and add another API. After that I call: ```shell opencode auth list ``` I only see the latest openrouter key added, and can not switch between different auth profiles per se. If you can point me in the right direction with more details, might be able to implement this.
yindo closed this issue 2026-02-16 17:27:42 -05:00
Author
Owner

@thdxr commented on GitHub (Jul 11, 2025):

i'm not sure this is something we'll support because it's tricky to then have to specify which auth to use for a given provider, loses a lot of simplicity

i recommend maybe using env vars for each project for the different keys? you can put an opencode.json in the folder of each and read from a different env var under apiKey: "{env:OPENROUTER_KEY_1}"

@thdxr commented on GitHub (Jul 11, 2025): i'm not sure this is something we'll support because it's tricky to then have to specify which auth to use for a given provider, loses a lot of simplicity<br><br>i recommend maybe using env vars for each project for the different keys? you can put an `opencode.json` in the folder of each and read from a different env var under `apiKey: "{env:OPENROUTER_KEY_1}"`
Author
Owner

@thdxr commented on GitHub (Jul 11, 2025):

more info here https://x.com/thdxr/status/1943826969189089460

@thdxr commented on GitHub (Jul 11, 2025): more info here [https://x.com/thdxr/status/1943826969189089460](https://x.com/thdxr/status/1943826969189089460)
Author
Owner

@OneAbodFTW commented on GitHub (Jul 14, 2025):

Oh, thank you, did not know that I could override the key within the config file, that works for my use-case, perhaps this needs a section in the documentation? As it was not clear initially to me this was possible.

@OneAbodFTW commented on GitHub (Jul 14, 2025): Oh, thank you, did not know that I could override the key within the config file, that works for my use-case, perhaps this needs a section in the documentation? As it was not clear initially to me this was possible.
Author
Owner

@jfpedroza commented on GitHub (Aug 1, 2025):

Related to this. I would like to use Claude Pro for personal projects and use an Anthropic API key for projects. Is that supported?

@jfpedroza commented on GitHub (Aug 1, 2025): Related to this. I would like to use Claude Pro for personal projects and use an Anthropic API key for projects. Is that supported?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#647