# Flyte

> Orchestrate ML pipelines, models, and agents at scale in pure Python

- Category: Models & Inference / GPU & Compute Clouds
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/flyteorg/flyte
- Website: https://flyte.org
- Canonical page: https://ai-tldr.dev/tools/flyte/

## In short

Flyte is a workflow engine for orchestrating machine learning pipelines, models, and agents in pure Python. You define tasks as plain Python functions, and Flyte runs them as a versioned, reproducible workflow that can scale from your laptop to a distributed cluster. It sits in the GPU & Compute Clouds category of the Models & Inference tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Flyte is a workflow engine for orchestrating machine learning pipelines, models, and agents in pure Python. You define tasks as plain Python functions, and Flyte runs them as a versioned, reproducible workflow that can scale from your laptop to a distributed cluster.

It is built for ML and data engineers who want to move from local scripts to production without rewriting their code. Flyte 2 lets you write ordinary async Python, run it locally with a single command, and execute the same code on a Kubernetes-native backend.

Within the compute orchestration space, Flyte focuses on reproducibility and versioning. Each task runs in a defined container image, and the same workflow can be invoked from Python or the Flyte CLI.

## What it does

- Define workflow tasks as plain Python functions using the @env.task decorator
- Write async pipelines and fan out work with calls like calculate.aio(num) plus asyncio.gather
- Pin each task to a container image with flyte.Image.from_debian_base and with_pip_packages
- Run the same code locally with python or remotely with the flyte run CLI
- Serve models as endpoints, including FastAPI apps via FastAPIAppEnvironment
- Local TUI for a richer development experience via the flyte[tui] extra

## Getting started

Install Flyte, write a task in Python, and run it locally or through the CLI.

1. Install Flyte

   Install the core package with uv. For the TUI local development experience, install the tui extra instead.

```bash
uv pip install flyte
```

2. Write a workflow

   Define a task environment and decorate Python functions as tasks. The async main task fans out work across the calculate task.

```python
import asyncio
import flyte

env = flyte.TaskEnvironment(
    name="hello_world",
    image=flyte.Image.from_debian_base(python_version=(3, 12)),
)

@env.task
def calculate(x: int) -> int:
    return x * 2 + 5

@env.task
async def main(numbers: list[int]) -> float:
    results = await asyncio.gather(*[
        calculate.aio(num) for num in numbers
    ])
    return sum(results) / len(results)

if __name__ == "__main__":
    flyte.init()
    run = flyte.run(main, numbers=list(range(10)))
    print(f"Result: {run.result}")
```

3. Run it

   Run the script directly with Python, or invoke the workflow through the Flyte CLI with inline arguments.

```bash
flyte run hello.py main --numbers '[1,2,3]'
```

## When to use it

- Turn local ML training scripts into versioned, reproducible pipelines that run on a cluster
- Fan out parallel data or model tasks using async Python and asyncio.gather
- Serve a trained model as an HTTP endpoint with a FastAPI app
- Run the same workflow locally during development and remotely in production without code changes
