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

# Retry

> Example demonstrating how to set up retries with CometAPI.

```python retry.py theme={null}
"""Example demonstrating how to set up retries with CometAPI."""

from agno.agent import Agent
from agno.models.cometapi import CometAPI

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

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

agent = Agent(
    model=CometAPI(
        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
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export environment variables">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export COMETAPI_KEY="your_cometapi_key_here"
      ```

      ```bash Windows theme={null}
      $Env:COMETAPI_KEY="your_cometapi_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `retry.py`, then run:

    ```bash theme={null}
    python retry.py
    ```
  </Step>
</Steps>

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