# LiveKit Agents

Use Reson8 speech-to-text with [LiveKit Agents](https://docs.livekit.io/agents/) to build real-time voice AI applications.

## Installation

```bash
pip install livekit-plugins-reson8 livekit-plugins-silero
```

## Quick start

```python
from livekit.agents import Agent, AgentSession, AutoSubscribe, JobContext, WorkerOptions, cli
from livekit.agents.stt import StreamAdapter
from livekit.plugins import reson8, silero

async def entrypoint(ctx: JobContext):
    await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)

    vad = silero.VAD.load()
    agent = Agent(
        instructions="You are a helpful Dutch-speaking assistant.",
        stt=StreamAdapter(stt=reson8.STT(language="nl"), vad=vad),
        llm=...,  # any LLM
        tts=...,  # any TTS
        vad=vad,
    )

    session = AgentSession()
    await session.start(agent=agent, room=ctx.room)
    await session.say("Hallo, hoe kan ik je helpen?")

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

## How it works

```
Microphone → Silero VAD → Reson8 STT → LLM → TTS → Speaker
```

Silero VAD detects speech segments. Each complete segment is sent to Reson8's [prerecorded REST API](../../api/speech-to-text/prerecorded.md), which returns the transcript. The LLM and TTS can be any provider supported by LiveKit, including models available through [LiveKit Inference](https://docs.livekit.io/agents/integrations/).

The batch approach with VAD segmentation gives Reson8 full utterances with complete context, producing faster and more accurate transcripts than streaming for conversational agents.

## Better turn handling

For more natural conversation pacing, add LiveKit's multilingual turn detector on top of VAD:

```bash
pip install livekit-plugins-turn-detector
```

```python
from livekit.plugins.turn_detector.multilingual import MultilingualModel

agent = Agent(
    ...
    vad=vad,
    turn_detection=MultilingualModel(),
)
```

This reduces premature interruptions when the user pauses mid-sentence. See the [LiveKit turn detection docs](https://docs.livekit.io/agents/build/turns/) for more.

## Configuration

Only `api_key` is required (can also be set via the `RESON8_API_KEY` environment variable). All other parameters are optional.

| Parameter | Required | Default | Description |
|---|---|---|---|
| `api_key` | Yes | `RESON8_API_KEY` env var | API key from [console.reson8.dev](https://console.reson8.dev) |
| `api_url` | No | `https://api.reson8.dev` | API base URL |
| `language` | No | `None` (auto-detect) | [Language code](../general/glossary.md) |
| `custom_model_id` | No | `None` | Custom model ID for domain-specific transcription |
| `sample_rate` | No | `16000` | Audio sample rate in Hz |
| `include_timestamps` | No | `False` | Include timing data on transcripts |
| `include_words` | No | `False` | Include word-level detail |
| `include_confidence` | No | `False` | Include confidence scores |

## Environment variables

```bash
RESON8_API_KEY=your-api-key
LIVEKIT_URL=wss://your-project.livekit.cloud
LIVEKIT_API_KEY=your-livekit-key
LIVEKIT_API_SECRET=your-livekit-secret
```

## Links

- [PyPI](https://pypi.org/project/livekit-plugins-reson8/)
- [GitHub](https://github.com/reson8labs/livekit-plugins-reson8)
- [LiveKit Agents documentation](https://docs.livekit.io/agents/)
