Skip to main content
Deploy single or multi-agent systems as HTTP REST API servers.

Quick Start

1

Install Dependencies

2

Set API Key

3

Initialize Agents

4

Start Server (localhost)

Expected Output:
5

Start Server (public bind)

A non-localhost host requires an API key:
6

Verify

Security

praisonai serve agents drives YAML-defined tools (including execute_command), so binding it to a non-localhost interface without authentication is refused.
Binding to any host other than 127.0.0.1 / localhost requires an API key. The server exits immediately (SystemExit) if neither --api-key nor PRAISONAI_SERVE_API_KEY is set.
Clients then send the key in the Authorization: Bearer … header (mirrors jobs/server.py).

Python - Single Agent

Expected Output:

Python - Multi-Agent

Expected Output:
Multiple Agent / Agents instances may call .launch(port=N) concurrently from different threads β€” registration is atomic. If two launch calls use the same path on the same port, the second gets an auto-suffixed path (/path_abc123) and a warning is logged. Server readiness is signalled deterministically (no fixed sleep); .launch() returns only after the port is accepting connections. The wait defaults to 5 seconds and is configurable via the PRAISONAI_SERVER_READY_TIMEOUT environment variable. If the server doesn’t become ready in time, .launch() still returns and a warning is logged β€” check server logs for startup errors.

agents.yaml

CLI Commands

launch() Parameters

Endpoints

/agents and /agents/{agent_name} share one pipeline. The named-agent route previously used a hand-rolled agent that dropped every safety/reliability field; both routes now apply identical YAML lowering.

Example Request/Response

Request:
Response:

Remote Access

Use host="0.0.0.0" to allow remote connections. For praisonai serve agents, a non-localhost bind requires an API key (see Security):
praisonai serve agents --host 0.0.0.0 without --api-key / PRAISONAI_SERVE_API_KEY exits immediately with SystemExit. Set a key before binding remotely.
Connect from remote (include the Bearer key when serving agents):

How It Works

The agents server builds one shared generator per app and routes every request through the same YAML pipeline.
  • Generator cached per app. A FastAPI lifespan builds a single AgentsGenerator at startup and close()s it at shutdown β€” no per-request YAML re-parse, framework re-resolution, or fresh 32-worker tool-timeout pool on every call.
  • Concurrency-safe. Concurrent requests are serialised on the shared cli_config via a per-app asyncio.Lock.
  • Graceful fallback. If the cached generator can’t be built, the server falls back to the per-request praisonai.arun path.
  • Route convergence. Both /agents and /agents/{agent_name} run through the cached generator, so both apply identical YAML lowering (ToolResolver, tool_timeout, approval, guardrails, retry policy). POST /agents/{agent_name} returns 404 for an unknown name.

Environment Variables

Troubleshooting