mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add /api/v2/ai-gateway API route aliases (#26475)
## 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)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# AI Bridge
|
||||
# AI Gateway
|
||||
|
||||
## List AI Bridge clients
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/aibridge/clients \
|
||||
curl -X GET http://coder-server:8080/api/v2/ai-gateway/clients \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /api/v2/aibridge/clients`
|
||||
`GET /api/v2/ai-gateway/clients`
|
||||
|
||||
Alias: also available at /api/v2/aibridge/clients for backward compatibility.
|
||||
|
||||
### Example responses
|
||||
|
||||
@@ -39,12 +41,14 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/aibridge/models \
|
||||
curl -X GET http://coder-server:8080/api/v2/ai-gateway/models \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /api/v2/aibridge/models`
|
||||
`GET /api/v2/ai-gateway/models`
|
||||
|
||||
Alias: also available at /api/v2/aibridge/models for backward compatibility.
|
||||
|
||||
### Example responses
|
||||
|
||||
@@ -72,12 +76,14 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/aibridge/sessions \
|
||||
curl -X GET http://coder-server:8080/api/v2/ai-gateway/sessions \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /api/v2/aibridge/sessions`
|
||||
`GET /api/v2/ai-gateway/sessions`
|
||||
|
||||
Alias: also available at /api/v2/aibridge/sessions for backward compatibility.
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -145,12 +151,14 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/aibridge/sessions/{session_id} \
|
||||
curl -X GET http://coder-server:8080/api/v2/ai-gateway/sessions/{session_id} \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /api/v2/aibridge/sessions/{session_id}`
|
||||
`GET /api/v2/ai-gateway/sessions/{session_id}`
|
||||
|
||||
Alias: also available at /api/v2/aibridge/sessions/{session_id} for backward compatibility.
|
||||
|
||||
### Parameters
|
||||
|
||||
Generated
+6
-6
@@ -184,12 +184,12 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/aibridge/keys \
|
||||
curl -X GET http://coder-server:8080/api/v2/ai-gateway/keys \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /api/v2/aibridge/keys`
|
||||
`GET /api/v2/ai-gateway/keys`
|
||||
|
||||
### Example responses
|
||||
|
||||
@@ -234,13 +234,13 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X POST http://coder-server:8080/api/v2/aibridge/keys \
|
||||
curl -X POST http://coder-server:8080/api/v2/ai-gateway/keys \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`POST /api/v2/aibridge/keys`
|
||||
`POST /api/v2/ai-gateway/keys`
|
||||
|
||||
> Body parameter
|
||||
|
||||
@@ -284,11 +284,11 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X DELETE http://coder-server:8080/api/v2/aibridge/keys/{key} \
|
||||
curl -X DELETE http://coder-server:8080/api/v2/ai-gateway/keys/{key} \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`DELETE /api/v2/aibridge/keys/{key}`
|
||||
`DELETE /api/v2/ai-gateway/keys/{key}`
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Reference in New Issue
Block a user