How It Works
Quick Start
Simple Usage
Enable rate limiting and metrics on an existing server:Scrape metrics at
GET /metrics (Prometheus format).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.| Feature | Endpoint / API | Purpose |
|---|---|---|
| Rate limiting | middleware | Cap requests per minute per client |
| Metrics | GET /metrics | Prometheus exposition |
| Admin reload | POST /admin/reload | Refresh recipe registry |
| Tracing | OpenTelemetry | Distributed request spans |
| Workers | serve(workers=N) | Multi-process scaling |
Configuration Options
| Key | Type | Default | Description |
|---|---|---|---|
rate_limit | int | 0 (disabled) | Requests per minute per client |
rate_limit_exempt_paths | list | ["/health", "/metrics"] | Paths exempt from rate limiting |
max_request_size | int | 10485760 (10MB) | Maximum request body size |
enable_metrics | bool | false | Enable /metrics endpoint |
enable_admin | bool | false | Enable /admin/* endpoints |
trace_exporter | str | "none" | Tracing exporter (none, otlp, jaeger, zipkin) |
otlp_endpoint | str | "http://localhost:4317" | OTLP collector endpoint |
service_name | str | "praisonai-recipe" | Service name for tracing |
workers | int | 1 | Worker processes (serve() argument) |
Common Patterns
Programmatic rate limiter
Admin reload
Prometheus scrape config
OpenTelemetry dependencies
Best Practices
Always enable auth with admin endpoints
Always enable auth with admin endpoints
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.Use workers for CPU-bound recipe loads
Use workers for CPU-bound recipe loads
Set
workers to roughly 2 × CPU cores + 1. Workers above 1 disable hot reload automatically.Exempt health and metrics from rate limits
Exempt health and metrics from rate limits
Keep
/health and /metrics in rate_limit_exempt_paths so orchestrators and Prometheus can poll without consuming quota.Use Redis for distributed rate limiting
Use Redis for distributed rate limiting
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).
Related
Recipe Serve
Programmatic server configuration and deployment
Endpoints Code
Client-side code for calling recipe endpoints

