asyncio.run().
Quick Start
FastAPI Route
The headline use case — running crews inside FastAPI routes without blocking the event loop:
How It Works
| Function | Method | When Used |
|---|---|---|
| Sync | praisonai.run() | Plain scripts, CLI usage |
| Async | praisonai.arun() | FastAPI, Jupyter, event loop contexts |
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
agent_file | str | Required | Path to the agent YAML file |
framework | str | None | Framework to use (auto-detected if None) |
tools | list | None | Additional tools to make available |
agent_yaml | str | None | Direct YAML content as string |
cli_config | dict | None | CLI configuration overrides |
When to use which
Common Patterns
FastAPI Background Task
Concurrent Crew Execution
Best Practices
Prefer async entry point over wrapping sync
Prefer async entry point over wrapping sync
Use
praisonai.arun() instead of wrapping the sync version:Use asyncio.gather for concurrent crews
Use asyncio.gather for concurrent crews
When running multiple crews, use
asyncio.gather for parallel execution:Framework auto-detection works in async mode
Framework auto-detection works in async mode
All supported frameworks work transparently with async execution:
Handle errors gracefully in async contexts
Handle errors gracefully in async contexts
Wrap async crew execution in try-catch blocks:
Related
Async Bridge
Lower-level async utilities and bridging functions
Framework Adapter Plugins
Custom framework adapters with async support

