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

# Llama OpenAI Metrics

> Stream a Llama 4 Maverick run with YFinance tools and inspect message, run, and session metrics.

> [!WARNING]
>
> This example reads `agent.run_response.messages`, but `Agent` does not expose that attribute. Update the saved file before running.

```python metrics.py theme={null}
"""
Meta Metrics
============

Cookbook example for `meta/llama_openai/metrics.py`.
"""

from typing import Iterator

from agno.agent import Agent, RunOutputEvent
from agno.models.meta import LlamaOpenAI
from agno.tools.yfinance import YFinanceTools
from agno.utils.pprint import pprint_run_response
from rich.pretty import pprint

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

agent = Agent(
    model=LlamaOpenAI(id="Llama-4-Maverick-17B-128E-Instruct-FP8"),
    tools=[YFinanceTools()],
    markdown=True,
)

run_stream: Iterator[RunOutputEvent] = agent.run(
    "What is the stock price of NVDA", stream=True
)
pprint_run_response(run_stream, markdown=True)

run_response = agent.get_last_run_output()

# Print metrics per message
if run_response.messages:
    for message in agent.run_response.messages:
        if message.role == "assistant":
            if message.content:
                print(f"Message: {message.content}")
            elif message.tool_calls:
                print(f"Tool calls: {message.tool_calls}")
            print("---" * 5, "Metrics", "---" * 5)
            pprint(message.metrics)
            print("---" * 20)

# Print the metrics
print("---" * 5, "Collected Metrics", "---" * 5)
pprint(run_response.metrics)
# Print the session metrics
print("---" * 5, "Session Metrics", "---" * 5)
pprint(agent.get_session_metrics())

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno llama-api-client openai yfinance
```

**2. Export your Meta Llama API key**

```bash Mac/Linux theme={null}
export LLAMA_API_KEY="your_llama_api_key_here"
```

```bash Windows theme={null}
$Env:LLAMA_API_KEY="your_llama_api_key_here"
```

**3. Correct the message metrics loop**

Replace `agent.run_response.messages` with `run_response.messages` in the saved file.

**4. Run the example**

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

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

Full source: [cookbook/90\_models/meta/llama\_openai/metrics.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/90_models/meta/llama_openai/metrics.py)


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