docs: byok docs (#24032)

## Summary

Adds BYOK (Personal API Key) documentation for OpenCode.

## BYOK support

| Client | Personal API Key | ChatGPT Subscription | Claude Subscription
|

|--------------|------------------|----------------------|---------------------|
| Codex CLI |  |  | - |
| Claude Code |  | - |  |
| Mux     | ?              | ?                   | ?                 |
| OpenCode |  |  |  |
| Factory |  |  |  |
| Cline |  Only OpenAI API |  |  |
| KiloCode |  (client-side bug) |  |  |
| RooCode |  Only OpenAI API |  |  |
| VSCode |  |  |  |
| JetBrains |  |  |  |
| Zed     |               |                    |                   |
| Copilot CLI | ? | ? | ? |

<details>
<summary>Why OpenCode doesn't support subscriptions through AI
Bridge</summary>

**ChatGPT subscription**: OpenCode's codex plugin [hardcodes the
upstream
URL](https://github.com/anomalyco/opencode/blob/3a0e00dd7f9192730f6d0eeee37ae0a5fb023927/packages/opencode/src/plugin/codex.ts#L458-L460)
to `https://chatgpt.com/backend-api/codex/responses` inside a custom
`fetch`, bypassing any configured `baseURL`.

**Claude subscription**: Anthropic [no longer
supports](https://www.reddit.com/r/ClaudeAI/comments/1r9hqdk/claude_subscriptions_will_no_longer_be_usable_in/)
using subscriptions in third-party clients.

</details>
 
## Notes

- Anthropic forbids Claude subscription in all 3rd-party clients
- OpenCode supports ChatGPT subscription, but there is no way to
customize BaseURL
- Does it make sense to investigate Mux?
- Factory doesn't support ChatGPT subscription
- Cline supports ChatGPT subscription, but there is no way to customize
BaseURL
- KiloCode supports CustomHeaders, but I wasn't able to make it work
neither for centralized key nor for BYOK. Seems support for custom
providers has bugs. I got different errors for different models, this
one is common:
`Unsupported parameter: 'max_tokens' is not supported with this model.
Use 'max_completion_tokens' instead.` Seems should be fixed on KiloCode
side.
- RooCode and Cline support only OpenAI. They have special
OpenAI-Compatible provider which allows adding custom headers.
- VSCode (NativeChat) uses github copilot under the hood. I wasn't able
to make it work, neither in VSCode nor in VSCode-Insiders on my MacOS. I
used VSCode-Insiders Version: 1.116.0-insider (Universal). I got
different errors. When I used Github Copilot Chat (stable release - it
ignored my AI Gateway configuration), when I tried to install Github
Copilot Chat pre-release it failed with
`~/.vscode-insiders/extensions/github.copilot-chat-0.43.2026040705`
- JetBrains (embedded AI assistant). OpenAI Compatible provider doesn't
support custom headers. Also I got some errors even for centralized key
setup.
- Zed doesn't support custom headers
- Copilot CLI is special, because it's only supported via gateway proxy.
But it also means that we don't need support of custom headers, because
`X-AI-Gov-Token` is set by proxy itself. So if BYOK is supported in
CopilotCLI - it should be supported for CopilotCLI via Bridge and
BridgeProxy.
## Questions
- Do we want to explicitly state that Claude Max/Pro or ChatGPT Plus/Pro
subscriptions aren’t supported by OpenCode via AIBridge? I initially
avoided mentioning it since this could change over time, and keeping
that information up to date across clients might be difficult.
This commit is contained in:
Yevhenii Shcherbina
2026-04-13 15:06:54 -04:00
committed by GitHub
parent 8382e96a81
commit ff6f5893df
10 changed files with 147 additions and 9 deletions
+20
View File
@@ -7,6 +7,8 @@ Cline supports both OpenAI and Anthropic models and can be configured to use AI
To configure Cline to use AI Gateway, follow these steps:
![Cline Settings](../../../images/aibridge/clients/cline-setup.png)
## Centralized API Key
<div class="tabs">
### OpenAI Compatible
@@ -33,4 +35,22 @@ To configure Cline to use AI Gateway, follow these steps:
</div>
## BYOK (Personal API Key)
<div class="tabs">
### OpenAI Compatible
1. Open Cline in VS Code.
1. Go to **Settings**.
1. **API Provider**: Select **OpenAI Compatible**.
1. **Base URL**: Enter `https://coder.example.com/api/v2/aibridge/openai/v1`.
1. **OpenAI Compatible API Key**: Enter your personal OpenAI API key.
1. **Model ID** (Optional): Enter the model you wish to use (e.g., `gpt-5.2-codex`).
1. **Custom Headers**: Add `X-Coder-AI-Governance-Token` with your **[Coder Session Token](../../../admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)**.
![Cline BYOK OpenAI Settings](../../../images/aibridge/clients/cline-byok-openai.png)
</div>
**References:** [Cline Configuration](https://github.com/cline/cline)
+39 -2
View File
@@ -2,7 +2,7 @@
Factort's Droid agent can be configured to use AI Gateway by setting up custom models for OpenAI and Anthropic.
## Configuration
## Centralized API Key
1. Open `~/.factory/settings.json` (create it if it does not exist).
2. Add a `customModels` entry for each provider you want to use with AI Gateway.
@@ -13,7 +13,7 @@ Factort's Droid agent can be configured to use AI Gateway by setting up custom m
{
"customModels": [
{
"model": "claude-4-5-opus",
"model": "claude-sonnet-4-5-20250929",
"displayName": "Claude (Coder AI Bridge)",
"baseUrl": "https://coder.example.com/api/v2/aibridge/anthropic",
"apiKey": "<your-coder-session-token>",
@@ -32,4 +32,41 @@ Factort's Droid agent can be configured to use AI Gateway by setting up custom m
}
```
## BYOK (Personal API Key)
1. Open `~/.factory/settings.json` (create it if it does not exist).
2. Add a `customModels` entry for each provider you want to use with AI Bridge.
3. Replace `coder.example.com` with your Coder deployment URL.
4. Use your personal API key for `apiKey`.
5. Set the `X-Coder-AI-Governance-Token` header to your **[Coder session token](../../../admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)**.
```json
{
"customModels": [
{
"model": "claude-sonnet-4-5-20250929",
"displayName": "Claude (Coder AI Bridge)",
"baseUrl": "https://coder.example.com/api/v2/aibridge/anthropic",
"apiKey": "<your-anthropic-api-key>",
"provider": "anthropic",
"maxOutputTokens": 8192,
"extraHeaders": {
"X-Coder-AI-Governance-Token": "<your-coder-session-token>"
}
},
{
"model": "gpt-5.2-codex",
"displayName": "GPT (Coder AI Bridge)",
"baseUrl": "https://coder.example.com/api/v2/aibridge/openai/v1",
"apiKey": "<your-openai-api-key>",
"provider": "openai",
"maxOutputTokens": 16384,
"extraHeaders": {
"X-Coder-AI-Governance-Token": "<your-coder-session-token>"
}
}
]
}
```
**References:** [Factory BYOK OpenAI & Anthropic](https://docs.factory.ai/cli/byok/openai-anthropic)
@@ -7,7 +7,7 @@ JetBrains IDE (IntelliJ IDEA, PyCharm, WebStorm, etc.) support AI Gateway via th
* [**JetBrains AI Assistant**](https://www.jetbrains.com/help/ai-assistant/installation-guide-ai-assistant.html): Installed and enabled.
* **Authentication**: Your **[Coder session token](../../../admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)**.
## Configuration
## Centralized API Key
1. **Open Settings**: Go to **Settings** > **Tools** > **AI Assistant** > **Models & API Keys**.
1. **Configure Provider**: Go to **Third-party AI providers**.
@@ -32,4 +32,9 @@ You can now use the AI Assistant chat with the configured provider.
> * JetBrains AI Assistant currently only supports OpenAI-compatible endpoints. There is an open [issue](https://youtrack.jetbrains.com/issue/LLM-22740) tracking support for Anthropic.
> * JetBrains AI Assistant may not support all models that support OPenAI's `/chat/completions` endpoint in Chat mode.
## BYOK (Personal API Key)
> [!NOTE]
> At the time of writing, JetBrains AI Assistant does not support sending custom headers, so BYOK mode is not available.
**References:** [Use custom models with JetBrains AI Assistant](https://www.jetbrains.com/help/ai-assistant/use-custom-models.html#provide-your-own-api-key)
@@ -2,7 +2,7 @@
Kilo Code allows you to configure providers via the UI and can be set up to use AI Gateway.
## Configuration
## Centralized API Key
<div class="tabs">
@@ -30,4 +30,9 @@ Kilo Code allows you to configure providers via the UI and can be set up to use
</div>
## BYOK (Personal API Key)
> [!NOTE]
> Kilo Code supports sending custom headers, but the integration does not currently work reliably with AI Gateway.
**References:** [Kilo Code Configuration](https://kilocode.ai/docs/ai-providers/openai-compatible)
+44 -3
View File
@@ -2,7 +2,7 @@
OpenCode supports both OpenAI and Anthropic models and can be configured to use AI Gateway by setting custom base URLs for each provider.
## Configuration
## Centralized API Key
You can configure OpenCode to connect to AI Gateway by setting the following configuration options in your OpenCode configuration file (e.g., `~/.config/opencode/opencode.json`):
@@ -24,8 +24,6 @@ You can configure OpenCode to connect to AI Gateway by setting the following con
}
```
## Authentication
To authenticate with AI Gateway, get your **[Coder session token](../../../admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)** and replace `<your-coder-session-token>` in `~/.local/share/opencode/auth.json`
```json
@@ -41,4 +39,47 @@ To authenticate with AI Gateway, get your **[Coder session token](../../../admin
}
```
## BYOK (Personal API Key)
Set the following in `~/.config/opencode/opencode.json`, including the `X-Coder-AI-Governance-Token` header with your Coder session token:
```json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://coder.example.com/api/v2/aibridge/anthropic/v1",
"headers": {
"X-Coder-AI-Governance-Token": "<your-coder-session-token>"
}
}
},
"openai": {
"options": {
"baseURL": "https://coder.example.com/api/v2/aibridge/openai/v1",
"headers": {
"X-Coder-AI-Governance-Token": "<your-coder-session-token>"
}
}
}
}
}
```
Set your personal API keys in `~/.local/share/opencode/auth.json`:
```json
{
"anthropic": {
"type": "api",
"key": "<your-anthropic-api-key>"
},
"openai": {
"type": "api",
"key": "<your-openai-api-key>"
}
}
```
**References:** [OpenCode Documentation](https://opencode.ai/docs/providers/#config)
@@ -6,6 +6,8 @@ Roo Code allows you to configure providers via the UI and can be set up to use A
Roo Code allows you to configure providers via the UI.
## Centralized API Key
<div class="tabs">
### OpenAI Compatible
@@ -36,4 +38,22 @@ Roo Code allows you to configure providers via the UI.
* If you encounter issues with the **OpenAI** provider type, use **OpenAI Compatible** to ensure correct endpoint routing.
* Ensure your Coder deployment URL is reachable from your VS Code environment.
## BYOK (Personal API Key)
<div class="tabs">
### OpenAI Compatible
1. Open Roo Code in VS Code.
1. Go to **Settings**.
1. **Provider**: Select **OpenAI Compatible**.
1. **Base URL**: Enter `https://coder.example.com/api/v2/aibridge/openai/v1`.
1. **API Key**: Enter your personal OpenAI API key.
1. **Model ID**: Enter the model you wish to use (e.g., `gpt-4o`).
1. **Custom Headers**: Add `X-Coder-AI-Governance-Token` with your **[Coder Session Token](../../../admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself)**.
![Roo Code BYOK OpenAI Settings](../../../images/aibridge/clients/roo-code-byok-openai.png)
</div>
**References:** [Roo Code Configuration Profiles](https://docs.roocode.com/features/api-configuration-profiles#creating-and-managing-profiles)
+6 -1
View File
@@ -2,7 +2,7 @@
VS Code's native chat can be configured to use AI Gateway with the GitHub Copilot Chat extension's custom language model support.
## Configuration
## Centralized API Key
> [!IMPORTANT]
> You need the **Pre-release** version of the [GitHub Copilot Chat extension](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat) and [VS Code Insiders](https://code.visualstudio.com/insiders/).
@@ -47,4 +47,9 @@ _Replace `coder.example.com` with your Coder deployment URL._
> [!NOTE]
> The setting names may change as the feature moves from pre-release to stable. Refer to the official documentation for the latest setting keys.
## BYOK (Personal API Key)
> [!NOTE]
> At the time of writing, GitHub Copilot Chat does not support sending custom headers, so BYOK mode is not available.
**References:** [GitHub Copilot - Bring your own language model](https://code.visualstudio.com/docs/copilot/customization/language-models#_add-an-openaicompatible-model)
+6 -1
View File
@@ -2,7 +2,7 @@
Zed IDE supports AI Gateway via its `language_models` configuration in `settings.json`.
## Configuration
## Centralized API Key
To configure Zed to use AI Gateway, you need to edit your `settings.json` file. You can access this by pressing `Cmd/Ctrl + ,` or opening the command palette and searching for "Open Settings".
@@ -60,4 +60,9 @@ You can set this in two ways:
</div>
## BYOK (Personal API Key)
> [!NOTE]
> At the time of writing, Zed Agent does not support sending custom headers, so BYOK mode is not available.
**References:** [Configuring Zed - Language Models](https://zed.dev/docs/reference/all-settings#language-models)
Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB