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. The API may change between versions.

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: Protocol-based integration with any observability platform.

Installation

pip install fastroai

Or with uv:

uv add fastroai

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.2.0.tar.gz (3.7 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.2.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastroai-0.2.0.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.30

File hashes

Hashes for fastroai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5101b0c884866a258fc353a7caaff179d3c436f048c5d05dd14a2cb1907dbe47
MD5 031e9edaf5a4f231163972babb7cbb4e
BLAKE2b-256 6693cf64ac6c62017b1a4d27b261ed459bb77c5c714af3dd35ad78656d439f07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastroai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.30

File hashes

Hashes for fastroai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dce1b963438d639d082be9bbd3d0b3056824ed531f5fe4543e16d1eacdd95c62
MD5 899afce3a54feb84ef5bdcc8d787b7c1
BLAKE2b-256 10b071981a768977ec9e70da205cbb958784c41ccd73f46db66e34f4cab136b0

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