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

# Arize Phoenix Via OpenInference

> Trace a structured-output stock agent to Phoenix Cloud via phoenix.otel register with auto-instrumentation.

Demonstrates instrumenting an Agno agent with OpenInference and sending traces to Phoenix.

```python arize_phoenix_via_openinference.py theme={null}
"""
Arize Phoenix Via OpenInference
===============================

Demonstrates instrumenting an Agno agent with OpenInference and sending traces to Phoenix.
"""

import asyncio
import os

from agno.agent import Agent
from agno.db.in_memory import InMemoryDb
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
from phoenix.otel import register
from pydantic import BaseModel

# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
os.environ["PHOENIX_API_KEY"] = os.getenv("PHOENIX_API_KEY")
os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = (
    "https://app.phoenix.arize.com/"  # Add the suffix for your organization
)

# Configure the Phoenix tracer
tracer_provider = register(
    project_name="default",  # Default is 'default'
    auto_instrument=True,  # Automatically use the installed OpenInference instrumentation
)


class StockPrice(BaseModel):
    stock_price: float


# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    name="Stock Price Agent",
    model=OpenAIChat(id="gpt-5.2"),
    tools=[YFinanceTools()],
    db=InMemoryDb(),
    instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
    session_id="test_123",
    output_schema=StockPrice,
)


# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    asyncio.run(
        agent.aprint_response("What is the current price of Tesla?", stream=True)
    )
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno arize-phoenix openai openinference-instrumentation-agno yfinance
```

**2. Export your API keys**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
export PHOENIX_API_KEY="your_phoenix_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
$Env:PHOENIX_API_KEY="your_phoenix_api_key_here"
```

**3. Run the example**

Save the code above as `arize_phoenix_via_openinference.py`, then run:

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

Full source: [cookbook/observability/arize\_phoenix\_via\_openinference.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/observability/arize_phoenix_via_openinference.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.