Skip to main content
Use LiveKit Agents when you want to own the realtime worker, media rooms, LLM, tools, and turn policy. Add PyAI Hear and PyAI Speak as the speech components. If you would rather run the complete voice agent through one managed connection, use Omni.
The PyAI plugin is maintained by PyAI and currently supports LiveKit’s Python Agents SDK. LiveKit also supports Node.js, but the package in this guide does not.

What stays under your control

LiveKit keeps the room, media transport, worker lifecycle, VAD, LLM, tools, and application logic. PyAI handles streaming transcription and speech synthesis. Your existing LiveKit deployment model does not change.

Prerequisites

  • Python 3.10 or newer
  • A LiveKit Agents worker
  • A PyAI key with hear:stream, hear:transcribe, and speak:synthesize scopes
  • A voice id from GET https://api.pyai.com/v1/voices
A pyai_test_ sandbox key includes the required Hear and Speak scopes, starts working immediately, and does not require billing. Keep all API keys on the server-side worker.

Install

Install the verified public release from PyPI:
Set the key once:

Replace the speech components

Keep the LLM and tools your worker already uses. Change only the stt and tts values in AgentSession:
That is the integration. LiveKit pushes caller audio into pyai.STT, receives interim and final transcripts, runs your LLM and tools, then streams the generated text through pyai.TTS back into the room.

Worker function

Drop this function into the worker that already creates your LLM and VAD:
Call run_agent(ctx, llm, vad) from your existing entrypoint. Keep the same WorkerOptions and process command you already use.

Configuration

Hear speech-to-text

Hear streaming is English-only. The plugin resamples incoming LiveKit frames to 16 kHz and maps PyAI partials and finals to LiveKit transcript events. Its batch recognize() fallback uses the synchronous transcription endpoint.

Speak text-to-speech

Speak returns raw mono PCM at the session rate. Use a streaming-capable stock, cloned, or designed voice id available to the same PyAI organization.

Run and verify

1

Start the worker

Run the same LiveKit worker command you use today.
2

Join a room

Connect a browser, phone, or synthetic participant and speak one short sentence.
3

Check both speech directions

Confirm a final caller transcript reaches the worker and agent audio reaches the room. Then send a second turn on the same session to verify that finalization and interruption handling keep working.
4

Measure your complete path

Record transport region, worker region, LLM, VAD settings, voice, and PyAI region with any latency result. The framework path is the sum of every component.

Production notes

  • Keep the LiveKit worker and PyAI speech endpoints in nearby regions.
  • A live Hear socket counts against the PyAI key’s realtime concurrency.
  • Hear and Speak meter against your PyAI account. LiveKit Cloud, telephony, your LLM, and worker hosting remain separate.
  • Do not expose a long-lived PyAI key to a browser or room participant.
  • Use Omni instead when you want PyAI to own turn-taking, reasoning, tools, caller continuity when an Agent profile has continuity enabled and a caller key is available, and optional managed telephony as one system.

Troubleshooting

Which path should I choose?

Choose LiveKit + PyAI for WebRTC rooms, video or multi-participant media, component swapping, and worker-level control. Choose Omni for a phone-first agent where one managed realtime contract is more valuable than owning each stage.

LiveKit Agents documentation

Review LiveKit’s worker, room, telephony, and deployment model.

PyAI Omni overview

Compare the managed speech-to-speech path.