Relates to AIGOV-824 Stacked on #32650. `GET /api/v2/ai-gateway/providers` was added in #28966, in September, and first shipped in v2.38.0. It was a fix for the provider filter on the AI Gateway sessions page. That filter called `GET /api/v2/ai/providers`, which only owners could read, so the dropdown was empty for auditors. Rather than open up the provider config, #28966 added a second route that returns just the `name`, `type`, `display_name` and `icon` of every provider, deleted ones included, to anyone who can read sessions, i.e. owners and auditors. Now that `GET /api/v2/ai/providers` answers every signed-in user with those same fields (#32650), the second route has no caller that it alone can serve. Jake, who added it, and I agree that we should remove it rather than keep two routes that list providers, so this PR does that. The one thing only the old route did was return deleted providers, so that sessions and spend recorded under a provider that has since been deleted keep their label. So, `GET /api/v2/ai/providers` gains an `include_deleted` query parameter. A deleted provider can share its name with a live one, so each name appears once, as its live provider if there is one, otherwise the most recently updated deleted one. Unlike the old route, any caller can pass it, so members can now see the names of deleted providers. A deleted provider comes back without its configuration, for owners too. The sessions provider filter and the Spend page now call `GET /api/v2/ai/providers?include_deleted=true`, and show the same thing as before. `codersdk.AIBridgeProvider`, `Client.AIBridgeListProviders` and the `GetAIProviderFilterOptions` query go with the route. ## For changelog - `GET /api/v2/ai-gateway/providers` has been removed (#32651) > `GET /api/v2/ai-gateway/providers` has been removed, along with `codersdk.AIBridgeProvider` and `Client.AIBridgeListProviders` in the Go SDK. It listed providers only for users who can read AI Gateway sessions, i.e. owners and auditors. `GET /api/v2/ai/providers` replaces it, and now answers every signed-in user. Owners still get each provider's full configuration from it, and everyone else gets the same list with an empty `base_url`, an empty `api_keys` array, `null` `settings` and no `status`. > > Migration: Call `GET /api/v2/ai/providers?include_deleted=true` instead. Each provider keeps its `name`, `type`, `display_name` and `icon` fields, and `display_name` now holds the provider name when no display name is set. In the Go SDK, `Client.AIProviders` now takes a `codersdk.AIProvidersFilter`. Set its `IncludeDeleted` field to list deleted providers too. An API token with an allow list needs `ai_provider` in that list to call `GET /api/v2/ai/providers`, where the removed route needed `aibridge_interception`.
13 KiB
Generated
13 KiB
Generated
title
| title |
|---|
| AI Providers |
List AI providers
Code samples
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/ai/providers \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
GET /api/v2/ai/providers
Lists AI providers, including disabled ones. The base_url, api_keys, settings, and status fields are empty when the caller can't read AI provider configuration.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
include_deleted |
query | boolean | false | Include deleted providers, which are returned without configuration. Each name appears once: its live provider if one exists, otherwise the most recently updated deleted one. |
Example responses
200 Response
[
{
"api_keys": [
{
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"masked": "string"
}
],
"base_url": "string",
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"display_name": "string",
"enabled": true,
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"settings": {},
"status": {
"warnings": [
"string"
]
},
"type": "openai",
"updated_at": "2019-08-24T14:15:22Z"
}
]
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | array of codersdk.AIProvider |
Response Schema
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
[array item] |
array | false | ||
» api_keys |
array | false | ||
»» created_at |
string(date-time) | false | ||
»» id |
string(uuid) | false | ||
»» masked |
string | false | ||
» base_url |
string | false | ||
» created_at |
string(date-time) | false | ||
» deleted |
boolean | false | ||
» display_name |
string | false | ||
» enabled |
boolean | false | ||
» icon |
string | false | ||
» id |
string(uuid) | false | ||
» name |
string | false | ||
» settings |
codersdk.AIProviderSettings | false | ||
» status |
codersdk.AIProviderStatus | false | Status carries runtime routing status; nil when empty. | |
»» warnings |
array | false | ||
» type |
codersdk.AIProviderType | false | ||
» updated_at |
string(date-time) | false |
Enumerated Values
| Property | Value(s) |
|---|---|
type |
anthropic, azure, bedrock, copilot, google, openai, openai-compat, openrouter, vercel |
To perform this operation, you must be authenticated. Learn more.
Create an AI provider
Code samples
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/ai/providers \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
POST /api/v2/ai/providers
Body parameter
{
"api_keys": [
"string"
],
"base_url": "string",
"display_name": "string",
"enabled": true,
"icon": "string",
"name": "string",
"settings": {},
"type": "openai"
}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
body |
body | codersdk.CreateAIProviderRequest | true | Create AI provider request |
Example responses
201 Response
{
"api_keys": [
{
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"masked": "string"
}
],
"base_url": "string",
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"display_name": "string",
"enabled": true,
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"settings": {},
"status": {
"warnings": [
"string"
]
},
"type": "openai",
"updated_at": "2019-08-24T14:15:22Z"
}
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 201 | Created | Created | codersdk.AIProvider |
To perform this operation, you must be authenticated. Learn more.
Get an AI provider
Code samples
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/ai/providers/{idOrName} \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
GET /api/v2/ai/providers/{idOrName}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idOrName |
path | string | true | Provider ID or name |
Example responses
200 Response
{
"api_keys": [
{
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"masked": "string"
}
],
"base_url": "string",
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"display_name": "string",
"enabled": true,
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"settings": {},
"status": {
"warnings": [
"string"
]
},
"type": "openai",
"updated_at": "2019-08-24T14:15:22Z"
}
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | codersdk.AIProvider |
To perform this operation, you must be authenticated. Learn more.
Delete an AI provider
Code samples
# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/ai/providers/{idOrName} \
-H 'Coder-Session-Token: API_KEY'
DELETE /api/v2/ai/providers/{idOrName}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idOrName |
path | string | true | Provider ID or name |
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 204 | No Content | No Content |
To perform this operation, you must be authenticated. Learn more.
Update an AI provider
Code samples
# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/ai/providers/{idOrName} \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
PATCH /api/v2/ai/providers/{idOrName}
Body parameter
{
"api_keys": [
{
"api_key": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
}
],
"base_url": "string",
"display_name": "string",
"enabled": true,
"icon": "string",
"settings": {}
}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idOrName |
path | string | true | Provider ID or name |
body |
body | codersdk.UpdateAIProviderRequest | true | Update AI provider request |
Example responses
200 Response
{
"api_keys": [
{
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"masked": "string"
}
],
"base_url": "string",
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"display_name": "string",
"enabled": true,
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"settings": {},
"status": {
"warnings": [
"string"
]
},
"type": "openai",
"updated_at": "2019-08-24T14:15:22Z"
}
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | codersdk.AIProvider |
To perform this operation, you must be authenticated. Learn more.