What are Models?

Configure the language model that an Agent or Team uses, including provider selection and request retries.

from agno.agent import Agent
from agno.models.openai import OpenAIResponses

agent = Agent(
    model=OpenAIResponses(id="gpt-5.4"),
    markdown=True,
)

agent.print_response("Share a two-sentence horror story.", stream=True)

Models connect Agents and Teams to model-provider APIs. The model class determines the API implementation, while id selects the provider's model or deployment.

Install the provider integration and set its credentials before running the example:

uv pip install "agno[openai]"
export OPENAI_API_KEY="your-api-key"

Model capabilities vary by provider, API, and model ID. Check model compatibility before relying on features such as multimodal input or native structured output.

Configure a Model

ConfigurationUse it when
model="openai:gpt-5.4"You need a built-in provider class with its default settings
model=OpenAIResponses(id="gpt-5.4", ...)You need provider parameters, custom clients, endpoints, or retry settings

The string form constructs the registered provider class with the supplied model ID. See Model as String for provider keys and API variants.

Retry Model Requests

Configure retries on the model class for transient provider errors such as rate limits and server errors:

from agno.models.openai import OpenAIResponses

model = OpenAIResponses(
    id="gpt-5.4",
    retries=2,
    delay_between_retries=1,
    exponential_backoff=True,
)
ParameterDefaultDescription
retries0Additional request attempts after the first attempt
delay_between_retries1Seconds to wait before the first retry
exponential_backoffFalseDouble the delay after each failed attempt

Model retries skip non-retryable errors such as authentication failures, invalid requests, and context-window errors. A retry after a streaming error restarts the entire model stream. Chunks emitted before the failure remain visible to the caller.

Set retries, delay_between_retries, and exponential_backoff on an Agent or Team to retry the full run instead of an individual model request.

Learn More