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

# ElevenLabs speech adapters

> Connect Scribe recognition, stream-input synthesis, or an authenticated Speech Engine session.

The recognition and synthesis adapters use WebSockets and can be selected independently. Both import from `@agentium/core/voice`.

```bash theme={null}
npm install @agentium/core@4.0.0 ws
export ELEVENLABS_API_KEY="your-key"
```

## Recognize and synthesize

```typescript theme={null}
import { ElevenLabsRecognizer, ElevenLabsSynthesizer } from "@agentium/core/voice";

export function createSpeech(voiceId: string) {
  return {
    recognizer: new ElevenLabsRecognizer(),
    synthesizer: new ElevenLabsSynthesizer({ voiceId, model: "eleven_flash_v2_5" }),
  };
}
```

| Adapter | V4 contract |
| - | - |
| `ElevenLabsRecognizer` | `scribe_v2_realtime`, manual commit, partial and final transcripts; PCM16 mono at 8, 16, 22.05, 24, 44.1, or 48 kHz |
| `ElevenLabsSynthesizer` | Stream-input endpoint; `eleven_flash_v2_5` (default), `eleven_turbo_v2_5`, or `eleven_multilingual_v2`; PCM16 mono at 16, 22.05, 24, or 44.1 kHz |

Supply a voice ID your account may use. The stream-input adapter rejects v3/v4 model families because they require a different dialogue API. A newer model's existence does not make it compatible with this endpoint.

For direct use, open a session with `SpeechOpenConfig` and an abort signal, consume its events/frames concurrently, send input, then flush and close. A synthesizer's `flush()` finishes that generation. To interrupt, abort/close it and start a new generation; do not append to a flushed session.

See [streaming voice](/voice/streaming) for composing these with `AgentVoiceBrain` and a media transport.

## Speech Engine

Use `createElevenLabsSpeechEngineHandler` when ElevenLabs owns the audio session and you supply the text reasoning component.

```typescript theme={null}
import {
  createElevenLabsSpeechEngineHandler,
  type VoiceBrain,
} from "@agentium/core/voice";

export function createEngineCallback(brain: VoiceBrain) {
  return createElevenLabsSpeechEngineHandler(brain);
}
```

Pass the resulting callback to the official SDK's **authenticated** `engine.attach(...)` integration in your host. Agentium does not create the engine server or verify that connection. Keep SDK authentication enabled.

The callback accepts the engine transcript as authoritative history, avoids identical duplicate transcript requests for a session, and streams public text deltas. Do not append the same transcript again into another automatic memory store. The engine/Agent and any host SDK clients retain their own lifecycle.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.