# Retry (/examples/models/meta/retry)



<Warning>
  At the linked revision, `LlamaOpenAI` fails in its formatter before sending a request. The wrong model ID below cannot test retries. Use the working compatible adapter in the Current Alternative.
</Warning>

```python title="retry.py"
"""Example demonstrating how to set up retries with Meta Llama (using OpenAI-compatible endpoint)."""

from agno.agent import Agent
from agno.models.meta import LlamaOpenAI

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

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

agent = Agent(
    model=LlamaOpenAI(
        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 [#current-alternative]

Follow the [compatible basic example's setup](/examples/models/meta/llama-openai/basic#run-the-example) for dependencies and `LLAMA_API_KEY`, and confirm account access to the selected model. Save this complete program as `meta_retry.py` and run `python meta_retry.py`.

The generic compatible adapter preserves HTTP status codes: terminal 400/404 errors are not retryable. `client_params={"max_retries": 0}` disables the underlying OpenAI SDK retries, leaving Agno's retry settings to control attempts. A successful call does not exercise retries; use a controlled transient failure to test them.

```python title="meta_retry.py"
from agno.agent import Agent

from os import getenv

from agno.models.openai.like import OpenAILike


def llama_model(**kwargs):
    return OpenAILike(
        api_key=getenv("LLAMA_API_KEY"),
        base_url="https://api.llama.com/compat/v1/",
        supports_native_structured_outputs=False,
        supports_json_schema_outputs=True,
        **kwargs,
    )

agent = Agent(
    model=llama_model(
        id="Llama-4-Maverick-17B-128E-Instruct-FP8",
        retries=3,
        delay_between_retries=1,
        exponential_backoff=True,
        client_params={"max_retries": 0},
    )
)
agent.print_response("What is the capital of France?")
```

Full source: [cookbook/90\_models/meta/retry.py](https://github.com/agno-agi/agno/blob/8f36eaf2d18e91afa7b327eec66a3cd3685dcb87/cookbook/90_models/meta/retry.py)
