A production-ready voice agent built with LiveKit Agents, featuring real-time speech processing, AI-powered responses, and seamless integration with LiveKit's real-time communication platform. This agent can handle voice interactions, process natural language, and integrate with various AI services.
- Python 3.12+ - Download Python
- UV (recommended) or pip - Install UV
- LiveKit Server - Get LiveKit Cloud or Self-host
- Mistral AI API Key - Get API Key
- FFmpeg - Required for audio processing (Installation Guide)
-
Clone and setup
# Clone the repository git clone https://github.com/yourusername/livekit-voice-agent.git cd livekit-voice-agent # Create and activate virtual environment (recommended) python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate # Install with UV (faster and more reliable) uv pip install -e . # Or with pip # pip install -e .
-
Configure Environment
Copy the example environment file and update with your credentials:
cp .env.example .env
Edit the
.envfile with your configuration:# Required: LiveKit Configuration LIVEKIT_URL=wss://your-instance.livekit.cloud LIVEKIT_API_KEY=your_api_key_here LIVEKIT_API_SECRET=your_api_secret_here # Required: Mistral AI Configuration MISTRAL_API_KEY=your_mistral_api_key_here # Optional: Voice Settings VOICE_MODEL=eleven-mono VOICE_SPEED=1.0 # Optional: Logging LOG_LEVEL=INFO
livekit-voice-agent/
├── agent.py # Main agent implementation and entry point
├── prompt.py # System prompts and conversation templates
├── tool.py # Custom tools and utilities
├── pyproject.toml # Project dependencies and configuration
├── .env.example # Example environment configuration
└── README.md # This file
-
Start the agent
# Basic usage python -m livekit_voice_agent.agent # With custom room and identity python -m livekit_voice_agent.agent --room my-room --identity assistant # With debug logging LOG_LEVEL=DEBUG python -m livekit_voice_agent.agent
-
Connect to the Agent
Option 1: LiveKit Test App
- Go to LiveKit Test App
- Enter the same room name you started the agent with
- Start a voice call and interact with the agent
Option 2: Custom Client Use any LiveKit client SDK to connect to the room where the agent is running.
Modify agent.py to customize:
- Voice model and parameters
- Audio processing settings
- Timeout and retry configurations
Edit prompt.py to adjust:
- Agent personality and behavior
- Response style and formatting
- Context and memory settings
Enhance tool.py to add:
- New functionality via custom tools
- API integrations
- Data processing utilities
| Variable | Required | Description |
|---|---|---|
LIVEKIT_URL |
Yes | WebSocket URL of your LiveKit server |
LIVEKIT_API_KEY |
Yes | API key for LiveKit server |
LIVEKIT_API_SECRET |
Yes | API secret for LiveKit server |
MISTRAL_API_KEY |
Yes | API key for Mistral AI |
VOICE_MODEL |
No | Voice model to use (default: eleven-mono) |
LOG_LEVEL |
No | Logging level (DEBUG, INFO, WARNING, ERROR) |
livekit-agents: Core framework for building LiveKit agentslivekit-plugins-noise-cancellation: Real-time noise cancellationpython-dotenv: Environment variable managementpydantic: Data validation and settings managementloguru: Modern logging utility
black: Code formattingmypy: Static type checkingpytest: Testing frameworkpytest-asyncio: Async test support
-
Add new tools:
- Create a new function in
tool.py - Register it with the
@tool()decorator - Update the system prompt to inform the agent about the new tool
- Create a new function in
-
Modify behavior:
- Adjust the system prompt in
prompt.py - Modify the agent's logic in
agent.py
- Adjust the system prompt in
❌ Failed to connect to LiveKit server
- Verify
LIVEKIT_URLstarts withwss:// - Check API key/secret permissions
- Ensure your LiveKit server is running and accessible
❌ No audio detected
- Check microphone permissions
- Verify audio input/output devices
- Ensure FFmpeg is installed and in PATH
# Check for conflicts
uv pip check
# Resolve conflicts
uv pip install --upgrade-strategy=only-if-needed -e .- Check the LiveKit Documentation
- Search LiveKit Community
- Open an Issue for bugs or feature requests
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- LiveKit for the amazing real-time platform
- Mistral AI for powerful language models
- All contributors who help improve this project
by ~chaitanya