# ElevenLabs

Gateway base address

`https://monsite.com/provider/elevenlabs/api/v1`

Replace `https://monsite.com` with the actual origin of your site. Prefix `/provider/eleventlabs/api/v1` also accepts the same operations.

## Authentication

Add `Authorization: Bearer <clé-de-la-passerelle>` to each request. Configure the ElevenLabs account key in Administration. The gateway adds that key to its own outgoing requests.

## Operations available

| Method | Relative path | Answer |
| --- | --- | --- |
| GET | `/` | List of bridge operations |
| GET | `/voices` | Voice accessible to the provider account |
| GET | `/models` | Available models |
| POST | `/text-to-speech/{voice_id}` | Audio |
| POST | `/text-to-speech/{voice_id}/stream` | Audio stream |
| POST | `/text-to-speech/{voice_id}/with-timestamps` | JSON with audio and timing |
| POST | `/text-to-speech/{voice_id}/stream/with-timestamps` | JSON stream with audio and timing |
| WSS | `/text-to-speech/{voice_id}/stream-input` | WebSocket audio stream |
| WSS | `/text-to-speech/{voice_id}/multi-stream-input` | Multi-context WebSocket stream |
| POST | `/single-use-token/tts_websocket` | Single-use WebSocket token |

For `/voices`, look for a voice with `search`, `page_size` and `next_page_token`. Use fields `voice_id` and `model_id` of the answers to choose a voice and a model. Synthesis queries await an object JSON with `text`. They accept the options of the provider's synthesis, including `model_id` and the parameter of the URL `output_format`.

```bash
curl --fail-with-body "$GATEWAY/provider/elevenlabs/api/v1/voices" \
  -H "Authorization: Bearer $GATEWAY_API_KEY"

curl --fail-with-body "$GATEWAY/provider/elevenlabs/api/v1/text-to-speech/$VOICE_ID?output_format=mp3_44100_128" \
  -H "Authorization: Bearer $GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Bonjour et bienvenue.","model_id":"eleven_multilingual_v2"}' \
  --output voix.mp3
```

## Text to speech with the ElevenLabs SDKs

For speech synthesis, use `https://campaign52.com` as the SDK base URL and set `api_key` to your Campaign52 key. The gateway receives it in `xi-api-key` and uses the ElevenLabs key configured in your workspace. The official paths start with `/v1/text-to-speech/`. The Campaign52 character limit applies to the original `/provider/elevenlabs/api/v1` prefix. On the native paths, ElevenLabs applies the model and account limits.

The gateway relays URL and body options, audio and JSON responses, and ElevenLabs errors. With `enable_logging=false`, Campaign52 skips audio archiving and keeps call metadata in its journal.

For browser WebSockets, request a token on your server with `POST /v1/single-use-token/tts_websocket`, then send its `token` value as `single_use_token` in the WebSocket URL. You can also supply your Campaign52 key in `xi-api-key`, in the `authorization` query parameter, or in the first message’s `xi_api_key` field.

## Results and consumption

- `401` indicates an absent, invalid or revoked key. `403` indicates that the account is no longer active.
- `404` indicates an operation not available. `503` indicates that the bridge is waiting for installation or that the provider is disabled. `501` is reserved for DeepL.
- The log distinguishes the characters from field `text` and the cost provided by ElevenLabs in header `character-cost`. A dash indicates a value not available.
- The call details include the HTTP preset and request ID ElevenLabs if it is present. The duration covers the time up to the initial response. In [Token](/token), you can download your archived audio files from the details of each call.

See also [reference ElevenLabs](https://elevenlabs.io/docs/api-reference/introduction/) and [guide AI Connect](/provider/ai).
