-
Notifications
You must be signed in to change notification settings - Fork 1k
docs: add client configuration section and examples to AI Bridge #20340
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
base: main
Are you sure you want to change the base?
Conversation
- Add comprehensive Client Configuration section explaining how to set OPENAI_BASE_URL and ANTHROPIC_BASE_URL to point to AI Bridge - Document authentication using Coder session tokens instead of provider keys - Add configuration examples for Claude Code CLI and custom scripts - Add Pre-configuring in Coder Templates subsection showing how to use data.coder_workspace_owner.me.session_token for automatic setup - Include Terraform example for configuring AI agents in Tasks templates - Fix unbalanced code fence that was causing markdown linting errors
docs/ai-coder/ai-bridge.md
Outdated
- **OpenAI-compatible clients**: Set `OPENAI_BASE_URL` to `https://coder.example.com/api/v2/api/experimental/aibridge/openai/v1/` | ||
- **Anthropic-compatible clients**: Set `ANTHROPIC_BASE_URL` to `https://coder.example.com/api/v2/api/experimental/aibridge/anthropic/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not /api/v2/api/experimental
, just /api/experimental
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a problem throughout the whole file as well
docs/ai-coder/ai-bridge.md
Outdated
|
||
Configure your AI client to point to your Coder deployment's Bridge endpoints: | ||
|
||
- **OpenAI-compatible clients**: Set `OPENAI_BASE_URL` to `https://coder.example.com/api/v2/api/experimental/aibridge/openai/v1/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes it's just .../aibridge/openai
and not .../aibrdige/openai/v1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed; it depends on the client 😞
docs/ai-coder/ai-bridge.md
Outdated
- **OpenAI-compatible clients**: Set `OPENAI_BASE_URL` to `https://coder.example.com/api/v2/api/experimental/aibridge/openai/v1/` | ||
- **Anthropic-compatible clients**: Set `ANTHROPIC_BASE_URL` to `https://coder.example.com/api/v2/api/experimental/aibridge/anthropic/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing slashes probably not required
|
||
### Authentication | ||
|
||
Instead of using provider-specific API keys (OpenAI/Anthropic keys), clients authenticate using your **Coder session token** or **API key**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using provider-specific API keys (OpenAI/Anthropic keys), clients authenticate using your **Coder session token** or **API key**: | |
Instead of using provider-specific API keys (OpenAI/Anthropic keys), clients authenticate using their **Coder session token** or **API key**: |
|
||
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: | ||
|
||
- **IDE workspaces** (VS Code, Cursor, JetBrains) where AI extensions are used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template settings don't boil down to IDEs by default (except terminal agents like claude
).
docs/ai-coder/ai-bridge.md
Outdated
|
||
Configure your AI client to point to your Coder deployment's Bridge endpoints: | ||
|
||
- **OpenAI-compatible clients**: Set `OPENAI_BASE_URL` to `https://coder.example.com/api/v2/api/experimental/aibridge/openai/v1/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed; it depends on the client 😞
) | ||
``` | ||
|
||
### Pre-configuring in Coder Templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Coder-specific use-cases should appear first.
- **Agent workspaces** where tools like Goose or Claude Code run | ||
- **Development environments** that include AI tooling out of the box | ||
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. < 8000 a class="Link--inTextBlock" href="https://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment" aria-label="Learn more about hiding disruptive comments">Learn more.
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. | |
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 is authenticated when requests are routed through AI Bridge. |
|
||
#### Configuring AI Agents in Tasks | ||
|
||
For Coder Tasks templates, you can pre-configure agents to use Bridge: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Coder Tasks templates, you can pre-configure agents to use Bridge: | |
For Coder Tasks templates, you can pre-configure agents to use AI Bridge: |
workdir = "/home/coder/project" | ||
ai_prompt = data.coder_parameter.ai_prompt.value | ||
# Use Bridge instead of direct Anthropic API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Use Bridge instead of direct Anthropic API | |
# Use AI Bridge instead of direct Anthropic API |
claude_api_key = data.coder_workspace_owner.me.session_token | ||
} | ||
resource "coder_env" "bridge_base_url" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource "coder_env" "bridge_base_url" { | |
resource "coder_env" "ai_bridge_base_url" { |
Corrected all AI Bridge client configuration URLs to include the /v1 suffix based on source code verification: - OpenAI: /api/experimental/aibridge/openai/v1 (was missing /v1) - Anthropic: /api/experimental/aibridge/anthropic/v1 (was missing /v1) Verified from enterprise/x/aibridged/aibridged_test.go which shows: - /openai/v1/chat/completions - /anthropic/v1/messages Updated in all configuration examples: - Setting Base URLs section - Claude Code CLI example - Custom Python scripts example - Terraform template example
Corrected Anthropic base URL configuration based on official dogfood template (commit 61fba2d): - Anthropic SDK appends /v1/messages to base URL - Therefore base URL should NOT include /v1 - Verified from dogfood/coder/main.tf which uses: ANTHROPIC_BASE_URL: "https://dev.coder.com/api/experimental/aibridge/anthropic" Final correct URLs: - OpenAI: .../openai/v1 (SDK appends /chat/completions) - Anthropic: .../anthropic (SDK appends /v1/messages) This ensures compatibility with official Anthropic Python SDK and tools like Claude Code that follow the same pattern.
Moving to draft as I am doing a larger refactor and adding more examples for all clients we have tested. |
Partially written by Claude Code