> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI With Retries

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

<Warning>
  This example assumes an invalid model ID triggers the configured retries. Invalid-model responses commonly use terminal 400 or 404 statuses, which Agno does not retry. Do not run this source as a retry test.
</Warning>

```python with_retries.py theme={null}
"""
Openai With Retries
===================

Cookbook example for `openai/chat/with_retries.py`.
"""

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

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

agent = Agent(
    model=OpenAIChat(
        id="gpt-wrong-id",  # Deliberately wrong model ID to trigger retries
        retries=3,
        delay_between_retries=1,
        exponential_backoff=True,
    ),
)
agent.print_response("What is the capital of France?")

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

if __name__ == "__main__":
    pass
```

## Current Alternative

Configure `retries`, `delay_between_retries`, and `exponential_backoff` as shown in [Retry Model Requests](/models/overview#retry-model-requests). Test the retry path with a controlled transient 429, connection failure, or 5xx response.

Full source: [cookbook/90\_models/openai/chat/with\_retries.py](https://github.com/agno-agi/agno/blob/main/cookbook/90_models/openai/chat/with_retries.py)
