# List Models

The `list_models` and `alist_models` functions return the available models for a given provider.

### `any_llm.list_models()`

```
def list_models(
    provider: str | LLMProvider,
    api_key: str | None = None,
    api_base: str | None = None,
    client_args: dict[str, Any] | None = None,
    **kwargs: Any,
) -> Sequence[Model]
```

### `any_llm.alist_models()`

Async variant with the same parameters.

```
async def alist_models(
    provider: str | LLMProvider,
    api_key: str | None = None,
    api_base: str | None = None,
    client_args: dict[str, Any] | None = None,
    **kwargs: Any,
) -> Sequence[Model]
```

### Parameters

| Parameter     | Type                     | Default    | Description |
| ------------- | ------------------------ | ---------- | ----------- |
| `provider`    | `str \| LLMProvider`     | *required* |             |
| `api_key`     | `str \| None`            | None       |             |
| `api_base`    | `str \| None`            | None       |             |
| `client_args` | `dict[str, Any] \| None` | None       |             |
| `**kwargs`    | `Any`                    | *required* |             |

### Return Value

Returns a `Sequence` of [`Model`](/api-reference/completion-1/model.md) objects. Each `Model` has at minimum an `id` field containing the model identifier string.

### Usage

```python
from any_llm import list_models

models = list_models("openai")
for model in models:
    print(model.id)
```

#### Async

```python
import asyncio
from any_llm import alist_models

async def main():
    models = await alist_models("mistral")
    for model in models:
        print(model.id)

asyncio.run(main())
```

#### Using the AnyLLM class

```python
from any_llm import AnyLLM

llm = AnyLLM.create("openai")
models = llm.list_models()
print(f"Available models: {len(models)}")
```

{% hint style="info" %}
Not all providers support listing models. Check the [providers page](/providers.md) for support details, or query `ProviderMetadata.list_models` programmatically.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mozilla.ai/api-reference/list-models.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
