Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ make status # Show current linking status
make doctor # Check development environment health
```

## Starter templates

This repository's copy is `examples/voice_agents/basic_agent.py`. The starter voice agent has copies in five repositories, and they must stay in sync. The two starter projects are the source of truth:

- [livekit-examples/agent-starter-python](https://github.com/livekit-examples/agent-starter-python): `src/agent.py` and `scenarios.yaml`.
- [livekit-examples/agent-starter-node](https://github.com/livekit-examples/agent-starter-node): `src/agent.ts`, `src/main.ts`, and `scenarios.yaml`.
- [livekit/agents](https://github.com/livekit/agents): `examples/voice_agents/basic_agent.py`, a copy of the Python starter's `src/agent.py`. The trimmed snippets in `README.md`, `examples/README.md`, and `examples/voice_agents/README.md` use the same models.
- [livekit/agents-js](https://github.com/livekit/agents-js): `examples/src/basic_agent.ts`, a copy of the Node.js starter's `src/agent.ts` and `src/main.ts` in one file. The trimmed snippet in `README.md` uses the same models.
- [livekit/web](https://github.com/livekit/web): the appendix of `apps/docs/app/(default)/agents/start/voice-ai/page.mdoc`, which shows the starter code without comments for both pipelines; the default models in `apps/docs/lib/code-substitutions/static-substitutions.ts`; and the code samples on the www homepage (`VoiceAIBuildSection`) and the `products/agents-sdks`, `products/inference`, and `products/agent-platform` pages. Agent Builder's defaults for new agents also follow the starter: the models, voice, instructions, greeting, and expressive mode in `apps/cloud/components/builder/schema.ts`, and `DEFAULT_TTS_MODELS_BY_MODE` and `DEFAULT_PIPELINE_FORM_VALUES` in `apps/cloud/components/builder/AgentBuilderModelsAndVoiceOptions.tsx`.

When you change the starter agent's models, voice, instructions, tools, or session options:

1. Make the change in both starters, so the Python and Node.js agents stay equivalent.
2. Copy it to every file listed above in the same round of PRs, and link the PRs to each other. If you can't update a repository, open an issue there.
3. Show OpenAI GPT-Live (`openai/gpt-live-1`) through LiveKit Inference as the speech-to-speech alternative. Don't show the OpenAI Realtime API, which is deprecated.

`basic_agent` is a copy of the starter, not a place for feature demos. To show off a new feature, write a new example. If every new agent should use the feature, add it to the starters first, then copy it everywhere.

## Architecture Overview

### Core Concepts
Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,21 @@ The Agent Skill works best alongside the MCP server: the skill teaches your agen

---

This is a trimmed version of the [starter agent](examples/voice_agents/basic_agent.py). For a complete project with tests, simulation scenarios, and a Dockerfile, start from [agent-starter-python](https://github.com/livekit-examples/agent-starter-python) with `lk agent init my-agent --template agent-starter-python`.

```python
from livekit.agents import (
Agent,
AgentServer,
AgentSession,
JobContext,
RunContext,
TurnHandlingOptions,
cli,
function_tool,
inference,
)
from livekit.agents.beta import EndCallTool


@function_tool
Expand All @@ -110,26 +114,25 @@ server = AgentServer()
@server.rtc_session()
async def entrypoint(ctx: JobContext):
session = AgentSession(
vad=inference.VAD(),
# any combination of STT, LLM, TTS, or realtime API can be used
# any combination of STT, LLM, TTS, or realtime model can be used
# this example shows LiveKit Inference, a unified API to access different models via LiveKit Cloud
# to use model provider keys directly, replace with the following:
# from livekit.plugins import deepgram, openai, cartesia
# stt=deepgram.STT(model="nova-3"),
# llm=openai.LLM(model="gpt-4.1-mini"),
# tts=cartesia.TTS(model="sonic-3", voice="9626c31c-bec5-4cca-baa8-f8ba9e84c8bc"),
stt=inference.STT("deepgram/nova-3", language="multi"),
stt=inference.STT("assemblyai/assemblyai-stt-3-7-realtime-agent"),
llm=inference.LLM("google/gemma-4-31b-it"), # low-latency gemma, hosted on LiveKit
tts=inference.TTS("cartesia/sonic-3", voice="9626c31c-bec5-4cca-baa8-f8ba9e84c8bc"),
tts=inference.TTS("fishaudio/s2.1-pro", voice="fa4c9eb3dccc4806b382b40d61c6b10a"),
turn_handling=TurnHandlingOptions(turn_detection=inference.TurnDetector()),
# to use OpenAI GPT-Live, a speech-to-speech model, instead of the pipeline above,
# remove stt, tts, and turn_handling, and set:
# llm="openai/gpt-live-1",
)

agent = Agent(
instructions="You are a friendly voice assistant built by LiveKit.",
tools=[lookup_weather],
# EndCallTool lets the agent hang up when the user is done
tools=[lookup_weather, EndCallTool()],
)

await session.start(agent=agent, room=ctx.room)
await session.generate_reply(instructions="greet the user and ask about their day")
await session.generate_reply(instructions="greet the user and offer to help")


if __name__ == "__main__":
Expand Down Expand Up @@ -186,8 +189,8 @@ class StoryAgent(Agent):
super().__init__(
instructions=f"You are a storyteller. Use the user's information in order to make the story personalized."
f"The user's name is {name}, from {location}",
# override the default model, switching to Realtime API from standard LLMs
llm=openai.realtime.RealtimeModel(voice="echo"),
# override the default model, switching to OpenAI GPT-Live, a speech-to-speech model
llm="openai/gpt-live-1",
chat_ctx=chat_ctx,
)

Expand Down Expand Up @@ -247,7 +250,7 @@ For more examples and detailed setup instructions, see the [examples directory](
<h3>🎙️ Starter Agent</h3>
<p>A starter agent optimized for voice conversations.</p>
<p>
<a href="examples/voice_agents/basic_agent.py">Code</a>
<a href="examples/voice_agents/basic_agent.py">Code</a> · <a href="https://github.com/livekit-examples/agent-starter-python">Starter project</a>
</p>
</td>
<td width="50%">
Expand Down
6 changes: 3 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Most examples use **LiveKit Inference** by default for STT, LLM, and TTS models.
from livekit.agents import inference

session = AgentSession(
stt=inference.STT("deepgram/nova-3"),
stt=inference.STT("assemblyai/assemblyai-stt-3-7-realtime-agent"),
llm=inference.LLM("google/gemma-4-31b-it"), # low-latency gemma, hosted on LiveKit
tts=inference.TTS("cartesia/sonic-3"),
tts=inference.TTS("fishaudio/s2.1-pro", voice="fa4c9eb3dccc4806b382b40d61c6b10a"),
)
```

**Note:** OpenAI Realtime and xAI Grok Voice models are available through `inference.RealtimeModel`, and OpenAI GPT-Live through `inference.DuplexModel(model="openai/gpt-live-1")`; use provider plugin classes for direct credentials or for other real-time models such as Amazon Nova Sonic.
**Note:** For a speech-to-speech model, use OpenAI GPT-Live through LiveKit Inference with `llm="openai/gpt-live-1"` (or `inference.DuplexModel(model="openai/gpt-live-1")`). xAI Grok Voice is available through `inference.RealtimeModel`; use provider plugin classes for direct credentials or for other realtime models such as Amazon Nova Sonic.

## 📁 Example Categories

Expand Down
8 changes: 4 additions & 4 deletions examples/voice_agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ Most examples use **LiveKit Inference** by default, which provides a unified API
from livekit.agents import inference

session = AgentSession(
stt=inference.STT("deepgram/nova-3"),
stt=inference.STT("assemblyai/assemblyai-stt-3-7-realtime-agent"),
llm=inference.LLM("google/gemma-4-31b-it"), # low-latency gemma, hosted on LiveKit
tts=inference.TTS("cartesia/sonic-3"),
tts=inference.TTS("fishaudio/s2.1-pro", voice="fa4c9eb3dccc4806b382b40d61c6b10a"),
)
```

**Note:** OpenAI Realtime and xAI Grok Voice models are available through `inference.RealtimeModel`, and OpenAI GPT-Live through `inference.DuplexModel(model="openai/gpt-live-1")`; use provider plugin classes for direct credentials or for other real-time models such as Amazon Nova Sonic.
**Note:** For a speech-to-speech model, use OpenAI GPT-Live through LiveKit Inference with `llm="openai/gpt-live-1"` (or `inference.DuplexModel(model="openai/gpt-live-1")`). xAI Grok Voice is available through `inference.RealtimeModel`; use provider plugin classes for direct credentials or for other realtime models such as Amazon Nova Sonic.

## Table of Contents

### Getting Started

- [`basic_agent.py`](./basic_agent.py) - A fundamental voice agent with STT, turn detection, preemptive generation, and metrics collection; switch its LLM to `inference.responses.LLM` for OpenAI models over the Responses API
- [`basic_agent.py`](./basic_agent.py) - The agent from the official [agent-starter-python](https://github.com/livekit-examples/agent-starter-python) template: an STT-LLM-TTS pipeline on LiveKit Inference with the LiveKit turn detector, keyterms, expressive TTS with fallback, noise cancellation, and an end call tool. Shows how to switch to OpenAI GPT-Live. For a full project with tests, simulation scenarios, and a Dockerfile, run `lk agent init my-agent --template agent-starter-python`

### MCP & External Integrations

Expand Down
Loading
Loading