Agno

Agno is a lightweight, high-performance library for building Agents.

Opik’s integration with Agno relies on OpenTelemetry. You can learn more about Opik’s OpenTelemetry features in our get started guide.

Getting started

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

$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:

If you are using Opik Cloud, you will need to set the following environment variables:

$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'

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

$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.

Using Opik with Agno

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

{pytest_codeblocks_skip=true}
1from agno.agent import Agent
2from agno.models.openai import OpenAIChat
3from agno.tools.yfinance import YFinanceTools
4from openinference.instrumentation.agno import AgnoInstrumentor
5from opentelemetry import trace as trace_api
6from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
7from opentelemetry.sdk.trace import TracerProvider
8from opentelemetry.sdk.trace.export import SimpleSpanProcessor
9
10# Configure the tracer provider
11tracer_provider = TracerProvider()
12tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
13trace_api.set_tracer_provider(tracer_provider=tracer_provider)
14
15# Start instrumenting agno
16AgnoInstrumentor().instrument()
17
18# Create and configure the agent
19agent = Agent(
20 name="Stock Price Agent",
21 model=OpenAIChat(id="gpt-4o-mini"),
22 tools=[YFinanceTools()],
23 instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
24 debug_mode=True,
25)
26
27# Use the agent
28agent.print_response("What is the current price of Apple?")

Once the integration is set-up, you will see the trace in Opik: