Skip to main content
The user hits the recipe server over HTTP; Python 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

1

Simple Usage

Start a local recipe server:
Or via CLI:
2

With Configuration

Load settings from serve.yaml and override auth:

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.

Configuration Options

serve.yaml example

Set PRAISONAI_API_KEY in the environment instead of hardcoding keys.

Concurrency model

The recipe server keeps its event loop responsive while long recipes run. Every recipe.* call (list_recipes, describe, get_schema, run, validate, admin_reload) is dispatched through asyncio.to_thread. A long-running recipe no longer blocks the single event loop — /health, /metrics, and every other request keep responding during execution. SSE streaming (POST /v1/recipes/stream) drives the underlying sync generator on a worker thread and hands each event back to the loop through an asyncio.Queue (max 64 items). Events reach the client without any next() blocking the loop, and the worker is signalled and drained cleanly on client disconnect so no threads leak. For operators: a single uvicorn worker can serve mixed short and long recipes without starving readiness probes. You no longer need a separate process per long recipe to keep the health check responsive.
Non-blocking dispatch applies as of PraisonAI #4215. Sync recipe work is offloaded to a worker thread pool and SSE events are queued off the event loop.

Common Patterns

ASGI app for custom deployment

Unified agents.yaml config

Test with TestClient


Best Practices

Set auth: api-key and load the key from PRAISONAI_API_KEY. Never expose an unauthenticated recipe server on a public network.
Set preload: true to warm recipes at startup and eliminate cold-start latency on the first request.
Set cors_origins to your exact frontend domain in production rather than "*".
Use the /health endpoint in Docker, Kubernetes, and load-balancer health checks.

Recipe Serve Advanced

Rate limiting, metrics, admin reload, and OpenTelemetry

Endpoints Code

Client-side code for calling recipe endpoints