For the complete documentation index, see llms.txt. This page is also available as Markdown.

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 objects. Each Model has at minimum an id field containing the model identifier string.

Usage

Async

Using the AnyLLM class

Not all providers support listing models. Check the providers page for support details, or query ProviderMetadata.list_models programmatically.

Last updated