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

# MLflow Via Autolog

> Enable mlflow.agno.autolog() against a local MLflow tracking server to capture traces from a YFinance stock agent.

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

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno mlflow openai yfinance
```

**2. Export your OpenAI API key**

```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"
```

**3. Start MLflow**

Start the local MLflow receiver on port 5000:

```bash theme={null}
mlflow server --host 127.0.0.1 --port 5000
```

**4. Run the example**

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

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

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


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