# Observability for Agno with Opik

> Start here to integrate Opik into your Agno-based genai application for end-to-end LLM observability, unit testing, and optimization.

[Agno](https://github.com/agno-agi/agno) is a lightweight, high-performance library for building AI agents.

Agno's primary advantage is its minimal overhead and efficient execution, making it ideal for production environments where performance is critical while maintaining simplicity in agent development.

<Frame>
  <img src="https://files.buildwithfern.com/https://opik.docs.buildwithfern.com/docs/opik/2026-01-30T17:33:07.444Z/img/tracing/agno_integration.png" alt="Agno tracing" />
</Frame>

## Getting started

To use the Agno integration with Opik, you will need to have the following
packages installed:

```bash
pip install -U agno openai opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-agno yfinance
```

In addition, you will need to set the following environment variables to
configure the OpenTelemetry integration:

<Tabs>
  <Tab value="Opik Cloud" title="Opik Cloud">
    If you are using Opik Cloud, you will need to set the following
    environment variables:

    ```bash wordWrap
    export OTEL_EXPORTER_OTLP_ENDPOINT=https://www.comet.com/opik/api/v1/private/otel
    export OTEL_EXPORTER_OTLP_HEADERS='Authorization=<your-api-key>,Comet-Workspace=default'
    ```

    <Tip>
      To log the traces to a specific project, you can add the
      `projectName` parameter to the `OTEL_EXPORTER_OTLP_HEADERS`
      environment variable:

      ```bash wordWrap
      export OTEL_EXPORTER_OTLP_HEADERS='Authorization=<your-api-key>,Comet-Workspace=default,projectName=<your-project-name>'
      ```

      You can also update the `Comet-Workspace` parameter to a different
      value if you would like to log the data to a different workspace.
    </Tip>
  </Tab>

  <Tab value="Enterprise deployment" title="Enterprise deployment">
    If you are using an Enterprise deployment of Opik, you will need to set the following
    environment variables:

    ```bash wordWrap
    export OTEL_EXPORTER_OTLP_ENDPOINT=https://<comet-deployment-url>/opik/api/v1/private/otel
    export OTEL_EXPORTER_OTLP_HEADERS='Authorization=<your-api-key>,Comet-Workspace=default'
    ```

    <Tip>
      To log the traces to a specific project, you can add the
      `projectName` parameter to the `OTEL_EXPORTER_OTLP_HEADERS`
      environment variable:

      ```bash wordWrap
      export OTEL_EXPORTER_OTLP_HEADERS='Authorization=<your-api-key>,Comet-Workspace=default,projectName=<your-project-name>'
      ```

      You can also update the `Comet-Workspace` parameter to a different
      value if you would like to log the data to a different workspace.
    </Tip>
  </Tab>

  <Tab value="Self-hosted instance" title="Self-hosted instance">
    If you are self-hosting Opik, you will need to set the following environment
    variables:

    ```bash
    export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:5173/api/v1/private/otel
    ```

    <Tip>
      To log the traces to a specific project, you can add the `projectName`
      parameter to the `OTEL_EXPORTER_OTLP_HEADERS` environment variable:

      ```bash
      export OTEL_EXPORTER_OTLP_HEADERS='projectName=<your-project-name>'
      ```
    </Tip>
  </Tab>
</Tabs>

## Using Opik with Agno

The example below shows how to use the Agno integration with Opik:

```python
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
from openinference.instrumentation.agno import AgnoInstrumentor
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor