Files
coder/codersdk
Ethan ac92143dbe refactor!: remove the AI Gateway provider list route (#32651)
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`.
2026-11-30 16:16:34 +11:00
..
…