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

# MLflow Via Autolog

> Demonstrates tracing an Agno agent with MLflow's built-in autolog integration.

```python mlflow_via_autolog.py theme={null}
"""
MLflow Via Autolog
==================

Demonstrates tracing an Agno agent with MLflow's built-in autolog integration.

Requirements:
    pip install mlflow agno

Start MLflow:
    mlflow server --host 127.0.0.1 --port 5000

Then open http://127.0.0.1:5000 to view traces.

NOTE: You can also configure the tracking URI and experiment via environment
variables instead of calling the Python APIs:

    export MLFLOW_TRACKING_URI="http://127.0.0.1:5000"
    export MLFLOW_EXPERIMENT_NAME="Agno Agent"
"""

import mlflow
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools

# ---------------------------------------------------------------------------
# Setup — must be called BEFORE mlflow.agno.autolog()
# ---------------------------------------------------------------------------

# Point MLflow at a running tracking server
mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("Agno Agent")

# Enable MLflow tracing for Agno
mlflow.agno.autolog()

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIChat(id="gpt-5-mini"),
    tools=[YFinanceTools()],
    instructions="Use tables to display data. Don't include any other text.",
    markdown=True,
)
agent.print_response("What is the stock price of Apple?", stream=False)
```

## Run the Example

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

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

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

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

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

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

Full source: [cookbook/observability/mlflow\_via\_autolog.py](https://github.com/agno-agi/agno/blob/main/cookbook/observability/mlflow_via_autolog.py)
