Production-ready orchestration for AI agents, built with Pydantic.
Project description
Flujo
A powerful Python library for orchestrating AI workflows using Pydantic models.
The flujo package (repository hosted at
github.com/aandresalvarez/flujo)
provides utilities to manage multi-agent pipelines with minimal setup.
Features
- 📦 Pydantic Native – agents, tools, and pipeline context are all defined with Pydantic models for reliable type safety.
- 🔁 Opinionated & Flexible – the
Defaultrecipe gives you a ready‑made workflow while the DSL lets you build any pipeline. - 🏗️ Production Ready – retries, telemetry, and quality controls help you ship reliable systems.
- 🧠 Intelligent Evals – automated scoring and self‑improvement powered by LLMs.
Quick Start
Installation
pip install flujo
Basic Usage
from flujo.recipes import Default
from flujo import (
Task,
review_agent, solution_agent, validator_agent,
init_telemetry,
)
# Optional: enable telemetry for your application
init_telemetry()
# Assemble an orchestrator with the library-provided agents. The class
# runs a fixed pipeline: Review -> Solution -> Validate.
flujo = Default(
review_agent=review_agent,
solution_agent=solution_agent,
validator_agent=validator_agent,
)
# Define a task
task = Task(prompt="Write a Python function to calculate Fibonacci numbers")
# Run synchronously
best_candidate = flujo.run_sync(task)
# Print the result
if best_candidate:
print("Solution:\n", best_candidate.solution)
if best_candidate.checklist:
print("\nQuality Checklist:")
for item in best_candidate.checklist.items:
status = "✅ Passed" if item.passed else "❌ Failed"
print(f" - {item.description:<45} {status}")
else:
print("No solution found.")
Pipeline Example
from flujo import (
Step, Flujo, Task,
review_agent, solution_agent, validator_agent,
)
# Build a custom pipeline using the Step DSL. This mirrors the internal
# workflow used by :class:`Default` but is fully configurable.
custom_pipeline = (
Step.review(review_agent)
>> Step.solution(solution_agent)
>> Step.validate(validator_agent)
)
pipeline_runner = Flujo(custom_pipeline)
# Run synchronously; Flujo returns a PipelineResult.
pipeline_result = pipeline_runner.run(
"Generate a REST API using FastAPI for a to-do list application."
)
print("\nPipeline Execution History:")
for step_res in pipeline_result.step_history:
print(f"- Step '{step_res.name}': Success={step_res.success}")
if len(pipeline_result.step_history) > 1 and pipeline_result.step_history[1].success:
solution_output = pipeline_result.step_history[1].output
print("\nGenerated Solution:\n", solution_output)
Documentation
Getting Started
- Installation Guide: Detailed installation instructions
- Quickstart Guide: Get up and running quickly
- Core Concepts: Understand the fundamental concepts
User Guides
- Usage Guide: Learn how to use the library effectively
- Configuration Guide: Configure the orchestrator
- Tools Guide: Create and use tools with agents
- Pipeline DSL Guide: Build custom workflows
- Scoring Guide: Implement quality control
- Telemetry Guide: Monitor and analyze usage
Advanced Topics
- Extending Guide: Create custom components
- Use Cases: Real-world examples and patterns
- API Reference: Detailed API documentation
- Troubleshooting Guide: Common issues and solutions
Development
- Contributing Guide: How to contribute to the project
- Development Guide: Development setup and workflow
- Code of Conduct: Community guidelines
- License: Dual License (AGPL-3.0 + Commercial)
Examples
Check out the examples directory for more usage examples:
| Script | What it shows |
|---|---|
| 00_quickstart.py | Hello World with the Default recipe. |
| 01_weighted_scoring.py | Weighted scoring to prioritize docstrings. |
| 02_custom_agents.py | Building creative agents with custom prompts. |
| 03_reward_scorer.py | Using an LLM judge via RewardScorer. |
| 04_batch_processing.py | Running multiple workflows concurrently. |
| 05_pipeline_sql.py | Pipeline DSL with SQL validation plugin. |
| 06_typed_context.py | Sharing state with Typed Pipeline Context. |
| 07_loop_step.py | Iterative refinement using LoopStep. |
| 08_branch_step.py | Dynamic routing with ConditionalStep. |
Looking for more community resources? Check out the Awesome Flujo list.
Requirements
- Python 3.11 or higher
- OpenAI API key (for OpenAI models)
- Anthropic API key (for Claude models)
- Google API key (for Gemini models)
Installation
Basic Installation
pip install flujo
Development Installation
# Clone the repository
git clone https://github.com/aandresalvarez/flujo.git
cd flujo
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# or
.\venv\Scripts\activate # Windows
# Install development dependencies
pip install -e ".[dev]"
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Support
License
This project is dual-licensed:
-
Open Source License: GNU Affero General Public License v3.0 (AGPL-3.0)
- Free for open-source projects
- Requires sharing of modifications
- Suitable for non-commercial use
-
Commercial License
- For businesses and commercial use
- Includes support and updates
- No requirement to share modifications
- Contact for pricing and terms
For commercial licensing, please contact: alvaro@example.com
See LICENSE and COMMERCIAL_LICENSE for details.
Acknowledgments
- Pydantic for data validation
- OpenAI for GPT models
- Anthropic for Claude models
- Google for Gemini models
- All our contributors and users
Citation
If you use this project in your research, please cite:
@software{flujo,
author = {Alvaro Andres Alvarez},
title = {Flujo},
year = {2024},
url = {https://github.com/aandresalvarez/flujo}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flujo-0.4.1.tar.gz.
File metadata
- Download URL: flujo-0.4.1.tar.gz
- Upload date:
- Size: 123.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de37b481ae55a556370401630dd47a78463d2400166cd15b5dfff0aaacb03b6
|
|
| MD5 |
191df1c742b21dd9d31a883b04d54c53
|
|
| BLAKE2b-256 |
de8db12a8d8b54d77288a31d4d6588561011e157bc1acedc21a7ac34fb9b68c9
|
Provenance
The following attestation bundles were made for flujo-0.4.1.tar.gz:
Publisher:
release.yml on aandresalvarez/flujo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flujo-0.4.1.tar.gz -
Subject digest:
3de37b481ae55a556370401630dd47a78463d2400166cd15b5dfff0aaacb03b6 - Sigstore transparency entry: 242579341
- Sigstore integration time:
-
Permalink:
aandresalvarez/flujo@87744cd5fa2eed11488ea7e5dc9044154b407473 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/aandresalvarez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@87744cd5fa2eed11488ea7e5dc9044154b407473 -
Trigger Event:
push
-
Statement type:
File details
Details for the file flujo-0.4.1-py3-none-any.whl.
File metadata
- Download URL: flujo-0.4.1-py3-none-any.whl
- Upload date:
- Size: 57.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebecd92f9e3856455d6c6e9b5999df417e4fee300ce16f53c06010ffd2b4ec35
|
|
| MD5 |
d9d855958bd4e12246c2edfa7dd3ba69
|
|
| BLAKE2b-256 |
c8dd11a0716186bea26ef37976fcfad95760751a1aed02e0b7249977b47cc2d3
|
Provenance
The following attestation bundles were made for flujo-0.4.1-py3-none-any.whl:
Publisher:
release.yml on aandresalvarez/flujo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flujo-0.4.1-py3-none-any.whl -
Subject digest:
ebecd92f9e3856455d6c6e9b5999df417e4fee300ce16f53c06010ffd2b4ec35 - Sigstore transparency entry: 242579343
- Sigstore integration time:
-
Permalink:
aandresalvarez/flujo@87744cd5fa2eed11488ea7e5dc9044154b407473 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/aandresalvarez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@87744cd5fa2eed11488ea7e5dc9044154b407473 -
Trigger Event:
push
-
Statement type: