Skip to main content

Express REST Server

Serve any agent over HTTP with createAgentRouter. It auto-generates /agents/:name/run and /agents/:name/stream endpoints for every agent passed in.

Streaming Responses

The router exposes an SSE streaming endpoint at /agents/:name/stream automatically. Clients receive incremental data: frames as the model generates tokens.
Or call the streaming endpoint directly with fetch:

Socket.IO Gateway

For real-time bidirectional communication, use createAgentGateway with Socket.IO. Agents registered in the global registry are immediately available.

Swagger UI

Enable auto-generated OpenAPI docs with interactive Swagger UI by passing swagger config. The spec is derived from your registered agents, teams, and workflows.

File Upload

Accept multimodal inputs (images, PDFs, audio) alongside text by enabling fileUpload. Files are automatically converted into multi-part content arrays.

Per-Request API Keys

In multi-tenant deployments, each request can supply its own API key via headers. The router extracts provider-specific keys and forwards them to the model.

Multiple Agents on One Server

Serve several agents under distinct routes from a single Express app. Each agent gets its own /run and /stream endpoints.

Teams and Workflows via REST

Serve teams and workflows alongside agents. Each gets typed endpoints under /teams/:name/run and /workflows/:name/run.

CORS and Security

Configure CORS origins, rate limiting, and custom auth middleware through createAgentRouter options.

Health Check Endpoint

Add a health and readiness probe alongside the agent router for production deployments behind load balancers.