[FEATURE]: Include custom providers in /provider and /connect command
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I defined a custom provider in my opencode.jsonc file (see below example).
If I start opencode and use the /provider command, I would expect my custom provider "fhgenie" to be shown in the list of providers. Howerver, it is not shown.
I would like to connect to my custom provider similar to github copilot provider, specifying some credentials in the command line.... that are stored as secret.
Currently I hard code my api key in opencode.jsonc. I am able to connect to the models using /models command.
=> Could you please support custom providers for the /provider and /connect command and clarify how to fully specify custom providers, including authentication?
Expected behavior: an improved config could support a syntax like
"Authorization": "Bearer ${secret.fhgenie}"
If the cutom secret does not yet exist, opencode asks for it and saves it as a secret.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"fhgenie": {
"npm": "@ai-sdk/openai-compatible",
"name": "FhGenie",
"options": {
"baseURL": "https://fhgenie.foo.de/v1",
"headers": {
"Authorization": "Bearer ***"
}
},
"models": {
"Kimi-K2-Thinking": {
"name": "Kimi-K2-Thinking"
},
}
}
}
}
This issue might be a duplicate of existing issues. Please check:
- #3735: [FEATURE]: CLI Providers - Related request to support additional provider types in selection dialogs
- #1555: LM Studio Missing as Provider, custom provider for LM Studio non-functional - Similar issue with custom providers not appearing in provider selection
- #5210: Custom OpenAI-compatible provider returns no text content - Related issue with custom provider configuration and functionality
- #5163: Custom baseURL configuration returns "Route /api/messages not found" error - Related issue with custom provider baseURL configuration
- #1298: Getting an issue integrating a custom provider: AI_TypeValidationError - Similar custom provider integration issue
- #4533: opencode auth list shows "undefined" for $schema and provider fields despite valid configuration - Related to custom provider configuration display
- #1597: Improve provider and API key update workflow after initial setup - Related feature request for provider management workflow
Feel free to ignore if none of these address your specific case.
Yeah we should fix
Hi, I'd like to work on this issue. cc @rekram1-node
Scope for initial PR:
I'm proposing to handle the first part of this request - making custom providers visible in /provider and /connect commands with API key auth support.
Changes:
- Modify the
/providerendpoint to merge custom providers from config alongside models.dev providers - Add default API key auth method for custom providers in
ProviderAuth.methods()
This would allow users to:
- See their custom providers in
/connect - Connect via API key (stored securely like other providers)
Out of scope (for now):
The ${secret.xxx} template syntax for config interpolation is a larger feature that would benefit from separate design discussion - recommend a follow-up issue for that.
Estimated effort: ~20-30 lines across 2 files (server/server.ts, provider/auth.ts)
I believe this is fixed in the next release
It is not clear if to set a custom provider globally on the machine (and not for project) how to do it https://opencode.ai/docs/providers/#custom-provider
The guide mention opencode.json but is a project file and not a global one.
https://opencode.ai/docs/config/#global
The config docs should help clear that up for you.
~/.config/opencode/opencode.json
I checked that page but there is no field like for my custom key to specify the host parameter.
Also checking the custom-provider section I should expect some info about what are the parameters in the config and a redirect to the page.
yeah docs need another pass