First agent
This guide walks through building a voice AI agent using VoiceGateway with LiveKit Agents. By the end you have a working agent that listens, thinks, and speaks using providers configured through VoiceGateway.Prerequisites
- Python 3.11+
- VoiceGateway installed with cloud providers:
pipx install 'voicegateway[cloud,dashboard]' - LiveKit Agents SDK:
pip install livekit-agents - API keys for at least one STT, LLM, and TTS provider
- A LiveKit server (Cloud or self-hosted): setup walkthrough below
LiveKit server setup
A LiveKit Agents worker connects to a LiveKit server over WebSocket. You have two options.Option A: LiveKit Cloud (free tier)
- Sign up at livekit.io.
- Create a project from the Cloud dashboard.
- On the project’s settings page, copy the WebSocket URL and the API key + secret pair.
Option B: self-hosted livekit-server (local development)
The fastest path on your laptop is the official Docker image with
the development flag:
--dev flag uses default credentials: API key devkey, API
secret secret. For a production self-hosted setup, follow the
LiveKit self-hosting guide.
Export credentials
Set three environment variables thatlivekit-agents reads at
startup:
ConnectionError: Failed to connect. Verify they are set:
Step 1: configure VoiceGateway
Create or update yourvoicegw.yaml:
Step 2: write the agent
Createagent.py:
Step 3: run the agent
Step 4: monitor with the dashboard
http://127.0.0.1:8080). The Costs page shows live cost tracking
per provider and per model, the Latency page shows p50 / p95 / p99
per model, and the Logs page shows the request stream for your
agent.
Routing to a different project
The agent above relies ondefault_project: my-agent in YAML. When
one process serves multiple agents, switch per request context with
set_project:
Adding fallbacks
For resolver-time fallback (try the next model in the chain when the primary fails at startup) walk a chain manually using the inference factories: iterate thefallbacks.<modality> list from
voicegw.yaml and use the first model whose provider plugin imports
cleanly.
Next steps
- Core concepts: understand gateways, stacks, projects, and fallbacks.
- Configuration reference: full YAML reference.
- Projects: per-project budgets and tracking.
- Providers: details on every supported provider.