
## List a key's models

`GET /v1/ai/credentials/:id/models`

Returns all models bound to the specified BYOK key via [`fetch-models`](./fetch-models.md) or [`models-add`](./models-add.md). Used to view a Custom provider's current catalog and to find a record's `id` before deletion.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | string | yes | Key ID from [`GET /v1/ai/credentials`](./list.md) |

## Examples

### curl — personal key

```bash
curl https://vibecode.bitrix24.com/v1/ai/credentials/cred_custom_xyz/models \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl https://vibecode.bitrix24.com/v1/ai/credentials/cred_custom_xyz/models \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const id = 'cred_custom_xyz'
const res = await fetch(`https://vibecode.bitrix24.com/v1/ai/credentials/${id}/models`, {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
data.forEach((m) => console.log(`${m.modelId} — ${m.name} (${m.status})`))
```

### JavaScript — OAuth application

```javascript
const id = 'cred_custom_xyz'
const res = await fetch(`https://vibecode.bitrix24.com/v1/ai/credentials/${id}/models`, {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
console.log('Models on the key:', data.length)
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of bound models |
| `data[].id` | string | Unique ID of the `AiModel` record (needed for [deletion](./models-delete.md)) |
| `data[].modelId` | string | Model ID to use as the `model` field in a request to [`/v1/chat/completions`](/docs/ai/chat/completions) |
| `data[].name` | string | Display name of the model |
| `data[].contextLength` | number | Maximum context size in tokens |
| `data[].maxOutputTokens` | number | Maximum tokens in the response |
| `data[].status` | string | Status: `ACTIVE`, `DEPRECATED`, `DISABLED` |
| `data[].isEnabled` | boolean | Global switch: `false` — the model is hidden from all catalogs |
| `data[].createdAt` | string | Time of first registration in `ISO 8601` |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": "aimodel_xyz789",
      "modelId": "abab6.5-chat",
      "name": "MiniMax abab6.5-chat",
      "contextLength": 32768,
      "maxOutputTokens": 8192,
      "status": "ACTIVE",
      "isEnabled": true,
      "createdAt": "2026-04-25T09:00:00.000Z"
    },
    {
      "id": "aimodel_old001",
      "modelId": "old-model-v1",
      "name": "Old model",
      "contextLength": 16384,
      "maxOutputTokens": 4096,
      "status": "DEPRECATED",
      "isEnabled": true,
      "createdAt": "2026-04-15T09:00:00.000Z"
    }
  ]
}
```

## Error response example

`404 not_found` — the key was not found or belongs to another user:

```json
{
  "success": false,
  "error": {
    "code": "not_found",
    "message": "Credential not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `not_found` | A key with this `id` was not found or does not belong to you |
| 403 | `scope_missing` | The API key lacks the `vibe:ai` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not provided |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

**`status: DEPRECATED` after `fetch-models`.** If a model was previously fetched via `fetch-models` but did not come from the provider in the last run — its status is automatically changed to `DEPRECATED`. Requests to it still work, but in the [`GET /v1/models`](/docs/ai/models/list) catalog it is marked as deprecated.

**Works for all providers, not just Custom.** The endpoint returns any models bound to the key. For standard providers `data` is usually empty — their models are platform-level (`credentialId: null`), not bound to a specific key.

**`id` is needed for deletion.** To delete a model — save the record's `id` and pass it to [`DELETE /v1/ai/credentials/:credId/models/:modelRowId`](./models-delete.md). `modelId` is not suitable — it is not unique across keys.

## See also

- [Fetch the model catalog](./fetch-models.md)
- [Add a model manually](./models-add.md)
- [Delete a key's model](./models-delete.md)
- [List of models](/docs/ai/models/list)
