API Reference¶
Complete reference for FastroAI's public API.
All classes, functions, and protocols documented here are considered stable and follow semantic versioning.
Looking for explanations?
This is a reference, not a tutorial. For explanations and examples, see the Guides.
Core Components¶
-
Agent
FastroAgent, AgentConfig, ChatResponse, StreamChunk
-
Pipelines
Pipeline, BaseStep, StepContext, configurations
-
Tools
@safe_tool decorator, SafeToolset, FunctionToolsetBase
-
Usage
CostCalculator with microcents precision
-
Tracing
Tracer protocol, SimpleTracer, LogfireTracer, NoOpTracer
Quick Import Reference¶
from fastroai import (
# Agent
FastroAgent,
AgentConfig,
ChatResponse,
StreamChunk,
# Pipelines
Pipeline,
PipelineResult,
PipelineConfig,
BaseStep,
StepContext,
StepConfig,
step,
ConversationState,
ConversationStatus,
# Tools
safe_tool,
SafeToolset,
FunctionToolsetBase,
# Tracing
Tracer,
SimpleTracer,
LogfireTracer,
NoOpTracer,
# Usage
CostCalculator,
# Errors
FastroAIError,
PipelineValidationError,
CostBudgetExceededError,
DispatchSkippedError,
ErrorCategory,
)
Error Hierarchy¶
All FastroAI exceptions inherit from FastroAIError, so you can catch all library errors with a single except clause:
FastroAIError # Base for all FastroAI errors
├── PipelineValidationError # Invalid pipeline configuration
├── StepExecutionError # Step failed during execution
├── CostBudgetExceededError # Cost budget exceeded
└── DispatchSkippedError # Raised from on_before_dispatch to short-circuit (no retry)
ErrorCategory (StrEnum: TRANSIENT, PERMANENT, RESOURCE_EXHAUSTION, UNKNOWN) is provided for callers that want to categorize exceptions inside on_after_dispatch (e.g., a circuit breaker that only counts transient failures toward its open threshold). The library doesn't auto-categorize.
try:
result = await pipeline.execute(inputs, deps)
except FastroAIError as e:
logger.error(f"FastroAI error: {e}")