serve() config controls auth, CORS, and ports.
Expose recipe workflows over HTTP — configure auth, CORS, and deployment from Python or YAML.
How It Works
Quick Start
How It Works
create_app() builds a Starlette ASGI application; serve() runs it with uvicorn. Configuration merges file, environment variables, and Python overrides — CLI flags take highest precedence.
| Route | Method | Description |
|---|---|---|
/health | GET | Health check |
/v1/recipes | GET | List recipes |
/v1/recipes/{name} | GET | Describe recipe |
/v1/recipes/run | POST | Run recipe (sync) |
/v1/recipes/stream | POST | Run recipe (SSE) |
Configuration Options
| Key | Type | Default | Description |
|---|---|---|---|
host | str | "127.0.0.1" | Bind address |
port | int | 8765 | Listen port |
auth | str | "none" | Auth mode (none, api-key, jwt) |
api_key | str | env | API key when auth=api-key |
recipes | list | all | Recipe names to expose |
preload | bool | false | Warm recipes on startup |
cors_origins | str | "*" | Allowed CORS origins |
log_level | str | "info" | Server log level |
serve.yaml example
PRAISONAI_API_KEY in the environment instead of hardcoding keys.
Common Patterns
ASGI app for custom deployment
Unified agents.yaml config
Test with TestClient
Best Practices
Always use auth in production
Always use auth in production
Set
auth: api-key and load the key from PRAISONAI_API_KEY. Never expose an unauthenticated recipe server on a public network.Preload recipes for faster startup
Preload recipes for faster startup
Set
preload: true to warm recipes at startup and eliminate cold-start latency on the first request.Restrict CORS origins
Restrict CORS origins
Set
cors_origins to your exact frontend domain in production rather than "*".Poll /health for orchestration
Poll /health for orchestration
Use the
/health endpoint in Docker, Kubernetes, and load-balancer health checks.Related
Recipe Serve Advanced
Rate limiting, metrics, admin reload, and OpenTelemetry
Endpoints Code
Client-side code for calling recipe endpoints

