# Models API

## POST /api/v1/admin/models/{id}/test

`POST /api/v1/admin/models/{id}/test` · operation `testModelConnection`

One minimal request through this gateway (ADR 0134), as an in-process caller allowed only this alias: a short chat with max_tokens 5, or an embedding of "ping". Walks the same path as real traffic (protocol translation, provider credential, fallback, guardrails) and lands in the ledger under console-model-test:&lt;user&gt;. Returns ok, HTTP status, latency, the provider that served it, the upstream model, tokens and, on failure, the gateway error code or upstream_&lt;status&gt; with credentials redacted from the provider message; never the raw provider body. 422 not_testable for other capabilities, 409 for a disabled alias. Requires models:manage.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Test ran; see ok | — |
| `404` | Unknown model | — |
| `409` | Model disabled | — |
| `422` | Capability not testable here | — |


## GET /v1/models

`GET /v1/models` · operation `listModels`

Aliases the key may call. With provider_model_discovery on, each provider/* wildcard alias is also expanded into the models its connection lists, filtered by the key's allowed_models; a model routed by an exact or longer alias is listed under that alias. A failing listing keeps only the wildcard and is retried after a minute. codex_model_catalog (T148): with the flag on and a valid client_version, the answer is the Codex CLI catalog (CodexModelCatalog) instead, with Cache-Control: no-store; otherwise the OpenAI list, unchanged.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `client_version` | query | string, max length 86, pattern `^[0-9]{1,6}\.[0-9]{1,6}\.[0-9]{1,6}([-+.][0-9A-Za-z.+-]{1,64})?$` | Sent by the Codex CLI when it reads model_catalog_url. With codex_model_catalog on and a value of this form, selects the CodexModelCatalog answer; any other value, or the flag off, keeps the OpenAI list. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Models allowed for the authenticated key | `application/json`: object or [CodexModelCatalog](/docs/api/schemas/c/#codexmodelcatalog) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object or [CodexModelCatalog](/docs/api/schemas/c/#codexmodelcatalog)
  - One of (1): object
    - `object` (`"list"`, required)
    - `data` (array of [GatewayModel](/docs/api/schemas/g/#gatewaymodel), required)
  - One of (2): [CodexModelCatalog](/docs/api/schemas/c/#codexmodelcatalog)


## GET /v1/models/{id}

`GET /v1/models/{id}` · operation `retrieveModel`

OpenAI client.models.retrieve. Same visibility as the listing: an active alias the key may use, including wildcard resolution. Anything else is 404, never 403, so aliases outside the key cannot be probed.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required | Model alias, or a model a provider/* wildcard alias resolves (may contain /) |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The model object | `application/json`: [GatewayModel](/docs/api/schemas/g/#gatewaymodel) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Unknown, disabled or not allowed for this key | — |


## GET /v1/model/info

`GET /v1/model/info` · operation `listModelInfo`

Model info for clients (Open WebUI and SDK tooling). Requires the model_info flag and route:models. For each alias the key may call: mode, capabilities, number of fallbacks, routing kind (auto, wildcard, cost, least_busy) and, for the primary target, max_input_tokens and advisory input/output cost per token from the resolved price catalog (automatic sources refresh in the background). Providers, URLs and upstream model names are never included.

**Authentication:** `bearerAuth`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | data: [{model_name, model_info}] | — |
| `401` | Missing or invalid key | — |
| `403` | Key without route:models | — |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |

