Agent Framework plugin for services from Ultravox
Project description
LiveKit Ultravox Plugin
LiveKit plugin for Ultravox's real-time speech-to-speech AI models, providing seamless integration with the LiveKit Agents framework.
Installation
pip install livekit-plugins-ultravox
Prerequisites
You'll need an API key from Ultravox. Set it as an environment variable:
export ULTRAVOX_API_KEY="your_api_key_here"
Optional: enable debug logs for the plugin (disabled by default):
export LK_ULTRAVOX_DEBUG=true
Basic Usage
Simple Voice Assistant
import asyncio
from livekit.agents import Agent, AgentSession, JobContext, JobProcess, WorkerOptions, cli
from livekit.plugins import silero
from livekit.plugins.ultravox.realtime import RealtimeModel
async def entrypoint(ctx: JobContext):
await ctx.connect()
session: AgentSession[None] = AgentSession(
allow_interruptions=True,
vad=ctx.proc.userdata["vad"],
llm=RealtimeModel(
model_id="fixie-ai/ultravox",
voice="Mark",
),
)
await session.start(
agent=Agent(
instructions="You are a helpful voice assistant.",
),
room=ctx.room,
)
def prewarm(proc: JobProcess) -> None:
proc.userdata["vad"] = silero.VAD.load()
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm))
Voice Assistant with Tools
from livekit.agents import function_tool, Agent, AgentSession, JobContext, JobProcess, WorkerOptions, cli
from livekit.plugins import silero
from livekit.plugins.ultravox.realtime import RealtimeModel
@function_tool
async def get_weather(location: str) -> str:
"""Get weather information for a location."""
return f"The weather in {location} is sunny and 72°F"
@function_tool
async def book_appointment(date: str, time: str) -> str:
"""Book an appointment."""
return f"Appointment booked for {date} at {time}"
async def entrypoint(ctx: JobContext):
await ctx.connect()
session: AgentSession[None] = AgentSession(
allow_interruptions=True,
vad=ctx.proc.userdata["vad"],
llm=RealtimeModel(model_id="fixie-ai/ultravox"),
)
await session.start(
agent=Agent(
instructions="You are a helpful assistant with access to weather and scheduling tools.",
tools=[get_weather, book_appointment],
),
room=ctx.room,
)
def prewarm(proc: JobProcess) -> None:
proc.userdata["vad"] = silero.VAD.load()
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm))
Configuration Options
Ultravox API (/api/calls) Parameters
RealtimeModel(
model_id="fixie-ai/ultravox", # Model to use (warn + pass-through if unknown)
voice="Mark", # Voice to use (warn + pass-through if unknown)
api_key=None, # API key (defaults to env var)
base_url=None, # API base URL (defaults to Ultravox API)
system_prompt="You are helpful.", # System prompt
input_sample_rate=16000, # Input audio sample rate
output_sample_rate=24000, # Output audio sample rate
client_buffer_size_ms=60, # Audio buffer size (min 200ms used on WS)
http_session=None, # Custom HTTP session
)
Notes:
- Unknown models/voices: the plugin logs a warning and sends them as-is; the server validates.
- Metrics: the plugin emits a single `metrics_collected` event per generation. To log them,
add a listener in your app and call the helper:
```python
from livekit.agents import metrics
@session.on("metrics_collected")
def on_metrics_collected(ev):
metrics.log_metrics(ev.metrics)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file livekit_plugins_ultravox-1.5.12.tar.gz.
File metadata
- Download URL: livekit_plugins_ultravox-1.5.12.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02d53ca0e3d3d60fda320ade38c9b761540f003a289f2ea6f0f468726b3cc49c
|
|
| MD5 |
c9e4b1f8663fe7a4276fa6d585ae9995
|
|
| BLAKE2b-256 |
b58c3824b2503fcdf298c882f97a718be3faeb07f70f9b742dc895c2164b96ce
|
Provenance
The following attestation bundles were made for livekit_plugins_ultravox-1.5.12.tar.gz:
Publisher:
publish.yml on livekit/agents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livekit_plugins_ultravox-1.5.12.tar.gz -
Subject digest:
02d53ca0e3d3d60fda320ade38c9b761540f003a289f2ea6f0f468726b3cc49c - Sigstore transparency entry: 1589188036
- Sigstore integration time:
-
Permalink:
livekit/agents@2992996767acffc16aeaa46a82a7e566741b65e9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/livekit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2992996767acffc16aeaa46a82a7e566741b65e9 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file livekit_plugins_ultravox-1.5.12-py3-none-any.whl.
File metadata
- Download URL: livekit_plugins_ultravox-1.5.12-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8625f488dceb6baa6cf55821d5e766b77258ce617a406031761d9042de0d0968
|
|
| MD5 |
b981ce85272ea509bbba15f5c1debb1b
|
|
| BLAKE2b-256 |
0a3e3d1e765a714fbc24ef4169b275ca2e9a6898f65b694eaafc5edde2df7c1c
|
Provenance
The following attestation bundles were made for livekit_plugins_ultravox-1.5.12-py3-none-any.whl:
Publisher:
publish.yml on livekit/agents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livekit_plugins_ultravox-1.5.12-py3-none-any.whl -
Subject digest:
8625f488dceb6baa6cf55821d5e766b77258ce617a406031761d9042de0d0968 - Sigstore transparency entry: 1589188368
- Sigstore integration time:
-
Permalink:
livekit/agents@2992996767acffc16aeaa46a82a7e566741b65e9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/livekit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2992996767acffc16aeaa46a82a7e566741b65e9 -
Trigger Event:
pull_request
-
Statement type: