Skip to content

Have multiple instances of the same provider #6217

Closed as not planned
Closed as not planned

Description

@raymelon

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

Activity

  1. github-actions commented on Dec 26, 2025

    @github-actions
    Contributor

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

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

  2. spenceforce commented on Jan 7, 2026

    @spenceforce

    +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 :)

  3. patriksimms commented on Jan 7, 2026

    @patriksimms

    @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

  4. patriksimms commented on Jan 7, 2026

    @patriksimms

    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
      }
    }
  5. spenceforce commented on Jan 7, 2026

    @spenceforce

    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.

  6. mathisdev7 commented on Jan 17, 2026

    @mathisdev7

    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

  7. clowa commented on Feb 1, 2026

    @clowa

    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?

  8. raymelon commented on Feb 9, 2026

    @raymelon
    Author

    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.

  9. florianbellmann commented on Feb 16, 2026

    @florianbellmann

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

  10. raymelon commented on Feb 17, 2026

    @raymelon
    Author

    @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.

  11. quarkcore commented on Feb 25, 2026

    @quarkcore

    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}"
  12. nateshmbhat commented on Feb 28, 2026

    @nateshmbhat

    really really need this feature, i'm having to juggle between many different providers and accounts as i keep running out of credits

  13. krshock commented on Mar 15, 2026

    @krshock

    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)

  14. raf1hh commented on Mar 15, 2026

    @raf1hh

    PR #17664 should in theory work with other providers and not just copilot. Just need to specify the auth used...

  15. onionhammer commented on May 12, 2026

    @onionhammer

    This seems very important for people who aren't just hobbyists

  16. MythicSorcerer commented on May 14, 2026

    @MythicSorcerer

    Sigh.... I don't want to have to change my auth.json every time I need to switch. This is so annoying.

  17. raf1hh commented on May 14, 2026

    @raf1hh

    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" ] }

  18. joeldrapper commented on Jun 2, 2026

    @joeldrapper

    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.

  19. rwxce commented on Jun 3, 2026

    @rwxce

    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.

    Visual Example:

    Image
  20. rekram1-node commented on Jun 23, 2026

    @rekram1-node
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions