Skip to main content
The user calls a hardened recipe HTTP endpoint; rate limits, metrics, and auth guard production traffic. Harden a recipe HTTP server with rate limits, Prometheus metrics, admin reload, and distributed tracing.

How It Works

Quick Start

1

Simple Usage

Enable rate limiting and metrics on an existing server:
Scrape metrics at GET /metrics (Prometheus format).
2

With Configuration

Production setup with auth, admin reload, workers, and tracing:

How It Works

Advanced features layer onto the base recipe server from Recipe Serve. Rate limiting uses a sliding window per client; metrics expose request counts and latency; admin endpoints hot-reload recipes without restart.

Configuration Options


Common Patterns

Programmatic rate limiter

Admin reload

Prometheus scrape config

OpenTelemetry dependencies

OpenTelemetry is lazily imported — if packages are missing, the server logs a warning and continues without tracing.

Best Practices

Set enable_admin=True only alongside auth: api-key and load the key from PRAISONAI_API_KEY. Admin reload can change live behaviour — protect it.
Set workers to roughly 2 × CPU cores + 1. Workers above 1 disable hot reload automatically.
Keep /health and /metrics in rate_limit_exempt_paths so orchestrators and Prometheus can poll without consuming quota.
The built-in limiter is in-memory per worker. For multi-node deployments, place a shared rate limiter in front of the service (API gateway or Redis-backed middleware).

Recipe Serve

Programmatic server configuration and deployment

Endpoints Code

Client-side code for calling recipe endpoints