ElevenAPI testing · 10 min guide

ElevenLabs TTS and STT with Python: A Two-Request Test and Its Limits

A reproducible Python TTS-to-STT workflow with ElevenLabs SDK, verified one-shot results, safer API keys and an explicit transcription caveat.

This hands-on ElevenAPI tutorial is based on a single bounded Toolnavira SDK experiment. Both API endpoints produced outputs, but an exact word check on the STT transcript failed. The full transcript was not retained, so its exact wording is unknown.

Experiment recorded 24 October 2026 · ElevenLabs Python SDK 2.74.1 · 2 total provider calls · no automatic retries

A bounded test, not a performance benchmark

Toolnavira ran one Text-to-Speech (TTS) call and then one Speech-to-Text (STT) call using the generated audio. Both endpoints returned outputs in a controlled test on 24 October 2026. This is direct evidence that this account, SDK version, voice and model combination executed these two API operations, not a guarantee for another account.

The script and measurements below are intentionally small. One run cannot establish uptime, throughput, speech quality across accents, inference latency percentiles, commercial rights or cost efficiency. We have not tested streaming, diarization, speaker separation, production deployment or real customer audio.

What the one-shot evidence actually shows

The Text-to-Speech request used Python SDK 2.74.1, the eleven_v4 model, the George voice and mp3_44100_128 output format. It produced a 95,755-byte MP3 in 2.797 seconds of local wall-clock elapsed time.

The generated MP3 was passed in memory to batch Speech-to-Text using scribe_v2 with English language selection. STT returned a text value of 86 characters; the local wall-clock elapsed time was 0.969 seconds.

The STT response contained the expected concepts “speech” and “personal information”, but an exact check for the string “Toolnavira” failed. The complete transcript was not retained. Its actual spelling and whether the provider wrote a separated or phonetic variant therefore remain UNKNOWN. We do not count this as an exact-transcription PASS.

The user had set a 300-credit ceiling on the restricted API key, but actual credits consumed were not read back from the provider. These two measured elapsed times are not server-side timing breakdowns, percentile measurements or a performance guarantee.

Observed results; one sample per endpoint, not a benchmark
MeasureRecorded resultBoundary
TTS model and voiceeleven_v4 · GeorgeSingle observed request
TTS audio output95,755 MP3 bytesLocal elapsed 2.797 s
STT modelscribe_v2Generated TTS audio reused in memory
STT transcript86 charactersLocal elapsed 0.969 s
Exact word “Toolnavira”NOT VERIFIED / check FAILEDSource transcript not retained
Provider credit usageUNKNOWN300-credit key limit is not a usage receipt

Before running a test yourself

Use an ElevenLabs key stored in a local secret manager or environment variable. Restrict it to Text to Speech and Speech to Text and set an account-enforced credit ceiling. Do not paste the key into a public repository, browser client bundle, tutorial screenshot or published page.

Choose a voice and model the account can use. The experiment used eleven_v4 and a published example voice, but model examples can change; the exact SDK and model named here are those verified in this single dated test.

A single execution of the example below will send two provider requests, which may use credits. It deliberately uses a synthetic sentence rather than any person’s recording. Do not send private customer audio without an appropriate data-processing and consent review.

A minimal Python SDK example

Create a virtual environment, install a pinned SDK version for a reproducible demo, and expose the secret only to the local process through ELEVENLABS_API_KEY. The code illustrates the same validated request parameters, with automatic SDK retries disabled on each endpoint.

Running this sample sends a live TTS request and then a live STT request. Treat any failure as a STOP and do not blindly run the whole script again: the first call may already have consumed credits. This excerpt is a learning example, not a production retry/orchestration harness.

The code below makes live billable API requests if you run it with your own key. On mobile, scroll sideways to inspect the full example.

import os
from io import BytesIO
from elevenlabs.client import ElevenLabs

# Sends up to one TTS and then one STT request when run once.
# This consumes API credits. Don't blindly rerun after an error.
client = ElevenLabs(
    api_key=os.environ["ELEVENLABS_API_KEY"],
    timeout=20,
    follow_redirects=False,
)

synthetic_text = (
    "Toolnavira checks a short speech demo. "
    "This sentence contains no personal information."
)

tts_stream = client.text_to_speech.convert(
    voice_id="JBFqnCBsd6RMkjVDRZzb",  # George (tested example)
    model_id="eleven_v4",
    text=synthetic_text,
    output_format="mp3_44100_128",
    request_options={"max_retries": 0, "timeout_in_seconds": 20},
)
mp3 = b"".join(tts_stream)
if len(mp3) < 128 or len(mp3) > 5_000_000:
    raise ValueError("Unexpected TTS audio size")

audio = BytesIO(mp3)
audio.name = "synthetic_tts.mp3"
stt = client.speech_to_text.convert(
    file=audio,
    model_id="scribe_v2",
    language_code="eng",
    tag_audio_events=False,
    diarize=False,
    request_options={"max_retries": 0, "timeout_in_seconds": 20},
)
transcript = getattr(stt, "text", "")
print("Generated MP3 bytes:", len(mp3))
print("Transcription characters:", len(transcript))
# Don't print private transcripts or API keys in shared logs.

Validate output without overclaiming accuracy

First verify that the TTS response is plausible audio data and record only non-sensitive metadata such as byte count, approved model ID, SDK version and a timestamp. Then confirm STT returns a string. Compare that string to the known synthetic source, including terms important to the use case.

A status-200 response and nonempty transcript do not prove an exact match. For this experiment the exact brand-name assertion did not pass, despite the other expected concepts being detected. No word error rate or provider accuracy percentage can be calculated from the sanitized retained evidence.

If you need a stronger demonstration, design a separate pre-approved study with reproducible ground-truth transcripts, explicit error criteria and multiple authorized samples. This guide does not fabricate such results.

Errors, cost boundaries and stop conditions

ElevenLabs distinguishes authentication failures (401), payment or insufficient-credit conditions (402), authorization errors (403) and throttling/concurrency errors (429). Inspect the structured error type and code, rather than guessing the cause from an HTTP number alone.

The first isolated Toolnavira attempt returned HTTP 401 from the STT endpoint, while the restricted key had STT disabled in its dashboard. After STT was enabled, a new separately authorized one-shot reached both endpoints successfully. That correlation does not conclusively establish why the original 401 occurred.

For a bounded demo, avoid automatic retries on unknown or time-out outcomes. Persist a run lock before sending; record independently whether TTS finished before attempting STT. Do not confuse a maximum credit quota with a verified expense receipt.

Practical acceptance checklist

For a real integration, the owner must verify supported key permissions, account-level credit limits, permitted media, SDK/model versions, deterministic fallbacks, error handling, output storage policies and an independently approved test budget. Revalidate after a model or SDK change.

A small two-call integration sample can validate request shape and authorization. It does not replace separate reliability, privacy, monitoring and quality evaluations for production systems.

Preflight checklist before your own calls

  • Keep the API key outside source code and logs; restrict endpoints and set a real provider credit cap
  • Pin an SDK release and date the model/voice IDs used in your own test
  • Use nonpersonal audio and explicitly budget provider calls
  • Disable automatic retries for one-shot experiments and stop after uncertain outcomes
  • Log sanitized TTS and STT stages separately without exposing content or secrets
  • Treat exact transcription mismatches as findings, not PASS
  • Measure actual credit use and repeated-sample performance separately before making claims

Source documentation and reproducibility boundary

The linked provider documentation describes the API surface. Toolnavira's observed values come from the dated local experiment, not from these general docs. Example model IDs and endpoint parameters may change; validate against your account before using them.

ElevenAPI quickstart

Speech to Text quickstart

ElevenLabs API error types

API key authentication and scopes

Next step: choose the right level of integration

For non-code narration, start with the voiceover workflow guide. For product limitations and fit, review the ElevenLabs profile or all practical guides. A static callback workflow may be safer than a speech agent if error handling cannot be independently validated.