🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

feat: add /api/v2/ai-gateway API route aliases - #26475

Merged
ssncferreira merged 6 commits into
mainfrom
ssncf/ai-gateway-api-aliases
Jun 23, 2026
Merged

feat: add /api/v2/ai-gateway API route aliases#26475
ssncferreira merged 6 commits into
mainfrom
ssncf/ai-gateway-api-aliases

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

Registers /api/v2/ai-gateway/* as the new API path for AI Gateway, replacing /api/v2/aibridge/*. Both prefixes share the same route builder (aiBridgeRoutes) backed by a single in-memory handler, so existing /aibridge endpoints continue to work. New endpoints must be registered on the enterprise API handler under /api/v2/ai-gateway only.

Swagger annotations now point to /api/v2/ai-gateway paths with a backward-compatibility note referencing /aibridge. The legacy /aibridge routes are skipped in the swagger documentation test.

Changes

  • Store one raw handler (aiGatewayHandler) instead of two prefix-stripped handlers
  • Register /ai-gateway and /ai-gateway/proxy route aliases alongside legacy /aibridge routes
  • Move /aibridge/keys to /ai-gateway/keys
  • Update in-process transport to use /api/v2/ai-gateway prefix
  • Update SDK client URLs and proxy forwarding URL
  • Swap @Router and @Tags annotations from aibridge/AI Bridge to ai-gateway/AI Gateway
  • Rename user-facing error messages from "AI Bridge" to "AI Gateway"
  • Define consts for route prefixes (AIGatewayRootPath, AIBridgeRootPath)
  • Update tests and comments to use new paths

Note: the following will be addressed in follow-up PRs:

  • Frontend API URLs
  • Frontend routes and redirects
  • Dogfood main.tf updates
  • Hand-written documentation URL updates
  • aibridge internal comments and nits
  • Scale tests path updates

Refs https://linear.app/coder/issue/AIGOV-230

Generated with the assistance of Coder Agents (@ssncferreira)

ssncferreira commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@ssncferreira
ssncferreira force-pushed the ssncf/ai-gateway-api-aliases branch 5 times, most recently from e82564e to 70af39c Compare June 19, 2026 15:55
@datadog-coder

This comment has been minimized.

@ssncferreira
ssncferreira force-pushed the ssncf/ai-gateway-api-aliases branch 3 times, most recently from a634eaa to 95125cc Compare June 19, 2026 16:53
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/ai-coder/ai-gateway/monitoring.md

@ssncferreira
ssncferreira force-pushed the ssncf/ai-gateway-api-aliases branch 2 times, most recently from 7eeb80c to f4f8875 Compare June 22, 2026 08:25
@linear-code

linear-code Bot commented Jun 22, 2026

Copy link
Copy Markdown

AIGOV-230

@ssncferreira
ssncferreira force-pushed the ssncf/ai-gateway-api-aliases branch from f4f8875 to 6c36692 Compare June 22, 2026 09:27
@ssncferreira
ssncferreira force-pushed the ssncf/ai-gateway-api-aliases branch from 6c36692 to 20f54ca Compare June 22, 2026 12:29
@ssncferreira
ssncferreira marked this pull request as ready for review June 22, 2026 12:34
@coder-tasks

coder-tasks Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Needed

  • docs/ai-coder/ai-gateway/monitoring.md - Line 134 link to ../../reference/api/aibridge.md updated to aigateway.md.
  • docs/install/releases/esr-2.29-2.34-upgrade.md - Line 178 link to ../../reference/api/aibridge.md updated to aigateway.md.
  • docs/ai-coder/ai-gateway/clients/ (multiple files) - 39+ references to /api/v2/aibridge/ URLs across client setup guides (claude-code, cline, codex, factory, index, jetbrains, kilo-code, mux, opencode, vscode, zed). Since /api/v2/ai-gateway/ is now the canonical path, these should be updated to use the new prefix (the old routes still work but docs should point to the canonical path).
  • docs/ai-coder/ai-gateway/setup.md - References /api/v2/aibridge/<provider-name>/ URL pattern (line 44). Should use /api/v2/ai-gateway/.
  • docs/ai-coder/ai-gateway/auth.md - References /api/v2/aibridge/anthropic in a ANTHROPIC_BASE_URL example (line 53). Should use /api/v2/ai-gateway/.
  • docs/ai-coder/ai-gateway/providers.md - References /api/v2/aibridge/chatgpt/v1 (line 138). Should use /api/v2/ai-gateway/.
  • docs/ai-coder/ai-gateway/monitoring.md - References /api/v2/aibridge/sessions in a curl example (line 101). Should use /api/v2/ai-gateway/.
  • docs/ai-coder/ai-gateway/ai-gateway-proxy/setup.md - References /api/v2/aibridge/proxy/ca-cert.pem (lines 156, 311). Should use /api/v2/ai-gateway/.

Priority

The broken link items are now addressed. The remaining URL updates are lower priority since the legacy /aibridge routes still work, but should be updated to keep docs consistent with the new canonical /ai-gateway path. These could be done in a follow-up PR if preferred.


Automated review via Coder Agents

@dannykopping dannykopping left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread coderd/aibridged.go Outdated
Comment thread enterprise/coderd/aibridge.go

@pawbana pawbana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLI still uses old path:

res, err := c.Request(ctx, http.MethodGet, "/api/v2/aibridge/sessions", nil, filter.asRequestOption(), filter.Pagination.asRequestOption())

res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/aibridge/sessions/%s", sessionID), nil, func(r *http.Request) {

res, err := c.Request(ctx, http.MethodGet, "/api/v2/aibridge/clients", nil)

~7 usages in:

const url = getURLWithSearchParams("/api/v2/aibridge/models", options);

Some tests use old PATH, eg:

url := client.URL.String() + "/api/v2/aibridge/test"
,
req, err := http.NewRequestWithContext(ctx, http.MethodGet, client.URL.String()+"/api/v2/aibridge/proxy/ca-cert.pem", nil)
or
url := client.URL.String() + "/api/v2/aibridge/" + providerName + "/v1/models"

nit: comment in:

// - https://coder.host.com/api/v2 + /aibridge + /{provider.RoutePrefix()} + /{bridged or passthrough route}
// {host} {aibridge root} {provider prefix} {provider route}

Paths of UI pages are separate? eg:

<Route path="/aibridge" element={<AIBridgeLayout />}>

Possible followup, update path in scale tests:

switch s.provider {

nit comment:

// crossing the gated /api/v2/aibridge HTTP route. The HTTP route

@ssncferreira

Copy link
Copy Markdown
Contributor Author

CLI still uses old path:

res, err := c.Request(ctx, http.MethodGet, "/api/v2/aibridge/sessions", nil, filter.asRequestOption(), filter.Pagination.asRequestOption())

res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/aibridge/sessions/%s", sessionID), nil, func(r *http.Request) {

res, err := c.Request(ctx, http.MethodGet, "/api/v2/aibridge/clients", nil)

~7 usages in:

const url = getURLWithSearchParams("/api/v2/aibridge/models", options);

Some tests use old PATH, eg:

url := client.URL.String() + "/api/v2/aibridge/test"

,

req, err := http.NewRequestWithContext(ctx, http.MethodGet, client.URL.String()+"/api/v2/aibridge/proxy/ca-cert.pem", nil)

or

url := client.URL.String() + "/api/v2/aibridge/" + providerName + "/v1/models"

nit: comment in:

// - https://coder.host.com/api/v2 + /aibridge + /{provider.RoutePrefix()} + /{bridged or passthrough route}
// {host} {aibridge root} {provider prefix} {provider route}

Paths of UI pages are separate? eg:

<Route path="/aibridge" element={<AIBridgeLayout />}>

Possible followup, update path in scale tests:

switch s.provider {

nit comment:

// crossing the gated /api/v2/aibridge HTTP route. The HTTP route

Good catch, site changes will be addressed on the follow-up PR #26567
UI route paths are handled by https://linear.app/codercom/issue/AIGOV-233/update-ai-gateway-ui-copy-and-route-redirects and will be addressed on a follow-up PR.

For the CLI, tests and other nits, I can update in the context of this PR 👍

@ssncferreira

Copy link
Copy Markdown
Contributor Author

@pawbana addressed the CLI, tests and other nits. There are still some other references that will be addressed in focused follow-up PRs. Updated the PR description as well with the changes meant for these follow-ups

@ssncferreira
ssncferreira requested a review from pawbana June 22, 2026 17:14
Comment thread coderd/aibridged.go Outdated
@ssncferreira
ssncferreira force-pushed the ssncf/ai-gateway-api-aliases branch from b51d159 to 7863ff7 Compare June 23, 2026 10:58
@ssncferreira
ssncferreira merged commit 970bd73 into main Jun 23, 2026
30 of 31 checks passed
@ssncferreira
ssncferreira deleted the ssncf/ai-gateway-api-aliases branch June 23, 2026 11:15
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants