Skip to main content

FastroAI

Lightweight AI orchestration built on PydanticAI.

FastroAI Logo

Documentation • Discord • GitHub


PyPI Python PydanticAI License


FastroAI wraps PydanticAI with production essentials: cost tracking in microcents, multi-step pipelines, and tools that handle failures gracefully.

Note: FastroAI is experimental, it was extracted into a package from code that we had in production in different contexts. We built it for ourselves but you're free to use and contribute. The API may change between versions and you'll probably find bugs, we're here to fix them. Use in production at your own risk (we do).

Features

  • Cost Tracking: Automatic cost calculation in microcents. No floating-point drift.
  • Pipelines: DAG-based workflows with automatic parallelization.
  • Safe Tools: Timeout, retry, and graceful error handling for AI tools.
  • Tracing: Built-in Logfire integration, or bring your own observability platform.

Installation

pip install fastroai

With Logfire tracing:

pip install fastroai[logfire]

Or with uv:

uv add fastroai
uv add "fastroai[logfire]"  # With Logfire tracing

Quick Start

from fastroai import FastroAgent

agent = FastroAgent(
    model="openai:gpt-4o",
    system_prompt="You are a helpful assistant.",
)

response = await agent.run("What is the capital of France?")

print(response.content)
print(f"Cost: ${response.cost_dollars:.6f}")

Every response includes token counts and cost. No manual tracking required.

Pipelines

Chain multiple AI steps with automatic parallelization:

from fastroai import FastroAgent, Pipeline

extract = FastroAgent(model="openai:gpt-4o-mini", system_prompt="Extract entities.")
classify = FastroAgent(model="openai:gpt-4o-mini", system_prompt="Classify documents.")

pipeline = Pipeline(
    name="processor",
    steps={
        "extract": extract.as_step(lambda ctx: ctx.get_input("text")),
        "classify": classify.as_step(lambda ctx: ctx.get_dependency("extract")),
    },
    dependencies={"classify": ["extract"]},
)

result = await pipeline.execute({"text": "Apple announced..."}, deps=None)
print(f"Total cost: ${result.usage.total_cost_dollars:.6f}")

Safe Tools

Tools that don't crash when external services fail:

from fastroai import safe_tool

@safe_tool(timeout=10, max_retries=2)
async def fetch_weather(location: str) -> str:
    """Get weather for a location."""
    async with httpx.AsyncClient() as client:
        resp = await client.get(f"https://api.weather.com/{location}")
        return resp.text

If the API times out, the AI receives an error message and can respond gracefully.

Documentation

  • Quick Start: Install and run your first agent in 2 minutes.
  • Guides: Deep dives into agents, pipelines, tools, and tracing.
  • API Reference: Complete reference for all classes and functions.

FastroAI Template

Looking for a complete AI SaaS starter? Check out FastroAI Template: authentication, payments, background tasks, and more built on top of this library.

FastroAI Template - the complete FastAPI SaaS template: auth, Stripe payments, entitlements, email, frontend and AI

Ship your SaaS faster with FastroAI →

Support

License

MIT


Built by Benav Labs

Metadata

Release files for fastroai 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastroai 0.6.1
File Size Uploaded
fastroai-0.6.1.tar.gz 4.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastroai 0.6.1
File Interpreter ABI Platform
fastroai-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 4.0 MB

Release files / fastroai-0.6.1.tar.gz

Download URL fastroai-0.6.1.tar.gz
Size 4.0 MB
Tags Source
SHA-256 checksum
How to use checksums
0c71a9f02f3fc9d315e8df8a9291f0d555db3a74eaddd43332f8127730e4d4e0
BLAKE2b-256 checksum
How to use checksums
1ae5b48b9e5d9c7ffe95bd0c03795bb7fe55a0880464a9d333caaf663189bf63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / fastroai-0.6.1-py3-none-any.whl

Download URL fastroai-0.6.1-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c7433ed896246eabb18f3e5c693eb46f0f561f9998ee32c57afb7768cbcc3ac
BLAKE2b-256 checksum
How to use checksums
ccdab7959999d6ecb36edc143d8a40cf38573720daf335c8974100ec5a35bbc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page