Examples using
security: { mode: "local" } are for trusted local use. Hosted deployments require verified identity and resource authorization.Express REST Server
Serve any agent over HTTP withcreateAgentRouter. 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.
fetch:
Socket.IO Gateway
For real-time bidirectional communication, usecreateAgentGateway with Socket.IO. Agents registered in the global registry are immediately available.
Swagger UI
Enable auto-generated OpenAPI docs with interactive Swagger UI by passingswagger config. The spec is derived from your registered agents, teams, and workflows.
File Upload
Accept multimodal inputs (images, PDFs, audio) alongside text by enablingfileUpload. 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 throughcreateAgentRouter options.