-
Notifications
You must be signed in to change notification settings - Fork 0
feat(backends): add custom compatible connectors #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Custom Compatible Backends | ||
|
|
||
| Custom compatible backends let operators add API-compatible providers without writing a Go plugin. Use them when a provider exposes an OpenAI Chat Completions, OpenAI Responses, or Anthropic Messages compatible API but the standard distribution does not ship a dedicated connector. | ||
|
|
||
| ## Factory kinds | ||
|
|
||
| Use the existing backend `kind` field to select the factory and `id` as the runtime route backend instance: | ||
|
|
||
| | Factory kind | Upstream API | | ||
| | --- | --- | | ||
| | `custom-openai-legacy-compatible` | OpenAI-compatible `/chat/completions` | | ||
| | `custom-openai-responses-compatible` | OpenAI-compatible `/responses` | | ||
| | `custom-anthropic-compatible` | Anthropic-compatible `/v1/messages` | | ||
|
|
||
| Each enabled custom backend requires a unique `config.backend_prefix`. The prefix is used for backend inventory and prefixed routing. It must not contain `/` or `:`, must not duplicate another enabled custom backend, and must not use a reserved standard backend prefix such as `nvidia`, `openrouter`, `anthropic`, `openai-legacy`, or `openai-responses`. | ||
|
|
||
| ## API keys | ||
|
|
||
| Custom backends follow the existing static API key convention: | ||
|
|
||
| - `api_key`, `api_keys`, and `credentials` in YAML are explicit operator credentials. | ||
| - `credentials` take precedence when present because they preserve credential IDs and remote account metadata. | ||
| - If YAML credentials are omitted, `api_key_env_var_root` supplies environment fallback keys. | ||
| - Numbered environment keys use the standard convention: `ROOT`, then `ROOT_2`, `ROOT_3`, and so on. | ||
|
|
||
| For example, `api_key_env_var_root: PROVIDER123_API_KEY` reads `PROVIDER123_API_KEY`, `PROVIDER123_API_KEY_2`, `PROVIDER123_API_KEY_3`, etc. | ||
|
|
||
| ## Model inventory | ||
|
|
||
| By default, custom backends probe the provider for models and register them in the central model registry under `backend_prefix`: | ||
|
|
||
| - OpenAI-compatible backends call `<base_url>/models` with bearer authentication. | ||
| - Anthropic-compatible backends call `<base_url>/v1/models` with `x-api-key` and `anthropic-version` headers. | ||
|
|
||
| Operators can override remote discovery with static `models:` config using the same inline or file inventory shape as other backends. | ||
|
|
||
| ## Example: New OpenAI-compatible provider | ||
|
|
||
| ```yaml | ||
| plugins: | ||
| backends: | ||
| - id: provider123 | ||
| kind: custom-openai-legacy-compatible | ||
| enabled: true | ||
| config: | ||
| backend_prefix: provider123 | ||
| base_url: https://api.provider123.example/v1 | ||
| api_key_env_var_root: PROVIDER123_API_KEY | ||
| ``` | ||
|
|
||
| With this config, route selectors can target discovered models from the `provider123` backend prefix after model inventory refresh. | ||
|
|
||
| ## Example: Static inventory override | ||
|
|
||
| ```yaml | ||
| plugins: | ||
| backends: | ||
| - id: provider123 | ||
| kind: custom-openai-responses-compatible | ||
| enabled: true | ||
| config: | ||
| backend_prefix: provider123 | ||
| base_url: https://api.provider123.example/v1 | ||
| api_key_env_var_root: PROVIDER123_API_KEY | ||
| models: | ||
| source: inline | ||
| items: | ||
| - canonical_id: provider123/deepseek-chat | ||
| native_id: deepseek-chat | ||
| display_name: Provider123 DeepSeek Chat | ||
| ``` | ||
|
|
||
| ## Example: Anthropic-compatible provider | ||
|
|
||
| ```yaml | ||
| plugins: | ||
| backends: | ||
| - id: provider-anthropic | ||
| kind: custom-anthropic-compatible | ||
| enabled: true | ||
| config: | ||
| backend_prefix: provider-anthropic | ||
| base_url: https://api.provider-anthropic.example | ||
| api_key_env_var_root: PROVIDER_ANTHROPIC_API_KEY | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.