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

Commit420c4c2

Browse files
committed
docs: add client configuration section and examples to AI Bridge
1 parent69c2c40 commit420c4c2

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

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

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,100 @@ Bridge is compatible with _[Google Vertex AI](https://cloud.google.com/vertex-ai
8181
>[!NOTE]
8282
>See[Supported APIs](#supported-apis) section below for a comprehensive list.
8383
84+
##Client Configuration
85+
86+
Once Bridge is enabled and configured on the server side, you need to configure your AI clients (IDEs, agents, CLI tools) to route their requests through Bridge instead of directly to OpenAI or Anthropic.
87+
88+
###Setting Base URLs
89+
90+
Configure your AI client to point to your Coder deployment's Bridge endpoints:
91+
92+
-**OpenAI-compatible clients**: Set`OPENAI_BASE_URL` to`https://coder.example.com/api/v2/api/experimental/aibridge/openai/v1/`
93+
-**Anthropic-compatible clients**: Set`ANTHROPIC_BASE_URL` to`https://coder.example.com/api/v2/api/experimental/aibridge/anthropic/`
94+
95+
Replace`coder.example.com` with your actual Coder deployment URL.
96+
97+
###Authentication
98+
99+
Instead of using provider-specific API keys (OpenAI/Anthropic keys), clients authenticate using your**Coder session token** or**API key**:
100+
101+
-**OpenAI clients**: Set`OPENAI_API_KEY` to your Coder session token or API key
102+
-**Anthropic clients**: Set`ANTHROPIC_API_KEY` to your Coder session token or API key
103+
104+
You can generate a Coder API key using:
105+
106+
```sh
107+
coder tokens create
108+
```
109+
110+
###Configuration Examples
111+
112+
####Claude Code CLI
113+
114+
Configure Claude Code to use Bridge:
115+
116+
```sh
117+
export ANTHROPIC_BASE_URL="https://coder.example.com/api/v2/api/experimental/aibridge/anthropic/"
118+
export ANTHROPIC_API_KEY="your-coder-session-token"
119+
```
120+
121+
####Custom Scripts
122+
123+
Any tool that supports custom base URLs can be configured similarly:
124+
125+
```python
126+
import openai
127+
128+
client= openai.OpenAI(
129+
base_url="https://coder.example.com/api/v2/api/experimental/aibridge/openai/v1/",
130+
api_key="your-coder-session-token"
131+
)
132+
```
133+
134+
###Pre-configuring in Coder Templates
135+
136+
For the best user experience, you can pre-configure AI Bridge settings in your Coder templates so that users don't need to manually set environment variables. This is especially useful for:
137+
138+
-**IDE workspaces** (VS Code, Cursor, JetBrains) where AI extensions are used
139+
-**Agent workspaces** where tools like Goose or Claude Code run
140+
-**Development environments** that include AI tooling out of the box
141+
142+
Coder provides the[`data.coder_workspace_owner.me.session_token`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace_owner) data source which gives you access to the workspace owner's session token. This token automatically authenticates requests through Bridge.
143+
144+
####Configuring AI Agents in Tasks
145+
146+
For Coder Tasks templates, you can pre-configure agents to use Bridge:
147+
148+
```tf
149+
# For Claude Code
150+
151+
data "coder_workspace_owner" "me" {}
152+
153+
module "claude-code" {
154+
source = "registry.coder.com/coder/claude-code/coder"
155+
version = "3.0.1"
156+
agent_id = coder_agent.main.id
157+
workdir = "/home/coder/project"
158+
ai_prompt = data.coder_parameter.ai_prompt.value
159+
160+
# Use Bridge instead of direct Anthropic API
161+
claude_api_key = data.coder_workspace_owner.me.session_token
162+
}
163+
164+
resource "coder_env" "bridge_base_url" {
165+
workspace_id = coder_workspace.main.id
166+
name = "ANTHROPIC_BASE_URL"
167+
value = "${data.coder_workspace.me.access_url}/api/v2/api/experimental/aibridge/"
168+
}
169+
170+
#### Benefits of Template Pre-configuration
171+
172+
- **Zero user configuration**: Users get AI tooling that works out of the box
173+
- **Centralized management**: Admins control AI provider access through Bridge
174+
- **Automatic authentication**: Session tokens are managed by Coder automatically
175+
- **Consistent environment**: All workspaces use the same AI configuration
176+
- **Audit trail**: All AI usage is automatically tracked through Bridge
177+
84178
## Collected Data
85179
86180
Bridge collects:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp