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

# List Models

List available models for a provider

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`](https://docs.mozilla.ai/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](https://docs.mozilla.ai/providers.md) for support details, or query `ProviderMetadata.list_models` programmatically.
{% 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.mozilla.ai/api-reference/list-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.
