> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elbic.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Vapi Integration

> Use KugelAudio as a custom TTS provider in Vapi voice assistants: get an API key and voice ID, configure the assistant, set the audio format and troubleshoot.

KugelAudio has a built-in [Vapi custom TTS](https://docs.vapi.ai/customization/custom-voices/custom-tts) endpoint, so no proxy server is needed. Point your Vapi assistant at our API and you're done.

## Setup

### 1. Get your KugelAudio API key and a voice ID

- **API key:** open the [KugelAudio dashboard](/dashboard), then go to Settings → API Keys.
- **Voice ID:** open the [KugelAudio dashboard](/dashboard), go to Voices, pick a voice, and copy its numeric ID.

### 2. Configure your Vapi assistant

Use `PATCH /assistant/{id}` to update an existing assistant, or include the `voice` field when creating a new one with `POST /assistant`:

```json
{
  "voice": {
    "provider": "custom-voice",
    "server": {
      "url": "https://api.elbic.com/vapi/synthesize?voice_id=YOUR_VOICE_ID",
      "secret": "YOUR_KUGELAUDIO_API_KEY",
      "timeoutSeconds": 30
    }
  }
}
```

- `voice_id`: the numeric voice ID from Step 1.
- `server.secret`: your KugelAudio API key. Vapi sends it as the `x-vapi-secret` header on every request, and KugelAudio authenticates it like any API key. This keeps the key out of the URL, which Vapi stores in the assistant config and may log.

Existing configurations that use the deprecated `api_key` query parameter can
move the key to `server.secret` and remove it from the URL.

No code, no extra server, no proxy.

<Tip>
  To select the model explicitly, add `&model_id=kugel-3` to the URL.
</Tip>

## How it works

Vapi sends one POST per phrase to `/vapi/synthesize`:

```json
{
  "message": {
    "type": "voice-request",
    "text": "Hello, how can I help you today?",
    "sampleRate": 24000
  }
}
```

KugelAudio streams back raw PCM16 at the requested sample rate, which is what Vapi expects. `message.sampleRate` must be one of `8000`, `16000`,
`22050`, `24000`, or `44100`; unsupported rates are rejected with `400`.

## Audio format

| Parameter   | Value                                             |
|-------------|---------------------------------------------------|
| Format      | Raw PCM (no WAV/container header)                 |
| Bit depth   | 16-bit signed, little-endian                      |
| Channels    | 1 (mono)                                          |
| Sample rate | Matches `message.sampleRate` from Vapi's request  |

## Troubleshooting

<AccordionGroup>
  <Accordion title="401: authentication failed">
    Check the key in `server.secret`. For an
    `eu-` key, point the URL at `https://api.eu.elbic.com/vapi/synthesize`
    and use the key without the `eu-` prefix: only the KugelAudio SDKs strip it
    for you.
  </Accordion>
  <Accordion title="400: unsupported sample rate">
    Vapi's `message.sampleRate` must be `8000`, `16000`, `22050`, `24000` or
    `44100`. Change the assistant's audio settings in Vapi.
  </Accordion>
  <Accordion title="The assistant speaks with the wrong voice">
    The voice comes from the `voice_id` query parameter in the server URL, not
    from Vapi's Voice ID field. Check the ID in [Voices](/features/voices).
  </Accordion>
</AccordionGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Voices" icon="microphone" href="/features/voices">
    Find and pick a voice ID
  </Card>
  <Card title="Voice prompting" icon="comment" href="/guides/voice-prompting">
    Prompt patterns that make an LLM sound good when spoken
  </Card>
  <Card title="Errors" icon="triangle-exclamation" href="/api-reference/errors">
    Status codes and error bodies
  </Card>
</CardGroup>
