Skip to main content

Lightweight AI orchestration built on PydanticAI

Project description

FastroAI

Lightweight AI orchestration built on PydanticAI.

FastroAI Logo

DocumentationDiscordGitHub


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.

Support

License

MIT


Built by Benav Labs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastroai-0.6.0.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastroai-0.6.0-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

Details for the file fastroai-0.6.0.tar.gz.

File metadata

  • Download URL: fastroai-0.6.0.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for fastroai-0.6.0.tar.gz
Algorithm Hash digest
SHA256 2c7016daf2d89d21a5fb0a8d9981750000d1f0ba655124d768787cfe25734379
MD5 0b18aafb7eb6a45882bec1e9d28f46ed
BLAKE2b-256 1063f3d7f0e6a32c5225e303ddda087cb434e9e704885e54ba80e93e24531bab

See more details on using hashes here.

File details

Details for the file fastroai-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: fastroai-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 43.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for fastroai-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cda8133934514e7224b8378daa958e4e19b602a10bf1d0efefbc0b7896b6860
MD5 7a08d63e691838a1c363a1129a9e3000
BLAKE2b-256 d4671e74b6709b8b6f01ac4c5f0b82b540186b001ced4f1d41fd393e8defdd9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page