Skip to content

Conversation

@matifali
Copy link
Member

@matifali matifali commented Oct 16, 2025

Partially written by Claude Code


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/`
Copy link
Member

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

Copy link
Contributor

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 😞


### Authentication

Instead of using provider-specific API keys (OpenAI/Anthropic keys), clients authenticate using your **Coder session token** or **API key**:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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).


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/`
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resource "coder_env" "bridge_base_url" {
resource "coder_env" "ai_bridge_base_url" {

@matifali matifali marked this pull request as draft October 16, 2025 14:58
@matifali
Copy link
Member Author

Moving to draft as I am doing a larger refactor and adding more examples for all clients we have tested.

matifali and others added 6 commits October 22, 2025 10:48
- 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
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.
Split AI Bridge documentation from single 530-line file into focused,
audience-specific pages for better organization and maintainability.

## Changes

### Structure
- Delete single-page docs/ai-coder/ai-bridge.md
- Create docs/ai-coder/ai-bridge/ directory with 7 pages:
  - index.md: Main overview, setup, general config, SDKs, templates
  - roo-code.md: Roo Code configuration
  - claude-code.md: Claude Code CLI and VSCode
  - cursor.md: Cursor IDE
  - github-copilot.md: GitHub Copilot (VSCode + CLI status)
  - goose.md: Goose Desktop and CLI
  - other-clients.md: Kilo Code and unsupported clients

### Content Organization
- Platform teams: Server setup in index.md
- Template admins: Template patterns in index.md + client pages
- End users: Client-specific configuration in dedicated pages
- Developers: SDK examples in index.md

### Quality Improvements
- Fix all markdown linting errors (8 total)
- Remove trailing spaces from all files
- Fix broken internal links
- Update client table with links to new pages
- Use proper heading hierarchy (h4 instead of h5)
- Use auto-numbering for ordered lists (1/1/1 style)

### Benefits
- Easier maintenance (update one client without affecting others)
- Better user experience (focused guides vs scrolling large file)
- Clear audience separation (platform/admin/end-user)
- Improved navigation (table links to dedicated pages)
@matifali matifali force-pushed the aibridge-provider-docs branch from 1a11811 to e524206 Compare October 22, 2025 05:49
@github-actions github-actions bot added the stale This issue is like stale bread. label Oct 30, 2025
@matifali
Copy link
Member Author

matifali commented Nov 1, 2025

closing in favour of #20640

@matifali matifali closed this Nov 1, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants