Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1cd71f2

Browse files
committed
docs: address feedback on AI Bridge documentation
Splits the AI Bridge documentation into multiple pages to improve readability and navigation.
1 parent458890f commit1cd71f2

File tree

8 files changed

+408
-384
lines changed

8 files changed

+408
-384
lines changed

‎docs/ai-coder/ai-bridge.md‎

Lines changed: 0 additions & 382 deletions
This file was deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#Client Configuration
2+
3+
Once AI Bridge is enabled on the server, your users need to configure their AI coding tools to use it. This section explains how users should configure their clients to connect to AI Bridge.
4+
5+
###Base URLs
6+
7+
The exact configuration method varies by client — some use environment variables, others use configuration files or UI settings:
8+
9+
-**OpenAI-compatible clients**: Set the base URL (commonly via the`OPENAI_BASE_URL` environment variable) to`https://coder.example.com/api/v2/aibridge/openai/v1`
10+
-**Anthropic-compatible clients**: Set the base URL (commonly via the`ANTHROPIC_BASE_URL` environment variable) to`https://coder.example.com/api/v2/aibridge/anthropic`
11+
12+
Replace`coder.example.com` with your actual Coder deployment URL.
13+
14+
###Authentication
15+
16+
Instead of distributing provider-specific API keys (OpenAI/Anthropic keys) to users, they authenticate to AI Bridge using their**Coder session token** or**API key**:
17+
18+
-**OpenAI clients**: Users set`OPENAI_API_KEY` to their Coder session token or API key
19+
-**Anthropic clients**: Users set`ANTHROPIC_API_KEY` to their Coder session token or API key
20+
21+
####Coder Templates Pre-configuration
22+
23+
Template admins can pre-configure authentication in templates using[`data.coder_workspace_owner.me.session_token`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace_owner#session_token-1) to automatically configure the workspace owner's credentials.
24+
25+
Here is an example of how to pre-configure a Coder template to install Claude Code and configure it for AI Bridge using the session token in a template:
26+
27+
```hcl
28+
data "coder_workspace_owner" "me" {}
29+
30+
resource "coder_agent" "dev" {
31+
arch = "amd64"
32+
os = "linux"
33+
dir = local.repo_dir
34+
env = {
35+
ANTHROPIC_BASE_URL : "https://dev.coder.com/api/v2/aibridge/anthropic",
36+
ANTHROPIC_AUTH_TOKEN : data.coder_workspace_owner.me.session_token
37+
}
38+
... # other agent configuration
39+
}
40+
41+
# See https://registry.coder.com/modules/coder/claude-code for more information
42+
module "claude-code" {
43+
count = local.has_ai_prompt ? data.coder_workspace.me.start_count : 0
44+
source = "dev.registry.coder.com/coder/claude-code/coder"
45+
version = ">= 3.2.0"
46+
agent_id = coder_agent.dev.id
47+
workdir = "/home/coder/project"
48+
order = 999
49+
claude_api_key = data.coder_workspace_owner.me.session_token # To Enable AI Bridge integration
50+
ai_prompt = data.coder_parameter.ai_prompt.value
51+
... # other claude-code configuration
52+
}
53+
54+
```
55+
56+
The same approach can be applied to pre-configure additional AI coding assistants by updating the base URL and API key settings.
57+
58+
####Generic API key generation
59+
60+
Users can generate a Coder API key using either the CLI or the web UI. Follow the instructions at[Sessions and API tokens](../../admin/users/sessions-tokens.md#generate-a-long-lived-api-token-on-behalf-of-yourself) to generate a Coder API key.
61+
62+
###Tested clients
63+
64+
The combinations below reflect what we have exercised so far. Use the upstream links for vendor-specific steps to point each client at Bridge. Share additional findings in the[`aibridge`](https://github.com/coder/aibridge) issue tracker so we can keep this table current.
65+
66+
| Client| OpenAI support| Anthropic support| Notes|
67+
|-------------------------------------------------------------------------------------------------------------------------------------------|----------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
68+
|[Claude Code](https://docs.claude.com/en/docs/claude-code/settings#environment-variables)| N/A|| Works out of the box and can be preconfigured in templates.|
69+
| Claude Code (VS Code)| N/A|| May require signing in once; afterwards respects workspace environment variables.|
70+
|[Cursor](https://cursor.com/docs/settings/api-keys)| ⚠️|| Only non reasoning models like`gpt-4.1` are available when using a custom endpoint. Requests still transit Cursor's cloud. There is no central admin setting to configure this.|
71+
|[Roo Code](https://docs.roocode.com/features/api-configuration-profiles#creating-and-managing-profiles)||| Use the**OpenAI Compatible** provider with the legacy format to avoid`/v1/responses`.|
72+
|[Codex CLI](https://github.com/openai/codex/blob/main/docs/config.md#model_providers)|| N/A|`gpt-5-codex` support is[in progress](https://github.com/coder/aibridge/issues/16).|
73+
|[GitHub Copilot (VS Code)](https://docs.github.com/en/copilot/configuring-github-copilot/configuring-network-settings-for-github-copilot)||| Requires the pre-release extension. Anthropic endpoints are not supported.|
74+
| Goose||||
75+
| Goose Desktop||||
76+
| WindSurf||| No option to override the base URL.|
77+
| Sourcegraph Amp||| No option to override the base URL.|
78+
| Kiro||| No option to override the base URL.|
79+
|[Copilot CLI](https://github.com/github/copilot-cli/issues/104)||| No support for custom base URLs and uses a`GITHUB_TOKEN` for authentication.|
80+
|[Kilo Code](https://kilocode.ai/docs/features/api-configuration-profiles#creating-and-managing-profiles)||| Similar to Roo Code.|
81+
| Gemini CLI||| Not supported yet (`GOOGLE_GEMINI_BASE_URL`).|
82+
|[Amazon Q CLI](https://aws.amazon.com/q/)||| Limited to Amazon Q subscriptions; no custom endpoint support.|
83+
84+
Legend: ✅ works, ⚠️ limited support, ❌ not supported, ❓ not yet verified, — not applicable.
85+
86+
>[!NOTE]
87+
>Click the respective client title to view the vendor-specific instructions for configuring the client.
88+
89+
####Compatibility overview
90+
91+
Most AI coding assistants that support custom base URLs can work with AI Bridge. Client-specific requirements vary:
92+
93+
- Some clients require specific URL formats (for example, removing the`/v1` suffix).
94+
- Some clients proxy requests through their own servers, which limits compatibility.
95+
- Some clients do not support custom base URLs.
96+
97+
See the[tested clients](#tested-clients) table above for the combinations we have verified and any known issues.

‎docs/ai-coder/ai-bridge/index.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#AI Bridge
2+
3+
![AI bridge diagram](../../images/aibridge/aibridge_diagram.png)
4+
5+
Bridge is a smart proxy for AI. It acts as a man-in-the-middle between your users' coding agents / IDEs
6+
and providers like OpenAI and Anthropic. By intercepting all the AI traffic between these clients and
7+
the upstream APIs, Bridge can record user prompts, token usage, and tool invocations.
8+
9+
Bridge solves 3 key problems:
10+
11+
1.**Centralized authn/z management**: no more issuing & managing API tokens for OpenAI/Anthropic usage.
12+
Users use their Coder session or API tokens to authenticate with`coderd` (Coder control plane), and
13+
`coderd` securely communicates with the upstream APIs on their behalf. Use a single key for all users.
14+
2.**Auditing and attribution**: all interactions with AI services, whether autonomous or human-initiated,
15+
will be audited and attributed back to a user.
16+
3.**Centralized MCP administration**: define a set of approved MCP servers and tools which your users may
17+
use, and prevent users from using their own.
18+
19+
##When to use AI Bridge
20+
21+
As the library of LLMs and their associated tools grow, administrators are pressured to provide auditing, measure adoption, provide tools through MCP, and track token spend. Disparate SAAS platforms provide_some_ of these for_some_ tools, but there is no centralized, secure solution for these challenges.
22+
23+
If you are an administrator or devops leader looking to:
24+
25+
- Measure AI tooling adoption across teams or projects
26+
- Provide an LLM audit trail to security administrators
27+
- Manage token spend in a central dashboard
28+
- Investigate opportunities for AI automation
29+
- Uncover the high-leverage use cases from experienced engineers
30+
31+
We advise trying Bridge as self-hosted proxy to monitor LLM usage agnostically across AI powered IDEs like Cursor and headless agents like Claude Code.

‎docs/ai-coder/ai-bridge/mcp.md‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#MCP
2+
3+
[Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro) is a mechanism for connecting AI applications to external systems.
4+
5+
Bridge can connect to MCP servers and inject tools automatically, enabling you to centrally manage the list of tools you wish to grant your users.
6+
7+
>[!NOTE]
8+
>Only MCP servers which support OAuth2 Authorization are supported currently. In future releases we will support[optional authorization](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization#protocol-requirements).
9+
>
10+
>[_Streamable HTTP_](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) is the only supported transport currently. In future releases we will support the (now deprecated)[_Server-Sent Events_](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#backwards-compatibility) transport.
11+
12+
Bridge makes use of[External Auth](../../admin/external-auth/index.md) applications, as they define OAuth2 connections to upstream services. If your External Auth application hosts a remote MCP server, you can configure Bridge to connect to it, retrieve its tools and inject them into requests automatically - all while using each individual user's access token.
13+
14+
For example, GitHub has a[remote MCP server](https://github.com/github/github-mcp-server?tab=readme-ov-file#remote-github-mcp-server) and we can use it as follows.
15+
16+
```bash
17+
CODER_EXTERNAL_AUTH_0_TYPE=github
18+
CODER_EXTERNAL_AUTH_0_CLIENT_ID=...
19+
CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=...
20+
# Tell Bridge where it can find this service's remote MCP server.
21+
CODER_EXTERNAL_AUTH_0_MCP_URL=https://api.githubcopilot.com/mcp/
22+
```
23+
24+
See the diagram in[Implementation Details](../reference#implementation-details) for more information.
25+
26+
You can also control which tools are injected by using an allow and/or a deny regular expression on the tool names:
27+
28+
```bash
29+
CODER_EXTERNAL_AUTH_0_MCP_TOOL_ALLOW_REGEX=(.+_gist.*)
30+
CODER_EXTERNAL_AUTH_0_MCP_TOOL_DENY_REGEX=(create_gist)
31+
```
32+
33+
In the above example, all tools containing`_gist` in their name will be allowed, but`create_gist` is denied.
34+
35+
The logic works as follows:
36+
37+
- If neither the allow/deny patterns are defined, all tools will be injected.
38+
- The deny pattern takes precedence.
39+
- If only a deny pattern is defined, all tools are injected except those explicitly denied.
40+
41+
In the above example, if you prompted your AI model with "list your available github tools by name", it would reply something like:
42+
43+
>Certainly! Here are the GitHub-related tools that I have available:
44+
>
45+
>1.`bmcp_github_update_gist`
46+
>2.`bmcp_github_list_gists`
47+
48+
Bridge marks automatically injected tools with a prefix`bmcp_` ("bridged MCP"). It also namespaces all tool names by the ID of their associated External Auth application (in this case`github`).
49+
50+
##Using AI Bridge with Coder Tasks
51+
52+
[Coder Tasks](../../workspaces/tasks.md) provides a chat-first interface for terminal agents such as Claude Code CLI or Codex. To route those agents through Bridge:
53+
54+
- Enable Bridge at the control plane and configure the upstream provider keys.
55+
- Inject the AI Bridge base URLs and API keys into the Task environment (for example by setting`OPENAI_BASE_URL` and`OPENAI_API_KEY`).
56+
- Template authors can bake these variables into Task definitions so that new runs automatically use Bridge.
57+
58+
This setup keeps agent execution within Coder while applying the same auditing and MCP policies as IDE clients.
59+
60+
##Using AI Bridge without Tasks
61+
62+
Bridge also works with IDE-native assistants inside workspaces. Configure the IDE extension or desktop client to point at the Bridge endpoints and rely on the workspace's environment variables for authentication. This is the fastest path to bring existing agents like Roo Code, Cursor, or Claude Code into compliance without adopting Tasks.
63+
64+
##Tool Injection
65+
66+
If a model decides to invoke a tool and it has a`bmcp_` suffix and Bridge has a connection with the related MCP server, it will invoke the tool. The tool result will be passed back to the upstream AI provider, and this will loop until the model has all of its required data. These inner loops are not relayed back to the client; all it seems is the result of this loop. See[Implementation Details](../reference#implementation-details).
67+
68+
In contrast, tools which are defined by the client (i.e. the[`Bash` tool](https://docs.claude.com/en/docs/claude-code/settings#tools-available-to-claude) defined by_Claude Code_) cannot be invoked by Bridge, and the tool call from the model will be relayed to the client, after which it will invoke the tool.
69+
70+
If you have the`oauth2` and`mcp-server-http` experiments enabled, Coder's own[internal MCP tools](../mcp-server.md) will be injected automatically.
71+
72+
###Troubleshooting
73+
74+
-**Too many tools**: should you receive an error like`Invalid 'tools': array too long. Expected an array with maximum length 128, but got an array with length 132 instead`, you can reduce the number by filtering out tools using the allow/deny patterns documented in the[MCP](#mcp) section.
75+
76+
-**Coder MCP tools not being injected**: in order for Coder MCP tools to be injected, the internal MCP server needs to be active. Follow the instructions in the[MCP Server](../mcp-server.md) page to enable it.
77+
78+
-**External Auth tools not being injected**: this is generally due to the requesting user not being authenticated against the External Auth app; when this is the case, no attempt is made to connect to the MCP server.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#Monitoring
2+
3+
Bridge records the last`user` prompt, token usage, and every tool invocation for each intercepted request. Each capture is tied to a single "interception" that maps back to the authenticated Coder identity, making it easy to attribute spend and behaviour.
4+
5+
![User Prompt logging](../../images/aibridge/grafana_user_prompts_logging.png)
6+
7+
![User Leaderboard](../../images/aibridge/grafana_user_leaderboard.png)
8+
9+
We provide an example Grafana dashboard that you can import as a starting point for your metrics. See[the Grafana dashboard README](https://github.com/coder/coder/blob/main/examples/monitoring/dashboards/grafana/aibridge/README.md).
10+
11+
These logs and metrics can be used to determine usage patterns, track costs, and evaluate tooling adoption.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp