Skip to main content

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, WorkerOptions, cli, inference
from livekit.plugins.ultravox.realtime import RealtimeModel

async def entrypoint(ctx: JobContext):
    await ctx.connect()
    
    session: AgentSession[None] = AgentSession(
        allow_interruptions=True,
        vad=inference.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,
    )

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

Voice Assistant with Tools

from livekit.agents import function_tool, Agent, AgentSession, JobContext, WorkerOptions, cli, inference
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=inference.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,
    )

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

livekit_plugins_ultravox-1.6.2.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

livekit_plugins_ultravox-1.6.2-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file livekit_plugins_ultravox-1.6.2.tar.gz.

File metadata

  • Download URL: livekit_plugins_ultravox-1.6.2.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for livekit_plugins_ultravox-1.6.2.tar.gz
Algorithm Hash digest
SHA256 320cab3607793682b84a059358fc1367039982776f7908cede85f6cad17483c6
MD5 fc42edfcbda366e4a23ab2df11191ae5
BLAKE2b-256 36f6f7d0b07c751b702b11287245d99839570547d9416ff9bc02499d96ff53f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_plugins_ultravox-1.6.2.tar.gz:

Publisher: publish.yml on livekit/agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_plugins_ultravox-1.6.2-py3-none-any.whl.

File metadata

File hashes

Hashes for livekit_plugins_ultravox-1.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ac48e21c108daa5535e7a97e79ed86b51a4611fbd786dd8f5152c51d7710f638
MD5 cb5a20a26935ff1dcfb5ee93a5682ada
BLAKE2b-256 a2b1960221573cf9ebabf734b4753bc8f442a21212b790806fe69f254453cf27

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_plugins_ultravox-1.6.2-py3-none-any.whl:

Publisher: publish.yml on livekit/agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page