how can i create apis for multiple agents
# ask-ai
s
how can i create apis for multiple agents
t
Thanks for reaching out, ABHIRAM. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It sounds like you want an API layer that can drive multiple LiveKit agents. Here are the two common patterns you can use: • Token endpoint (simple, client-driven): 1) Your server issues an access token for a room. 2) Embed
room_config.agents
to auto-dispatch one or more agents on connect. 3) Clients use the token to join; agents start automatically. Docs: Authentication, Room config + agents • Explicit dispatch endpoint (flexible, server-driven): 1) Start workers with
agent_name
for each agent. 2) Your server calls the Agent Dispatch API to dispatch specific agents to a room, passing job metadata (JSON string). 3) Agents read metadata via
JobContext
. Docs: Agent dispatch, Job lifecycle & metadata For coordinating work across multiple agents, use: • function_tool for agent-to-agent handoffs and chaining. • Keep agents stateless; pass per-job context via metadata/UserData. • Optionally preserve chat context between agents. Docs: Multi-agent patterns, Workflows Would you like a minimal example for the token endpoint or the explicit dispatch endpoint (Node.js or Python)? Sources: Building Multi-Agent Architectures with LiveKit Agents | Python Agents Core Architecture | livekit/livekit_composite | DeepWiki | Node.js Agents Architecture | livekit/livekit_composite | DeepWiki | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | SIP Integration & Telephony | livekit/livekit_composite | DeepWiki
s
how can i start multiple agents with api
t
It sounds like you want to start multiple LiveKit agents programmatically. You have two API approaches: • Token-based auto-dispatch (simple) 1) Generate an access token for a room. 2) Set
room_config.agents
with multiple entries (each with
agent_name
and optional JSON
metadata
). 3) When the client connects with this token, all listed agents start. • Explicit dispatch (flexible, server-driven) 1) Run each worker with a distinct
agent_name
. 2) Call the Agent Dispatch API for each agent you want in the room, passing JSON metadata as a string. 3) Each agent reads metadata from its
JobContext
on start. For coordination between agents, use
function_tool
for handoffs and keep agents stateless, passing context via metadata/UserData. Want a minimal example for either method (Node.js or Python)?
s
how can i start multiple agent worker with api
t
It sounds like you want to programmatically start multiple agent workers (the processes that register with LiveKit and run jobs). You have two practical options: • Start multiple worker instances from your code or deploy multiple replicas ◦ Launch your worker app multiple times (separate processes/containers/VMs), each calling the worker start routine (e.g., `run_app`/`WorkerOptions`) to register with LiveKit. ◦ Scale replicas to the count you need; LiveKit will load-balance jobs across them. ◦ References: Worker lifecycle, Custom deployments. • Use the Agent deployment CLI to manage a pool of workers ◦ Create/deploy and scale your agent service, then use CLI commands to list/restart/scale instances as needed. ◦ Reference: Agent deployment CLI. Once your workers are running, start them in a room via: • Explicit dispatch: call the Agent Dispatch API for each
agent_name
you want in the room, optionally passing JSON metadata. Reference: Agent dispatch. Would you like a minimal example to spin up N worker processes and then dispatch them (Node.js or Python)? Sources: Worker lifecycle | LiveKit Docs | Agent dispatch | LiveKit Docs | Node.js Agents Architecture | livekit/livekit_composite | DeepWiki | An open source stack for real-time multimodal AI | Deploying to custom environments | LiveKit Docs
s
create me a api to start workers
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!