Skip to main content
AgentOS routes every team and flow you pass in as its own HTTP endpoint, and exposes a chat WebSocket that speaks the agent’s native achat/chat surface.

Quick Start

1

Serve teams, flows, and WebSocket chat

Pass teams= and flows= to AgentOS — each one becomes its own route, and /api/chat/stream is always available.
2

Call every surface

Teams and flows are plain POST endpoints; the chat stream is a WebSocket.

How It Works

A team or flow call acquires that instance’s lock, invokes the async entry point first, and offloads a sync target to a thread. A WebSocket frame clones and binds a per-request agent, then speaks its native chat surface.

Endpoint reference

Three surfaces resolve under the default /api prefix (AgentOSConfig.api_prefix).

Request and response shapes

Teams and flows share one request model; the WebSocket exchanges JSON frames.
Request:
Response:
Same shape as teams, with flow instead of team.Request:
Response:

Authentication (WebSocket)

The HTTP api-key middleware does not run on the WebSocket handshake. When you configure AgentOSConfig(api_key=...) or set PRAISONAI_AGENTOS_API_KEY, the WS endpoint checks the token itself and rejects unauthenticated clients with close code 1008 before accept(). Pass the token via Authorization: Bearer, X-API-Key, or ?api_key= in the URL — browsers can only use the query form. Comparison uses hmac.compare_digest.

Concurrency and session isolation

Teams and flows serialise per instance; chat clones its agent per request.
  • Each team and flow has a lazy per-instance asyncio.Lock — concurrent calls to the same instance queue, while different instances run in parallel (teams/flows carry mutable run state and cannot run re-entrantly).
  • Per-request chat uses an isolated agent clone via _isolate_agent() (chat history is not shared across callers), except when handoffs are configured on the template — those agents stay on the shared template because clone_for_channel drops handoffs, so delegation isn’t silently lost.
  • WebSocket calls use the exact same _isolate_agent() helper as POST /chat.

Choosing the right surface

Pick the surface that matches the interaction shape.

Best Practices

The lookup matches getattr(team, "name", None) against the path. Without a name, the call silently returns 404.
Set AgentOSConfig(api_key=...) (or PRAISONAI_AGENTOS_API_KEY) so the WebSocket endpoint isn’t an unauthenticated back door — the HTTP api-key middleware does not cover the WS handshake.
The socket stays open on {"error": ...}, so a retry can send another frame without a new handshake.
Teams and flows serialise same-instance calls. For true concurrency, build multiple team/flow instances — one per concurrent caller.

AgentOS Read Endpoints

Health, agents, approvals, and other read routes.

AgentOS Serve Reload

Hot-reload agents without restarting the server.

Session Persistence

Carry conversation state across calls with session_id.

Approval Protocol

Gate risky tool calls behind an approval registry.