# LiveKit Voice Agent

Full-stack voice AI application template built with LiveKit Agents, Next.js, and Rime TTS.

- Repository: https://github.com/render-examples/voice-agent-template
- Stack: nextjs, typescript
- Tags: ai, full-stack, llm, voice, websockets
- URL: https://render.com/templates/livekit-voice-agent

## Why deploy LiveKit Voice Agent on Render?

LiveKit Voice Agent is a real-time voice AI application framework that combines LiveKit's WebRTC infrastructure with LLM-powered conversational agents. It enables developers to build voice-based AI assistants with speech recognition, text-to-speech, and GPT integration in a single deployable stack.

This template wires together a Next.js voice UI frontend and a LiveKit agent worker as separate Render services. The services are pre-configured with the necessary networking and environment variables—saving you from manually orchestrating this multi-service architecture.

The agent worker is set up with appropriate resource allocation (8GB+ RAM required for AI model loading) and health checks out of the box. One-click deploy gets both services running with auto-scaling enabled, so you skip the Docker orchestration and infrastructure configuration entirely.

## Architecture

```mermaid
flowchart LR
    User([User])
    LiveKit([LiveKit Cloud])
    Rime([Rime API])
    
    User -->|"voice/web"| voice-agent-app[voice-agent-app]
    voice-agent-app -->|"WebSocket"| LiveKit
    voice-agent-worker{{voice-agent-worker}} -->|"connects"| LiveKit
    voice-agent-worker -->|"TTS API"| Rime
```

## What you can build

After deploying, you'll have a browser-based voice chat application where users can speak directly with a GPT-5.2 Mini-powered AI agent. The system handles speech-to-text via AssemblyAI, generates responses, and speaks back using Rime's text-to-speech—all in real-time through LiveKit's infrastructure. You can customize the agent's personality and voice by editing a single configuration file.

## Key features

- *GPT-5.2 Mini LLM*: Uses OpenAI's GPT-5.2 Mini model for generating intelligent conversational responses in real-time voice interactions.
- *Rime TTS Integration*: Provides high-quality text-to-speech with multiple voice options (rainforest, lagoon, astra) using the mistv2 model.
- *AssemblyAI STT*: Leverages AssemblyAI for accurate speech-to-text transcription of user voice input.
- *Silero VAD*: Includes Silero voice activity detection for intelligent turn-taking and background noise reduction.
- *Render Auto-scaling Deployment*: Pre-configured render.yaml blueprint deploys separate Next.js app and LiveKit agent services with health checks and auto-scaling.

## Use cases

- Startup founder builds voice customer support bot for e-commerce store
- Developer creates hands-free voice assistant for smart home control
- Healthcare team prototypes patient intake system using conversational AI
- Educator builds interactive voice tutor for language learning app

## What's included

| Service | Type | Purpose |
|---------|------|---------|
| voice-agent-app | Web Service | Application service |
| voice-agent-worker | Private Service | Application service |

## Prerequisites

You bring:
- *[LiveKit API Key](https://cloud.livekit.io/)*: Your API key for authenticating with LiveKit Cloud's real-time communication platform.
- *[LiveKit API Secret](https://cloud.livekit.io/)*: Your secret key for securely signing tokens and authenticating with LiveKit Cloud.
- *[LiveKit WebSocket URL](https://cloud.livekit.io/)*: The WebSocket URL for connecting to your LiveKit Cloud project.
  - Note: You'll use this for the `LIVEKIT_API_SECRET` and `NEXT_PUBLIC_LIVEKIT_URL` environment variables (since Next.js conventionally uses two separate variables in this context).
- *[Rime API Key](https://rime.ai/)*: API key for Rime's high-quality text-to-speech service used for voice synthesis.

Already in place:
- *[OpenAI API Key](https://platform.openai.com/api-keys)*: API key for accessing OpenAI's GPT-5.2 Mini model that powers the AI assistant's responses.
- *[AssemblyAI API Key](https://www.assemblyai.com/)*: API key for AssemblyAI's speech-to-text service used for accurate speech recognition.

## Next steps

1. Open your web app URL and click the microphone button to start a voice conversation — You should hear the agent greet you and see the voice activity indicator respond to your speech within 2-3 seconds
2. Test the agent's responsiveness by asking a simple question like 'What can you help me with?' — You should receive a spoken response from the Rime TTS voice (lagoon) within 5 seconds, confirming GPT-5.2 Mini and AssemblyAI are connected
3. Open the Render dashboard and check the agent worker logs under the agent service — You should see 'Agent connected' messages and real-time transcription logs showing your speech being processed

## Resources

- [LiveKit Agents official site](https://docs.livekit.io/agents)
