Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 docs: add client configuration section and examples to AI Bridge by matifali · Pull Request #20340 · coder/coder · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content

Conversation

matifali
Copy link
Member
@matifali matifali commented Oct 16, 2025

Partially written by Claude Code

- 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
Comment on lines 92 to 93
- **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/`
Copy link
Member

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

Copy link
Member

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


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 😞

Comment on lines 92 to 93
- **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/`
Copy link
Member

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


### A 10BC0 uthentication

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
8000 # 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" {

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.
8809 @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0