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

# Use Agno with CometAPI

> Use this guide to connect Agno agents to CometAPI with the CometAPI model provider, API key, and model ID.

[Agno](https://docs.agno.com/) lets you build and run AI agents in Python. Agno includes an official `CometAPI` model provider, so you can use CometAPI directly from `agno.models.cometapi` without creating a custom adapter.

## Prerequisites

* Python 3.10+
* The Agno Python package
* A CometAPI account with an active API key — [get yours in the dashboard](https://www.cometapi.com/console/token)

## Configure the integration

<Steps>
  <Step title="Install Agno">
    Install Agno in your Python environment:

    ```bash theme={null}
    pip install -U agno
    ```
  </Step>

  <Step title="Set your CometAPI API key">
    Store your CometAPI API key in the `COMETAPI_KEY` environment variable:

    ```bash theme={null}
    read -rsp "CometAPI API key: " COMETAPI_KEY
    printf '\n'
    export COMETAPI_KEY
    ```
  </Step>

  <Step title="Create an Agno agent">
    Use Agno's official `CometAPI` provider:

    ```python theme={null}
    from agno.agent import Agent
    from agno.models.cometapi import CometAPI

    agent = Agent(
        model=CometAPI(id="your-model-id"),
        markdown=True,
    )

    agent.print_response("Write a short product update in three bullet points.")
    ```

    Replace `your-model-id` with a current model ID from the [CometAPI Models page](/overview/models).
  </Step>

  <Step title="Run the agent">
    Save the example as `agent.py`, then run it from the same shell session:

    ```bash theme={null}
    python agent.py
    ```

    A successful response confirms that Agno is sending model calls through CometAPI.
  </Step>
</Steps>

## How Agno connects to CometAPI

Agno's official `CometAPI` provider reads `COMETAPI_KEY` from your environment and uses `https://api.cometapi.com/v1` as the default base URL. It extends Agno's OpenAI-compatible model interface internally, but your application code should import and instantiate `CometAPI`.

You can also pass the API key or base URL explicitly when your runtime cannot read environment variables:

```python theme={null}
import os

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

agent = Agent(
    model=CometAPI(
        id="your-model-id",
        api_key=os.environ["COMETAPI_KEY"],
        base_url="https://api.cometapi.com/v1",
    )
)

agent.print_response("Summarize the benefits of a unified AI API.")
```

## List available models

Agno's provider exposes `get_available_models()` for checking the model IDs available through your CometAPI account:

```python theme={null}
from agno.models.cometapi import CometAPI

model = CometAPI()
available_models = model.get_available_models()
print(available_models)
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Authentication errors">
    Confirm that `COMETAPI_KEY` is set in the same shell session that runs `agent.py`. If the variable is missing, Agno raises an authentication error before sending the model request.
  </Accordion>

  <Accordion title="Model errors">
    Confirm that the `id` value matches a model ID from the [CometAPI Models page](/overview/models). You can also call `CometAPI().get_available_models()` to inspect model availability from your account.
  </Accordion>
</AccordionGroup>

## Related resources

* [Agno CometAPI provider documentation](https://docs.agno.com/models/providers/gateways/cometapi/overview)
* [Agno CometAPI provider source](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/models/cometapi/cometapi.py)
* [Agno CometAPI cookbook](https://github.com/agno-agi/agno/tree/main/cookbook/90_models/cometapi)
* [CometAPI quick start](/overview/quick-start)
* [CometAPI Models page](/overview/models)

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "HowTo",
        "@id": "https://apidoc.cometapi.com/integrations/agno#howto",
        "name": "Use Agno with CometAPI",
        "description": "Use this guide to connect Agno agents to CometAPI with the CometAPI model provider, API key, and model ID.",
        "step": [
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/agno#step-1",
            "position": 1,
            "name": "Install Agno",
            "text": "Complete the Install Agno step in the Use Agno with CometAPI guide."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/agno#step-2",
            "position": 2,
            "name": "Set your CometAPI API key",
            "text": "Store your CometAPI API key in the environment variable or settings field used by the integration."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/agno#step-3",
            "position": 3,
            "name": "Create an Agno agent",
            "text": "Complete the Create an Agno agent step in the Use Agno with CometAPI guide."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/agno#step-4",
            "position": 4,
            "name": "Run the agent",
            "text": "Complete the Run the agent step in the Use Agno with CometAPI guide."
          }
        ]
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "CometAPI Docs",
            "item": "https://apidoc.cometapi.com/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "Integrations",
            "item": "https://apidoc.cometapi.com/integrations"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "Use Agno with CometAPI",
            "item": "https://apidoc.cometapi.com/integrations/agno"
          }
        ]
      }
    ]
    }
    `}
</script>
