Skip to content
Tavio
All articles
  • text to speech
  • TTS API
  • AI voice
  • voiceover
  • Tavio

AI Text to Speech API: Turn Text into Natural Speech

5 min read

Text-to-speech (TTS) turns plain text into audio with a natural, human-sounding voice. What once needed a studio and a voice actor now takes a single HTTP request. This guide walks you through generating speech with the Tavio AI text to speech API — from your first curl call to saving an mp3 and understanding exactly what you pay for.

What is an AI text to speech API

An AI text to speech API is a programmatic way to get an audio file from a text string: you send text and a voice name, and the service returns ready-to-play speech. Tavio is one unified API and web dashboard for generating images, video, speech (TTS), and text (chat/LLM) with a single key across every modality.

The key detail: the Tavio API is OpenAI-compatible. That means the /audio/speech path, the request shape, and existing OpenAI SDKs all work unchanged — you just swap the base URL to https://api.tavio.tech/v1 and drop in your Tavio key.

With Tavio you can generate speech, images, video, and LLM completions through the same key, and every request runs on edge infrastructure for low latency worldwide.

Where AI voiceovers are used

TTS has moved well beyond screen readers. Here are the main scenarios where a text to speech API saves time and money:

  • Video and clip voiceovers. Narration for YouTube, courses, and ads without booking a studio.
  • IVR and phone menus. Auto-attendants and voice bots where lines are generated on the fly per caller.
  • Accessibility. Reading articles, interfaces, and documents aloud for visually impaired users.
  • Audiobooks and podcasts. Turning a script into an audio track with steady pacing and intonation.
  • Notifications and assistants. Voice messages inside apps, smart devices, and chatbots.

How to call the speech endpoint

The speech endpoint in Tavio is POST https://api.tavio.tech/v1/audio/speech. In the request body you set three main fields: model (which model speaks), input (the text to narrate), and voice (which voice to use). The response is a binary audio stream you can write straight to a file.

Here is a minimal copy-paste curl example that saves the result to speech.mp3:

curl https://api.tavio.tech/v1/audio/speech \
  -H "Authorization: Bearer $TAVIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "elevenlabs-tts",
    "input": "Hello! This is the Tavio text to speech API.",
    "voice": "alloy"
  }' \
  --output speech.mp3

After it runs, a speech.mp3 file appears in your current folder, ready to play. Export TAVIO_API_KEY once into your environment so you never hard-code the key in scripts.

Python example with the OpenAI SDK

Because the API is OpenAI-compatible, you don’t need a separate client — the official openai package works. Just point base_url at Tavio and pass your key. The example below generates speech and writes it to disk:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.tavio.tech/v1",
    api_key="TAVIO_API_KEY",
)

response = client.audio.speech.create(
    model="openai-tts",
    voice="nova",
    input="Tavio turns text into natural speech in a single request.",
)

response.stream_to_file("output.mp3")
print("Done: output.mp3")

The same pattern plugs into any tool that already uses the OpenAI SDK — from automation scripts to a production backend. Only the base_url and key change.

Choosing a voice and model: elevenlabs-tts vs openai-tts

Tavio offers two speech models, and the right one depends on your use case:

  • elevenlabs-tts — focused on maximally natural, expressive delivery. A strong pick for audiobooks, podcasts, and ads where a lively, human voice matters.
  • openai-tts — balanced, clean output that fits UI notifications, IVR, and system prompts where predictability and speed win.

The voice itself is set via the voice field (for example, alloy or nova). Practical tip: render the same short snippet with both models and a few voices — in a couple of minutes you’ll pick the right timbre for your project instead of guessing from a description.

Another platform benefit is automatic failover between providers: if one model or provider is temporarily down, the request routes to a backup, so your generation doesn’t fail.

What TTS costs: credits per second

Tavio runs on a subscription: your plan grants a daily credit quota that refreshes every day, with any unused credits burning at midnight UTC. Paid plans start at $10/mo, with Enterprise on request. Speech draws credits per second of generated audio — from your daily quota, for exactly the duration of the voiceover you get, not per character or per request.

Exact per-model prices in credits (including the per-second rate for elevenlabs-tts and openai-tts) live on the pricing page: tavio.tech/en/pricing. The trial credits you get on sign-up are handy for testing: narrate a couple of sentences and judge the quality before committing to a paid plan.

FAQ

Do I need a dedicated SDK for speech in Tavio?

No. The Tavio API is OpenAI-compatible, so the official OpenAI SDKs and any tools built on them work. Just set the base URL to https://api.tavio.tech/v1 and use your Tavio key — your existing code runs without a rewrite.

What audio format does the endpoint return?

The /audio/speech endpoint returns a binary audio stream that you write to a file (mp3 in the examples above). In curl you do this with the --output flag; in the Python SDK, with the stream_to_file method.

elevenlabs-tts or openai-tts — which should I pick?

For the most lifelike, expressive delivery (audiobooks, ads), use elevenlabs-tts. For clean, predictable system lines (IVR, notifications), use openai-tts. The best approach is to test both on the same snippet of text.

How are credits charged for speech?

Per second of generated audio, drawn in credits from your plan’s daily quota. Check the current per-second rate for each model, in credits, on tavio.tech/en/pricing.

Try it now

To start generating speech, sign up through the Telegram bot https://t.me/taviotech_bot — it creates your account and issues an API key in seconds. Full details on the speech endpoint and every other modality are in the docs at https://api.tavio.tech/docs. One key, a subscription with a daily quota, natural speech from text in a single request.