# Use Paxa with LiveKit Agents

Give a LiveKit voice agent a voice that speaks English, Thai, and Mandarin, and Paxa transcription, through LiveKit's OpenAI plugin.

Give your LiveKit voice agent a voice that speaks English, Thai, and Mandarin, mixed sentences included. LiveKit's OpenAI plugin connects to Paxa with a base URL and an API key, for text to speech and for speech to text.

## Install the plugin

Terminal:

```bash
pip install "livekit-agents[openai]"
export PAXA_API_KEY=pxa_your_key_here
```

## Give the agent a voice

Python:

```python
import os

from livekit.plugins import openai

paxa_tts = openai.TTS(
    base_url="https://api.paxalabs.com/v1",
    api_key=os.environ["PAXA_API_KEY"],
    model="paxa-tts-flash-v2",
    voice="khanomkrok",
    response_format="pcm",
)
```

- Set `model` to `paxa-tts-flash-v2`, or keep OpenAI's model names, which run on it. The plugin asks for an event stream on most model names, and Paxa answers with raw audio, which the plugin plays as it arrives.
- Set `voice` to any voice id from [GET /v1/voices](https://paxalabs.com/docs/api/voices) whose model is `paxa-tts-flash-v2`. OpenAI's voice names also work ([accepted voice names](https://paxalabs.com/docs/accepted-voice-names)).
- Keep `response_format="pcm"`. It returns 16-bit mono samples at 24 kHz, the rate the plugin plays, with no decoding step.
- Set `speed` between 0.5 and 1.5. A value outside that range answers 400.

The agent speaks a reply one sentence at a time. Thai written without punctuation counts as one sentence, and a long Thai reply then starts speaking only after the LLM finishes it.

## Add transcription

In the same file, create the transcription side and pass both to the session.

Python:

```python
from livekit.agents import AgentSession, inference

paxa_stt = openai.STT(
    base_url="https://api.paxalabs.com/v1",
    api_key=os.environ["PAXA_API_KEY"],
    model="paxa-stt-lite-v1-preview",
    language="th",
)

session = AgentSession(
    stt=paxa_stt,
    # Any LLM LiveKit Agents supports.
    llm=inference.LLM("openai/gpt-4.1-mini"),
    tts=paxa_tts,
    vad=inference.VAD(),
)
```

- The plugin transcribes each finished turn as one recording. The session needs a VAD to find where each turn ends.
- `language` passes a hint, such as `th`. Set `detect_language=True` to send none and let the model detect the language.
- Paxa STT Lite is a Research preview.

Argument names can differ between LiveKit Agents versions.
