翻篇收录说明
翻篇网页快照

Voice AI quickstart | LiveKit Documentation

https://docs.livekit.io/agents/start/voice-ai/

最近抓取:2026-12-05 12:46:03(北京时间)

最近内容变化:2026-12-03 10:45:54(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Build and deploy a simple voice assistant in less than 10 minutes.

正文摘录

OverviewThis guide walks you through the setup of your very first voice assistant using LiveKit Agents. In less than 10 minutes, you'll have a voice assistant that you can speak to in your terminal, browser, telephone, or native app.LiveKit Agent BuilderThe LiveKit Agent Builder is a quick way to get started with voice agents in your browser, without writing any code. It's perfect for prototyping and exploring ideas, but doesn't have as many features as the full LiveKit Agents SDK. See the Agent Builder guide for more details.RequirementsBefore you start, you need:PythonNode.jsThe uv package manager. It installs a supported Python version for you if you don't have one.Node.js >= 24.The pnpm package manager, version 10 or later.Install the LiveKit CLI The LiveKit CLI creates, runs, and deploys your agent. Install it for your operating system:macOSLinuxWindowsFrom SourceInstall the LiveKit CLI with Homebrew :brew install livekit-clicurl -sSL https://get.livekit.io/cli | bashTipYou can also download the latest precompiled binaries here .winget install LiveKit.LiveKitCLITipYou can also download the latest precompiled binaries here .This repo uses Git LFS for embedded video resources. Please ensure git-lfs is installed on your machine before proceeding.git clone github.com/livekit/livekit-climake installSign in to LiveKit CloudSign in to LiveKit Cloud and link a project to the CLI. If you don't have an account, sign up for free in the browser window that opens:lk cloud authSet up your coding agentInstall LiveKit's Agent Skills and Docs MCP server for your coding agents, like Claude Code , Cursor , or Codex . They teach your coding agent to build, test, and deploy LiveKit agents:lk skills install --globalCreate your agent Create your project from a starter:PythonNode.jslk agent init my-agent --template agent-starter-pythonlk agent init my-agent --template agent-starter-nodeThe CLI creates the my-agent directory from the Python or Node.js starter project, which includes a complete working agent, simulation scenarios, and an AGENTS.md for coding agents. It asks a few questions as it goes:Project. If you've linked more than one LiveKit Cloud project, confirm the one to use.Dependencies. Install them.Coding agents. Choose the coding agents to install the Agent Skills for in this project. A project copy stays with the code for anyone who clones it. Select none to rely on your global install.Run your agent Run your agent in development mode:cd my-agentlk agent devSpeak to your agentTalk to your agent in the Agent Console:Open the Agent Console link that lk agent dev prints.Click Start a session.Speak into your microphone.The Console shows your agent's responses in realtime. Its tool panes show events, tool calls, and model timing for each turn.Customize your agent Open the my-agent directory in your coding agent and describe the agent you want. The Agent Skills and the project's AGENTS.md show it how to build, test, and debug LiveKit agents. To get started, paste one of these prompts. Each one asks your coding agent to check its work: simulations grade whole conversations, and the agent debugger shows the tool calls and handoffs behind each reply.Give your agent a new personality:Turn this agent into a patient Spanish tutor. Speak mostly in Spanish, and switch to English when I get stuck. Add a simulation scenario that checks it switches languages, and update the existing scenarios to fit the new role.Keep track of state across the conversation:Make this agent a trivia host. Ask one question at a time, keep score, and get more dramatic as the game goes on. Play a few rounds with the agent debugger to check the score stays right.Give your agent a tool:Add a tool that looks up the current weather for a city with the Open-Meteo API. Write simulation scenarios for a real city and a made-up one, then try both with the agent debugger.Hand off between agents:Make this agent take a pizza order. When the order is complete, read it back and hand off to a separate checkout agent that confirms the delivery address. Run a full order through the agent debugger, including a change of mind.After each change, talk to your agent again in the Agent Console to try it out.Deploy to LiveKit Cloud Deploy your agent to LiveKit Cloud so it runs without your computer. From the my-agent directory, run:lk agent createThe CLI asks which region to deploy to, then registers your agent with your LiveKit Cloud project, builds it, and deploys it. To talk to the deployed agent, open your project's Agents dashboard and launch the Agent Console. To deploy later changes, run lk agent deploy. For more, see the deployment quickstart.Improve your agent After people talk to your deployed agent, your coding agent can read those sessions to find and fix problems. Sign in with your user account:lk cloud auth --user-authThen ask your coding agent to read your recent sessions with lk analytics and suggest fixes. To learn more, see Session data.Next stepsFollow these guides to bring your voice AI app to life in the real world.Web and mobile frontendsPut your agent in your pocket with a custom web or mobile app.Telephony integrationYour agent can place and receive calls with LiveKit's SIP integration.Testing your agentAdd behavioral tests to fine-tune your agent's behavior.Building voice agentsComprehensive documentation to build advanced voice AI apps with LiveKit.Agent serverLearn how to manage your agents with agent servers and jobs.Deploying to LiveKit CloudLearn more about deploying and scaling your agent in production.AI ModelsExplore the full list of AI models available with LiveKit Agents.RecipesA comprehensive collection of examples, guides, and recipes for LiveKit Agents.Appendix For reference, here's a complete working version of the quickstart agent. You don't need to copy it: lk agent init already created the starter project, which includes this agent plus tests and other extras.The agent uses an STT-LLM-TTS pipeline through LiveKit Inference, so you don't need provider API keys. Choose a pipeline to see its models and code. To compare them, see Pipeline types. For more models, see AI models.STT-LLM-TTS pipelineRealtime modelYour agent strings together three specialized models into a voice pipeline.ComponentModelAlternativesSTTAssemblyAI STT 3.7 Realtime AgentSTT modelsLLMGemma 4 31BLLM modelsTTSFish Audio S3 ProTTS models agent.pyPythonNode.jsfrom dotenv import load_dotenv from livekit import agentsfrom livekit.agents import AgentServer, AgentSession, Agent, inference, room_io, TurnHandlingOptionsfrom livekit.plugins import ai_coustics load_dotenv(".env.local") class Assistant(Agent): def __init__(self) -> None: super().__init__( instructions="""You are a helpful voice AI assistant. You eagerly assist users with their questions by providing information from your extensive knowledge. Your responses are concise, to the point, and without any complex formatting or punctuation including emojis, asterisks, or other symbols. You are curious, friendly, and have a sense of humor.""", ) server = AgentServer() @server.rtc_session(agent_name="my-agent")async def my_agent(ctx: agents.JobContext): session = AgentSession( stt=inference.STT(model="assemblyai/assemblyai-stt-3-7-realtime-agent"), llm=inference.LLM(model="google/gemma-4-31b-it"), tts=inference.TTS( model="fishaudio/s3-pro", voice="fa4c9eb3dccc4806b382b40d61c6b10a", ), turn_handling=TurnHandlingOptions( turn_detection=inference.TurnDetector(), ), ) await session.start( room=ctx.room, agent=Assistant(), room_options=room_io.RoomOptions( audio_input=room_io.AudioInputOptions( noise_cancellation=ai_coustics.audio_enhancement(model=ai_coustics.EnhancerModel.QUAIL_VF_S), ), ), ) await session.generate_reply( instructions="Greet the user and offer your assistance." ) if __name__ == "__main__": agents.cli.run_app(server)import { type JobContext, ServerOptions, cli, defineAgent, inference, voice,} from '@livekit/agents';import * as aiCoustics from '@livekit/plugins-ai-coustics';import { fileURLToPath } from 'node:url';import dotenv from 'dotenv';import { createAgent } from './agent'; dotenv.config({ path: '.env.local' }); export default defineAgent({ entry: async (ctx: JobContext) => { const session = new voice.AgentSession({ stt: new inference.STT({ model: 'assemblyai/assemblyai-stt-3-7-realtime-agent' }), llm: new inference.LLM({ model: 'google/gemma-4-31b-it' }), tts: new inference.TTS({ model: 'fishaudio/s3-pro', voice: 'fa4c9eb3dccc4806b382b40d61c6b10a', }), turnHandling: { turnDetection: new inference.TurnDetector(), }, }); await session.start({ agent: createAgent(), room: ctx.room, inputOptions: { noiseCancellation: aiCoustics.audioEnhancement({ model: aiCoustics.EnhancerModel.QuailVfS }), }, }); await ctx.connect(); const handle = session.generateReply({ instructions: 'Greet the user and offer your assistance.', }); },}); cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url), agentName: 'my-agent' }));import { voice } from '@livekit/agents'; export function createAgent() { return voice.Agent.create({ instructions: `You are a helpful voice AI assistant. You eagerly assist users with their questions by providing information from your extensive knowledge. Your responses are concise, to the point, and without any complex formatting or punctuation including emojis, asterisks, or other symbols. You are curious, friendly, and have a sense of humor.`, });}Your agent uses a single realtime model for an expressive, lifelike voice.ModelAlternativesOpenAI GPT Realtime 2.1Realtime models agent.pyPythonNode.jsfrom dotenv import load_dotenv from livekit import agentsfrom livekit.agents import AgentServer, AgentSession, Agent, inference, room_iofrom livekit.plugins import ai_coustics load_dotenv(".env.local") class Assistant(Agent): def __init__(self) -> None: super().__init__(instructions="You are a helpful voice AI assistant.") server = AgentServer() @server.rtc_session(agent_name="my-agent")async def my_a