Skip to main content

LiveKit Agents Plugin for SpatialReal Avatar

This plugin provides integration with SpatialReal's avatar service for lip-synced avatar rendering in LiveKit voice agents.

Installation

pip install livekit-plugins-spatialreal

Or install from source:

pip install -e .

Configuration

Set the following environment variables:

# Required
SPATIALREAL_API_KEY=your-api-key
SPATIALREAL_APP_ID=your-app-id
SPATIALREAL_AVATAR_ID=your-avatar-id

# Optional
SPATIALREAL_CONSOLE_ENDPOINT=
SPATIALREAL_INGRESS_ENDPOINT=

# LiveKit credentials
LIVEKIT_URL=
LIVEKIT_API_KEY=
LIVEKIT_API_SECRET=

Usage

from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
from livekit.plugins import spatialreal


class VoiceAssistant(Agent):
    def __init__(self):
        super().__init__(instructions="You are a helpful voice assistant.")


async def entrypoint(ctx: JobContext):
    await ctx.connect()

    # Configure your pipeline components (VAD, STT, LLM, TTS)
    session = AgentSession(
        vad=vad,
        stt=stt,
        llm=llm,
        tts=tts,
    )

    # Initialize and start the avatar session
    avatar = spatialreal.AvatarSession()
    await avatar.start(session, room=ctx.room)

    # Start the agent session
    await session.start(
        agent=VoiceAssistant(),
        room=ctx.room,
    )


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

For production agents, catch SpatialRealException so you can decide whether to fail the job or continue without avatar output:

try:
    await avatar.start(session, room=ctx.room)
except spatialreal.SpatialRealException as err:
    logger.error("Avatar startup failed: %s", err)
    raise

API Reference

AvatarSession

Main class for integrating SpatialReal avatars with LiveKit agents.

Constructor Parameters

Parameter Type Description
api_key str SpatialReal API key (or set SPATIALREAL_API_KEY)
app_id str SpatialReal application ID (or set SPATIALREAL_APP_ID)
avatar_id str Avatar ID to use (or set SPATIALREAL_AVATAR_ID)
console_endpoint_url str Custom console endpoint URL
ingress_endpoint_url str Custom ingress endpoint URL
avatar_participant_identity str LiveKit identity for avatar participant
avatar_participant_name str LiveKit display name for avatar participant
idle_timeout_seconds int LiveKit egress idle timeout in seconds (0 uses server defaults)
sample_rate int | None Optional avatar audio sample rate override

Methods

  • start(agent_session, room, *, livekit_url, livekit_api_key, livekit_api_secret): Start the avatar session and hook into the agent's audio output. Raises SpatialRealException with actionable context if startup fails.
  • aclose(): Clean up avatar session resources.

When starting, the plugin automatically sets lk.publish_on_behalf to the agent participant identity for avatar worker association in LiveKit frontends.

SpatialRealException

Exception raised for SpatialReal-related errors.

How It Works

  1. The plugin intercepts TTS audio output from the agent session
  2. Audio frames are forwarded to SpatialReal's avatar service
  3. SpatialReal generates lip-synced video and audio
  4. The avatar joins the LiveKit room and publishes the synchronized streams

License

Apache-2.0

Release files for livekit-plugins-spatialreal 1.6.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for livekit-plugins-spatialreal 1.6.8
File Size Uploaded
livekit_plugins_spatialreal-1.6.8.tar.gz 17.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for livekit-plugins-spatialreal 1.6.8
File Interpreter ABI Platform
livekit_plugins_spatialreal-1.6.8-py3-none-any.whl Python 3 none any Details

Total release size: 35.2 kB

Release files / livekit_plugins_spatialreal-1.6.8.tar.gz

Download URL livekit_plugins_spatialreal-1.6.8.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4a1c6164bc9de93ea1a99dd84362e7ba3e74818b04bc5f369cb7c9267257ce33
BLAKE2b-256 checksum
How to use checksums
1ad80146c445a3ddbca7906f5d7d31e5ea8bb4f183923cab86a76c186544d993
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / livekit_plugins_spatialreal-1.6.8-py3-none-any.whl

Download URL livekit_plugins_spatialreal-1.6.8-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
870162bb6e20378a97750c9ea202d825e7df3bcd188621c19b462a77f7d88e84
BLAKE2b-256 checksum
How to use checksums
eae1e5e91bb66b77b8c63e28a74a4259230284523bbe6b3bb1b210d71414971f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release history Release notifications | RSS feed

1.8.1

2 release files

1.8.0

2 release files

1.7.1

2 release files

This release

1.6.8 This release

2 release files

1.6.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page