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

# Groq Metrics

> Inspect token and timing metrics per message after a Groq agent run.

<Warning>
  For free and developer tiers, Groq will shut down `llama-3.3-70b-versatile` on August 16, 2026. Replace it with `openai/gpt-oss-120b` before that date. See [Groq deprecations](https://console.groq.com/docs/deprecations).
</Warning>

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

Cookbook example for `groq/metrics.py`.
"""

from agno.agent import Agent, RunOutput
from agno.models.groq import Groq
from agno.tools.yfinance import YFinanceTools
from agno.utils.pprint import pprint_run_response
from rich.pretty import pprint

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

agent = Agent(
    model=Groq(id="llama-3.3-70b-versatile"),
    tools=[YFinanceTools()],
    markdown=True,
)

run_output: RunOutput = agent.run("What is the stock price of NVDA")
pprint_run_response(run_output)

# Print metrics per message
if run_output.messages:
    for message in run_output.messages:  # type: ignore
        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_output.metrics)  # type: ignore

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

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

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno groq yfinance
    ```
  </Step>

  <Step title="Export your Groq API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export GROQ_API_KEY="your_groq_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:GROQ_API_KEY="your_groq_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Replace Llama 3.3">
    Replace `llama-3.3-70b-versatile` with `openai/gpt-oss-120b` in the saved file.
  </Step>

  <Step title="Run the example">
    Save the code above as `metrics.py`, then run:

    ```bash theme={null}
    python metrics.py
    ```
  </Step>
</Steps>

Full source: [cookbook/90\_models/groq/metrics.py](https://github.com/agno-agi/agno/blob/main/cookbook/90_models/groq/metrics.py)
