> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/ai-in-umbraco/19.latest/management-api/connections/models.md).

# Get Models

Get available AI models for a connection.

Retrieve the list of AI models available through a specific connection. This is useful for populating model selection dropdowns in the UI.

## Endpoint

```
GET /umbraco/ai/management/api/v1/connections/{idOrAlias}/models
```

## Path Parameters

| Parameter   | Type   | Description              |
| ----------- | ------ | ------------------------ |
| `idOrAlias` | string | Connection GUID or alias |

## Response

### Success (200 OK)

{% code title="Response" %}

```json
{
    "items": [
        {
            "id": "gpt-4o",
            "name": "GPT-4o",
            "capabilities": ["Chat"]
        },
        {
            "id": "gpt-4o-mini",
            "name": "GPT-4o Mini",
            "capabilities": ["Chat"]
        },
        {
            "id": "text-embedding-3-small",
            "name": "Text Embedding 3 Small",
            "capabilities": ["Embedding"]
        },
        {
            "id": "text-embedding-3-large",
            "name": "Text Embedding 3 Large",
            "capabilities": ["Embedding"]
        }
    ]
}
```

{% endcode %}

### Model Properties

| Property       | Type      | Description                          |
| -------------- | --------- | ------------------------------------ |
| `id`           | string    | Model identifier to use in API calls |
| `name`         | string    | Display name                         |
| `capabilities` | string\[] | Capabilities this model supports     |

### 404 Not Found

```json
{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.4",
    "title": "Not Found",
    "status": 404,
    "detail": "Connection not found"
}
```

## Examples

### cURL

{% code title="cURL" %}

```bash
curl -X GET "https://your-site.com/umbraco/ai/management/api/v1/connections/openai-prod/models" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

{% endcode %}

### JavaScript

{% code title="JavaScript" %}

```javascript
async function getModels(connectionIdOrAlias) {
    const response = await fetch(`/umbraco/ai/management/api/v1/connections/${connectionIdOrAlias}/models`, {
        credentials: "include",
    });

    if (!response.ok) {
        throw new Error("Failed to fetch models");
    }

    const { items } = await response.json();
    return items;
}

// Usage
const models = await getModels("openai-prod");
console.log(models);
```

{% endcode %}

### Filter by Capability

{% code title="JavaScript" %}

```javascript
async function getChatModels(connectionIdOrAlias) {
    const models = await getModels(connectionIdOrAlias);
    return models.filter((m) => m.capabilities.includes("Chat"));
}

async function getEmbeddingModels(connectionIdOrAlias) {
    const models = await getModels(connectionIdOrAlias);
    return models.filter((m) => m.capabilities.includes("Embedding"));
}
```

{% endcode %}

### Populate Model Dropdown

{% code title="JavaScript" %}

```javascript
async function populateModelSelect(selectElement, connectionId, capability) {
    const models = await getModels(connectionId);
    const filtered = models.filter((m) => m.capabilities.includes(capability));

    selectElement.innerHTML = "";

    for (const model of filtered) {
        const option = document.createElement("option");
        option.value = model.id;
        option.textContent = model.name;
        selectElement.appendChild(option);
    }
}
```

{% endcode %}

## Notes

{% hint style="info" %}
The list of models is fetched from the AI provider in real-time. Results may vary based on your API key's permissions and the provider's available models.
{% endhint %}

{% hint style="warning" %}
This endpoint makes a call to the AI provider's API. Consider caching the results if you need to call it frequently.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/ai-in-umbraco/19.latest/management-api/connections/models.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
