Skip to main content
praisonai serve agents starts freely on localhost but requires an API key on any public bind, because POST /agents can execute YAML-defined tools.

Quick Start

1

Private mode (default)

Localhost binds need no key:
Any of 127.0.0.1, localhost, or ::1 starts without an API key.
2

Public mode (with key)

Non-localhost binds require a key. Generate one and start:
Or pass it as a flag:
3

Call a protected route

Send the key with either header:

The Localhost Allowlist

The server treats these hosts as private and skips the key requirement: “Non-localhost” means any --host value outside the allowlist above.

Configuration

Provide the key through either path — the flag wins if both are set. Generate a strong key with:

The SystemExit Error

Binding to a non-localhost host without a key exits immediately with:
Fix it by setting PRAISONAI_SERVE_API_KEY (or --api-key), or bind to 127.0.0.1 for a private-only server.

Protected vs Public Routes

When a key is set, most routes require the header. A few stay public for health checks and discovery. Both headers are equivalent and use constant-time comparison. Missing or wrong keys return 401 {"error": "Unauthorized"}.

Consistent YAML Lowering

Both POST /agents and POST /agents/{agent_name} flow through a single cached generator, so identical YAML gets identical treatment — guardrails, approval, tool_timeout, and retry settings now apply uniformly across both endpoints. The generator is cached for the app’s lifetime (built once at startup) instead of rebuilt per request, so requests share the same adapter, config list, and resolver.

Best Practices

Use openssl rand -hex 32 for a 256-bit key. Avoid short or guessable values.
Keep PRAISONAI_SERVE_API_KEY out of source control. Load it from your shell, a .env file that is git-ignored, or a secrets manager.
Inject the key from AWS Secrets Manager, Vault, or your platform’s secret store rather than hard-coding it in deploy scripts.
Rotate periodically and after any suspected exposure. Update both the server env and every client header at the same time.

Serve CLI

All praisonai serve commands and options

Agents HTTP Server

Deploy agents as an HTTP REST API