how to add multiple providers in opencode.json? #1292

Closed
opened 2026-02-16 17:30:20 -05:00 by yindo · 2 comments
Owner

Originally created by @the-vampiire on GitHub (Aug 13, 2025).

closest i found was https://github.com/sst/opencode/issues/629 but i dont understand the solution of using openauth though.

my use case is that i can only add one custom provider in opencode.json

{
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {...}
    }
  }
}

sometimes i test out with other custom providers (local or hosted). is the only solution to overwrite the ollama provider config? what i was hoping for was something like

{
  "providers": {
    "ollama": {...},
    "other": {...}
  }
}

i did try opencode auth login and selecting other and naming it but all i got was this message afterwards, not sure where it even wrote the auth key to (i checked ~/.config/opencode/ but nothing was there and no change to the config json).

opencode auth login

┌  Add credential
│
◇  Select provider
│  Other
│
◇  Enter provider id
│  llama-cpp
│
▲  This only stores a credential for llama-cpp - you will need configure it in opencode.json, check the docs for examples.
│
◇  Enter your API key
│  ▪
│
└  Done

seems like the TUI can already support this since it separates the providers in /models. let me know if I’m thinking about this the wrong way.

Originally created by @the-vampiire on GitHub (Aug 13, 2025). closest i found was https://github.com/sst/opencode/issues/629 but i dont understand the solution of using `openauth` though. my use case is that i can only add one custom provider in `opencode.json` ```json { "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:11434/v1" }, "models": {...} } } } ``` sometimes i test out with other custom providers (local or hosted). is the only solution to overwrite the ollama provider config? what i was hoping for was something like ```json { "providers": { "ollama": {...}, "other": {...} } } ``` i did try `opencode auth login` and selecting `other` and naming it but all i got was this message afterwards, not sure where it even wrote the auth key to (i checked `~/.config/opencode/` but nothing was there and no change to the config json). ```sh opencode auth login ┌ Add credential │ ◇ Select provider │ Other │ ◇ Enter provider id │ llama-cpp │ ▲ This only stores a credential for llama-cpp - you will need configure it in opencode.json, check the docs for examples. │ ◇ Enter your API key │ ▪ │ └ Done ``` seems like the TUI can already support this since it separates the providers in `/models`. let me know if I’m thinking about this the wrong way.
yindo closed this issue 2026-02-16 17:30:20 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 13, 2025):

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

  • #629: Feature request for ability to configure multiple providers and toggle between them (same core concept)
  • #383: Feature request for ability to switch providers inside app (related switching functionality)
  • #152: Request to read custom providers from central config location (related configuration issue)

If none of these address your specific case, please let us know how this issue differs.

@github-actions[bot] commented on GitHub (Aug 13, 2025): 👋 This issue might be a duplicate of existing issues. Please check: - #629: Feature request for ability to configure multiple providers and toggle between them (same core concept) - #383: Feature request for ability to switch providers inside app (related switching functionality) - #152: Request to read custom providers from central config location (related configuration issue) If none of these address your specific case, please let us know how this issue differs.
Author
Owner

@the-vampiire commented on GitHub (Aug 13, 2025):

turns out i am legally retarded and should have my issue opening privileges revoked..

fix for anyone else who is challenged, literally what was proposed minus an s at the end:

{
  "provider": {
    "ollama": {...},
    "other": {...}
  }
}
@the-vampiire commented on GitHub (Aug 13, 2025): turns out i am legally retarded and should have my issue opening privileges revoked.. fix for anyone else who is challenged, literally what was proposed minus an `s` at the end: ```json { "provider": { "ollama": {...}, "other": {...} } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1292