Files
coder/docs/reference/api/aigateway.md
T
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

12 KiB
Generated

title
title
AI Gateway

List AI Gateway clients

Code samples

# Example request using curl
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/ai-gateway/clients

Alias: also available at /api/v2/aibridge/clients for backward compatibility.

Example responses

200 Response

[
  "string"
]

Responses

Status Meaning Description Schema
200 OK OK array of string

Response Schema

To perform this operation, you must be authenticated. Learn more.

List AI Gateway models

Code samples

# Example request using curl
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/ai-gateway/models

Alias: also available at /api/v2/aibridge/models for backward compatibility.

Parameters

Name In Type Required Description
q query string false Search query in the format key:value. Available keys are: model. A bare term searches by model. The match is a case-insensitive substring.
model query string false Literal model identifier substring, matched case-insensitively. Cannot be combined with q.

Example responses

200 Response

[
  "string"
]

Responses

Status Meaning Description Schema
200 OK OK array of string

Response Schema

To perform this operation, you must be authenticated. Learn more.

List AI Gateway sessions

Code samples

# Example request using curl
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/ai-gateway/sessions

Alias: also available at /api/v2/aibridge/sessions for backward compatibility.

Parameters

Name In Type Required Description
q query string false Search query in the format key:value. Available keys are: initiator, provider, provider_name, model, client, session_id, organization, started_after, started_before.
limit query integer false Page limit
after_session_id query string false Cursor pagination after session ID (cannot be used with offset)
offset query integer false Offset pagination (cannot be used with after_session_id)

Example responses

200 Response

{
  "count": 0,
  "sessions": [
    {
      "client": "string",
      "ended_at": "2019-08-24T14:15:22Z",
      "id": "string",
      "initiator": {
        "avatar_url": "http://example.com",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "name": "string",
        "username": "string"
      },
      "last_active_at": "2019-08-24T14:15:22Z",
      "last_prompt": "string",
      "metadata": {
        "property1": null,
        "property2": null
      },
      "models": [
        "string"
      ],
      "network_calls": {
        "blocked": 0,
        "total": 0
      },
      "organizations": [
        {
          "display_name": "string",
          "icon": "string",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
          "name": "string",
          "sources": [
            "workspace"
          ]
        }
      ],
      "providers": [
        "string"
      ],
      "started_at": "2019-08-24T14:15:22Z",
      "threads": 0,
      "token_usage_summary": {
        "cache_read_input_tokens": 0,
        "cache_write_input_tokens": 0,
        "input_tokens": 0,
        "output_tokens": 0
      }
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.AIBridgeListSessionsResponse

To perform this operation, you must be authenticated. Learn more.

Get AI Gateway session threads

Code samples

# Example request using curl
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/ai-gateway/sessions/{session_id}

Alias: also available at /api/v2/aibridge/sessions/{session_id} for backward compatibility.

Parameters

Name In Type Required Description
session_id path string true Session ID (client_session_id or interception UUID)
after_id query string false Thread pagination cursor (forward/older)
before_id query string false Thread pagination cursor (backward/newer)
limit query integer false Number of threads per page (default 50)

Example responses

200 Response

{
  "client": "string",
  "ended_at": "2019-08-24T14:15:22Z",
  "id": "string",
  "initiator": {
    "avatar_url": "http://example.com",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "name": "string",
    "username": "string"
  },
  "metadata": {
    "property1": null,
    "property2": null
  },
  "models": [
    "string"
  ],
  "network_call_logs": [
    {
      "allowed": true,
      "captured_at": "2019-08-24T14:15:22Z",
      "created_at": "2019-08-24T14:15:22Z",
      "detail": "string",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "matched_rule": "string",
      "method": "string",
      "proto": "string",
      "sequence_number": 0,
      "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82"
    }
  ],
  "network_calls": {
    "blocked": 0,
    "total": 0
  },
  "network_domain_count": 0,
  "network_top_domains": [
    {
      "count": 0,
      "domain": "string"
    }
  ],
  "organizations": [
    {
      "display_name": "string",
      "icon": "string",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "name": "string",
      "sources": [
        "workspace"
      ]
    }
  ],
  "page_ended_at": "2019-08-24T14:15:22Z",
  "page_started_at": "2019-08-24T14:15:22Z",
  "providers": [
    "string"
  ],
  "started_at": "2019-08-24T14:15:22Z",
  "threads": [
    {
      "agent_firewall_sequence_number": 0,
      "agent_firewall_session_id": "3735294f-18b1-4e7a-a269-99c30f0b30e7",
      "agentic_actions": [
        {
          "attribution": {
            "property1": "string",
            "property2": "string"
          },
          "interception_id": "34d9b688-63ad-46f4-88b5-665c1e7f7824",
          "model": "string",
          "organization": {
            "display_name": "string",
            "icon": "string",
            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
            "name": "string",
            "source": "workspace"
          },
          "priced_model": {
            "cache_read_price": 0,
            "cache_write_price": 0,
            "input_price": 0,
            "model": "string",
            "output_price": 0
          },
          "thinking": [
            {
              "text": "string"
            }
          ],
          "token_usage": {
            "cache_read_input_tokens": 0,
            "cache_write_input_tokens": 0,
            "cost_micros": 0,
            "has_unpriced_usage": true,
            "input_tokens": 0,
            "metadata": {
              "property1": null,
              "property2": null
            },
            "output_tokens": 0
          },
          "tool_calls": [
            {
              "created_at": "2019-08-24T14:15:22Z",
              "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
              "injected": true,
              "input": "string",
              "interception_id": "34d9b688-63ad-46f4-88b5-665c1e7f7824",
              "metadata": {
                "property1": null,
                "property2": null
              },
              "provider_response_id": "string",
              "server_url": "string",
              "tool": "string"
            }
          ]
        }
      ],
      "attribution": {
        "property1": "string",
        "property2": "string"
      },
      "credential_hint": "string",
      "credential_kind": "string",
      "ended_at": "2019-08-24T14:15:22Z",
      "error_message": "string",
      "error_type": "string",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "model": "string",
      "organization": {
        "display_name": "string",
        "icon": "string",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "name": "string",
        "source": "workspace"
      },
      "priced_model": {
        "cache_read_price": 0,
        "cache_write_price": 0,
        "input_price": 0,
        "model": "string",
        "output_price": 0
      },
      "prompt": "string",
      "provider": "string",
      "started_at": "2019-08-24T14:15:22Z",
      "token_usage": {
        "cache_read_input_tokens": 0,
        "cache_write_input_tokens": 0,
        "cost_micros": 0,
        "has_unpriced_usage": true,
        "input_tokens": 0,
        "metadata": {
          "property1": null,
          "property2": null
        },
        "output_tokens": 0
      }
    }
  ],
  "token_usage_summary": {
    "cache_read_input_tokens": 0,
    "cache_write_input_tokens": 0,
    "cost_micros": 0,
    "has_unpriced_usage": true,
    "input_tokens": 0,
    "metadata": {
      "property1": null,
      "property2": null
    },
    "output_tokens": 0
  }
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.AIBridgeSessionThreadsResponse

To perform this operation, you must be authenticated. Learn more.