Skip to content

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

@the-vampiire

Description

@the-vampiire

closest i found was #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions