Skip to main content
ElevenLabs is a voice AI platform providing text-to-speech and speech-to-text. Braintrust traces ElevenLabs SDK calls, including speech generation, streaming audio, timestamped audio, and transcription.

Setup

Install the Braintrust and @elevenlabs/elevenlabs-js packages, then set your API keys. Requires @elevenlabs/elevenlabs-js v2.67.0 or later.
1

Install packages

2

Set environment variables

.env

Auto-instrumentation

To trace ElevenLabs SDK calls without modifying your application code, initialize Braintrust normally, then run your app with Braintrust’s import hook to patch the ElevenLabs SDK at runtime.
1

Initialize Braintrust and call ElevenLabs

2

Run with the import hook

The auto-instrumentation example uses plain JavaScript so node --import can run the file directly. The Braintrust APIs work the same in TypeScript projects — compile your TypeScript to JavaScript, then run the compiled file with the import hook.
If you’re using a bundler, see Trace LLM calls for plugin and loader setup.

Manual instrumentation

To trace ElevenLabs clients manually, wrap them yourself with wrapElevenLabs(). Use this when you want to instrument specific clients individually rather than all of them globally.

What Braintrust traces

Braintrust patches the @elevenlabs/elevenlabs-js SDK and creates an LLM-typed span per call:
  • Text-to-speech spans (elevenlabs.textToSpeech.convert): input text, voice ID, and model as metadata. Generated audio is attached as a Braintrust attachment with content type audio/mpeg.
  • Streaming text-to-speech spans (elevenlabs.textToSpeech.stream): same as above, with time_to_first_token captured for the first audio chunk.
  • Timestamped text-to-speech spans (elevenlabs.textToSpeech.convertWithTimestamps, elevenlabs.textToSpeech.streamWithTimestamps): same fields as their non-timestamped counterparts, including word-level timing data.
  • Transcription spans (elevenlabs.speechToText.convert): audio input and model as metadata. Transcript text is captured as output.
  • Errors captured on every call.
Webhook transcription and Speech Engine sessions are not instrumented.

Resources