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

# Workflow CLI

> Use `Workflow.cli_app()` for interactive command-line workflow runs.

Demonstrates using `Workflow.cli_app()` for interactive command-line workflow runs.

```python workflow_cli.py theme={null}
"""
Workflow CLI
============

Demonstrates using `Workflow.cli_app()` for interactive command-line workflow runs.
"""

import os
import sys

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.workflow import Workflow
from agno.workflow.step import Step

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
assistant_agent = Agent(
    name="CLI Assistant",
    model=OpenAIResponses(id="gpt-5.2"),
    instructions="Answer clearly and provide concise, actionable output.",
)

# ---------------------------------------------------------------------------
# Define Steps
# ---------------------------------------------------------------------------
assistant_step = Step(name="Assistant", agent=assistant_agent)

# ---------------------------------------------------------------------------
# Create Workflow
# ---------------------------------------------------------------------------
workflow = Workflow(
    name="Workflow CLI Demo",
    description="Simple workflow used to demonstrate the built-in CLI app.",
    steps=[assistant_step],
)

# ---------------------------------------------------------------------------
# Run Workflow
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    starter_prompt = os.getenv(
        "WORKFLOW_CLI_PROMPT",
        "Create a three-step plan for shipping a workflow feature.",
    )

    if sys.stdin.isatty():
        print("Starting interactive workflow CLI. Type 'exit' to stop.")
        workflow.cli_app(
            input=starter_prompt,
            stream=True,
            user="Developer",
            exit_on=["exit", "quit"],
        )
    else:
        print("Non-interactive environment detected; running a single response.")
        workflow.print_response(input=starter_prompt, stream=True)
        print("Run this script in a terminal to use interactive cli_app mode.")
```

## Run the Example

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

**1. Install dependencies**

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

**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. Run the example**

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

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

Full source: [cookbook/04\_workflows/06\_advanced\_concepts/run\_control/workflow\_cli.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/04_workflows/06_advanced_concepts/run_control/workflow_cli.py)


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