Retry

Review retry settings and why invalid model IDs cannot reliably exercise the retry path.

These retained examples come from the source revision linked below. Use the installation and model configuration in the AI/ML API guide, or use the compatible OpenAILike adaptation below with an older package.

retry.py
"""Example demonstrating how to set up retries with AIMLAPI."""

from agno.agent import Agent
from agno.models.aimlapi import AIMLAPI

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

# We will use a deliberately wrong model ID, to trigger retries.
wrong_model_id = "aimlapi-wrong-id"

agent = Agent(
    model=AIMLAPI(
        id=wrong_model_id,
        retries=3,  # Number of times to retry the request.
        delay_between_retries=1,  # Delay between retries in seconds.
        exponential_backoff=True,  # If True, the delay between retries is doubled each time.
    ),
)

agent.print_response("What is the capital of France?")

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass

Current Alternative

Use the working AIMLAPI gateway setup, then configure retries, delay_between_retries, and exponential_backoff on that model as described in Retry Model Requests. Its status-aware retry path treats ordinary 400/404 responses as terminal. Test with a controlled transient 429, connection failure, or 5xx response and a valid model ID. The old adapter revision linked below fails before reaching this path; current main fixes that formatter mismatch.

Full source: cookbook/90_models/aimlapi/retry.py