Skip to main content
Models provide a consistent interface for invoking any supported LLM provider. Call synchronously, asynchronously, or via streaming — with the same API regardless of provider.

Supported Providers

Basic Usage

Common Parameters

All model classes accept these parameters:
str
required
The model identifier (e.g., "gpt-4o", "deepseek-chat").
str
API key for authentication. Defaults to the provider’s environment variable.
str
Override the API base URL. Useful for proxies or self-hosted endpoints.
float
Sampling temperature (0.0 to 2.0). Lower values are more deterministic.
int
Maximum number of tokens to generate.
float
Request timeout in seconds.
int
Maximum number of retries on transient failures.

Invocation Methods

Every model supports four ways to call it:

Retry Configuration

All models support automatic retries with configurable backoff:
int
default:"0"
Number of retry attempts on failure.
int
default:"1"
Base delay in seconds between retries.
bool
default:"false"
Whether to use exponential backoff for retries.

Response Caching

Cache model responses locally for development and testing:

Model Resolution from Strings

Agents accept string model shorthand — no explicit model import needed:
You can also resolve strings programmatically:
Supported providers: openai, deepseek, moonshot, xai, anthropic, mistral, google, perplexity, ollama, openrouter

Next Steps

String Shorthand

Use string format instead of class imports.

Model Resilience

Key rotation, failover, and rate limit handling.

Streaming

Stream responses token-by-token.

Structured Output

Return Pydantic models from LLM calls.

Multimodal

Images, audio, video, and files.

Metrics & Pricing

Token counting and cost calculation.