Text-to-Speech API Documentation for Python Developers

By AudioGen editorial team · Updated 2026-11-19

This guide helps freelance podcast creators generate high-quality narration using Python. You will learn how to send scripts to our API and receive audio files, focusing on practical workflows that let you concentrate on your show’s voice rather than complex SDK integration.

We provide clear examples using both the standard requests library and the OpenAI Python package. You can start immediately with a free trial, manage your API key, and handle errors confidently. This documentation covers everything from setting up your first request to understanding rate limits and supported formats.

Text-to-Speech API Documentation for Python Developers

Frequently asked questions

What is the API endpoint URL?

The endpoint is POST https://api.apatu.cc/v1/audio/speech. You send a JSON body containing the text, model, voice, and other parameters. This follows the standard OpenAI speech endpoint structure, ensuring compatibility with existing tools and libraries that expect this specific request shape for text-to-speech synthesis.

How do I get an API key?

Sign up on our /get-api-key/ page using Google or an email and password. Accounts are per site. Once registered, your dashboard displays your active API key, current balance, and usage statistics. You can issue a new key at any time, which immediately invalidates the old one.

Can I use the OpenAI SDK?

Yes, the official OpenAI SDKs work perfectly. You just need to change the base_url to https://api.apatu.cc/v1 and use your AudioGen API key. This allows you to leverage familiar SDK methods while accessing our specific voices, formats, and pricing structure without writing custom HTTP logic.

What formats are supported?

You can request audio in mp3, wav, opus, flac, or pcm formats. Specify your preference using the response_format field in your request body. These options cover most podcast production workflows, from web-friendly compressed files to high-quality lossless formats suitable for professional editing.

How do I set the voice?

Include the voice field in your JSON body with one of eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Each voice has a distinct tone, from warm narrators to energetic promo styles. You can test different voices to find the fit for your podcast content.

What is the rate limit?

The limit is 60 requests per minute per key. Before your first top-up, this drops to 10 requests per minute. Requests are processed sequentially, so under load, you might experience slight delays. Plan your batch generation accordingly to stay within these limits and avoid temporary throttling.

How do I handle errors?

If synthesis fails, the charge is returned in full. Monitor your response status codes and handle exceptions in your Python code. Failed requests do not consume your character credit, ensuring you only pay for successfully generated audio. Check the API documentation for specific error codes and meanings.

Can I use Python requests?

Yes, you can use the standard Python requests library. Simply send a POST request to the endpoint with the correct JSON payload and authorization header. This approach gives you full control over the request lifecycle and is ideal if you prefer lightweight HTTP clients over heavier SDKs.

Is there an SDK for Python?

We do not have an official dedicated SDK. However, the OpenAI Python SDK works seamlessly by adjusting the base URL. This is the recommended way to integrate AudioGen into your Python applications, providing a familiar interface while accessing our specific TTS capabilities and voice presets.

How do I specify language?

Set the language field with an ISO code like en, es, or fr. If omitted, the system guesses the language from the script, defaulting to English for Latin text. For non-English Latin-script text, explicitly setting the language ensures accurate pronunciation and avoids misinterpretation by the synthesis engine.

Can I change speed in requests?

Yes, adjust the speed parameter between 0.25 and 4.0. This allows you to speed up narration for quick updates or slow it down for clarity. The speed change applies to the entire request, affecting the pacing of the generated audio file without altering the voice characteristics.

What happens if I exceed limits?

If you exceed the rate limit, requests may be delayed or rejected. Since requests are processed sequentially, high volume can cause queuing. Monitor your usage via the dashboard to stay within the 60 requests per minute limit. Failed requests do not incur charges.

Do I need to install extra packages?

If using the OpenAI SDK, install the openai package. For raw requests, use the standard requests library. No other specific packages are required. These are common Python libraries, so you likely already have them or can install them easily via pip without complex dependencies or version conflicts.

How do I authenticate requests?

Include the header Authorization: Bearer tts-<your-key> in your requests. Replace <your-key> with your actual API key found on the dashboard. This standard Bearer token format ensures secure access to the API. Ensure your key is kept secret and rotated if compromised, as only one key is active at a time.

First request

curl

curl https://api.apatu.cc/v1/audio/speech \
  -H "Authorization: Bearer $TTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"tts-1","voice":"aria","input":"Hello from the API.","response_format":"mp3"}' \
  --output hello.mp3

Python (openai)

from openai import OpenAI

client = OpenAI(base_url="https://api.apatu.cc/v1", api_key="tts-...")

with client.audio.speech.with_streaming_response.create(
    model="tts-1", voice="nova", input="Hello from Python.", response_format="mp3"
) as response:
    response.stream_to_file("hello.mp3")

Node.js (openai)

import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({ baseURL: "https://api.apatu.cc/v1", apiKey: process.env.TTS_API_KEY });
const res = await client.audio.speech.create({ model: "tts-1", voice: "milo", input: "Hello from Node.js." });
fs.writeFileSync("hello.mp3", Buffer.from(await res.arrayBuffer()));
voice
ariafemale
novafemale
lunafemale
sagefemale
felixmale
milomale
atlasmale
orionmale
language
arالعربية
zh中文
daDansk
nlNederlands
enEnglish
fiSuomi
frFrançais
deDeutsch
elΕλληνικά
heעברית
hiहिन्दी
itItaliano
ja日本語
ko한국어
msBahasa Melayu
noNorsk
plPolski
ptPortuguês
ruРусский
esEspañol
swKiswahili
svSvenska
trTürkçe

Getting Your API Key

Sound wave illustration for: Getting Your API Key

To start generating narration for your podcasts, visit the /get-api-key/ page on apatu.cc. You can create an account using your Google sign-in or a standard email and password. This step establishes your unique identity within our system.

Sign up on the website

Sign up on the website

Accounts are specific to this site. If you use Google sign-in, you receive a free trial credit of $0.50, valid for seven days. Email-based accounts start without trial credit but work identically for paid usage.

Find key in dashboard

Find key in dashboard

Once registered, your dashboard displays your active API key, current balance, and character usage. You can use this key immediately with tools like cURL or Python libraries. The key format begins with 'tts-'.

Issue new key if needed

You have one active key per account. If you suspect the key has been compromised, you can issue a new one at any time. The old key stops working instantly, ensuring your podcast production remains secure.

First Request with cURL

Sound wave illustration for: First Request with cURL

Start by sending a POST request to https://api.apatu.cc/v1/audio/speech. This endpoint accepts a JSON body containing the text and voice configuration, returning an audio file in the response body.

You need a valid Bearer token in the Authorization header. Replace YOUR_API_KEY with your key from the dashboard to authenticate your request.

Basic JSON body structure

The request body is a standard JSON object. It includes the model name, the text to convert, and the voice preset. The response returns the audio data in the format you specified.

  • model: "tts-1" or "tts-1-hd"
  • input: your text (max 4096 chars)
  • voice: one of the 8 presets
  • response_format: mp3, wav, opus, flac, or pcm

Required fields: model, input, voice

You must specify the model, input, and voice. The input field holds your script text, which is limited to 4096 characters per request. Longer texts should be split and joined.

  • model: Choose "tts-1" or "tts-1-hd"
  • input: The text to synthesize
  • voice: e.g., "nova" or "atlas"

Optional fields: speed, language

Adjust the speed between 0.25 and 4.0 to control playback rate. Set the language ISO code if the text is in Latin script but not English, as the API defaults to English for Latin text.

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

Leverage the familiar OpenAI Python package to integrate AudioGen’s TTS API with minimal configuration changes. This approach allows podcast creators to use standard SDK methods without learning a new library or wrestling with complex custom implementations.

Set base_url to our endpoint

Initialize the OpenAI client by pointing it to our API base URL: https://api.apatu.cc/v1. This redirects all standard speech requests to our infrastructure while maintaining the familiar method signatures you already know.

Use standard speech endpoint

Call the audio.speech.create() method exactly as you would for OpenAI. Pass your desired model (tts-1 or tts-1-hd), input text, voice preset, and optional parameters like speed or language directly into the function call.

Pass your API key

Provide your unique API key during client initialization. Ensure the key starts with tts- and is retrieved from your dashboard at /get-api-key/. The SDK handles authentication headers automatically, keeping your podcast production workflow clean.

Supported Audio Formats

Sound wave illustration for: Supported Audio Formats

The API accepts MP3, WAV, OPUS, FLAC, or PCM via the response_format field. Choose MP3 for efficient web delivery or WAV for uncompressed studio quality. Each format balances file size and fidelity to suit your podcast workflow.

MP3 for web playback

MP3 is a common choice for web delivery. It provides good audio quality at low bitrates, making it ideal for embedding directly into your podcast player or sharing via links. Use this format when bandwidth efficiency matters.

WAV for high quality

WAV offers uncompressed audio, preserving every detail of the synthesized voice. This format is best for editors who need lossless audio for post-production. Be aware that WAV files are significantly larger than MP3s, so ensure your storage scales accordingly.

OPUS, FLAC, PCM options

OPUS provides efficient compression. FLAC delivers lossless compression, reducing file size without quality loss. PCM returns raw, uncompressed audio data, useful for specialized processing pipelines that handle encoding themselves.

  • MP3: Best for web players
  • WAV: Lossless studio quality
  • OPUS: Efficient modern streaming
  • FLAC: Lossless compression
  • PCM: Raw audio data

Voice and Language Parameters

Sound wave illustration for: Voice and Language Parameters

Choose from eight distinct voice presets tailored for podcast narration, from warm narrators to energetic promo styles. Each voice is built on licensed recordings and supports all 23 available languages without restriction.

Select any voice regardless of its origin; for example, use 'aria' for a clear, calm documentary style or 'felix' for upbeat promotional segments. The API handles the audio synthesis efficiently, letting you focus on your script’s tone rather than technical constraints.

8 preset voices available

Our library includes eight distinct voices designed for diverse podcast needs. Female voices like aria (warm narrator) and nova (bright) offer clarity, while male options like atlas (neutral news) and orion (deep documentary) provide professional depth.

Each voice is derived from licensed recordings, ensuring high-quality synthetic speech. You can mix and match voices across episodes to maintain listener interest without worrying about licensing complexities or custom cloning limitations.

  • aria: warm, clear narrator
  • nova: bright, upbeat
  • luna: soft, storytelling
  • sage: calm, instructional
  • felix: energetic, promo
  • milo: friendly, conversational
  • atlas: neutral, news
  • orion: deep, documentary

23 languages supported

The API supports 23 languages, including English, Spanish, German, French, Japanese, and Hindi. Any voice can speak any of these languages, allowing you to produce multilingual content with a single key.

Unsupported languages include Vietnamese, Indonesian, Thai, Ukrainian, Romanian, Czech, Bengali and all others not in the list. For non-English Latin-script text, always set the language parameter explicitly to avoid incorrect dialect guesses.

  • Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, Turkish

Automatic language detection

If you omit the language field, the system guesses the language based on the script’s script characters. Latin script defaults to English, so ensure you specify the language for non-English content.

Explicitly setting the language code reduces errors and ensures consistent pronunciation, especially when mixing languages or using less common scripts.

Voice and Language Parameters

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

AudioGen enforces a rate limit of 60 requests per minute per API key. This limit applies to all synthesis calls, ensuring fair usage across the network. If you exceed this threshold, you will receive a 429 error until the window resets.

60 requests per minute

The standard limit allows 60 requests per minute per key. This is sufficient for most podcast workflows, where you typically generate full episodes in batches rather than real-time streams.

10 requests before first top-up

New accounts start with a lower limit of 10 requests per minute. This applies until you make your first top-up. Once you add funds via USDT (TRC-20), the limit increases to the standard 60 requests per minute.

  • Start with 10 req/min
  • Top up to unlock 60 req/min
  • Limits reset every 60 seconds

Queued processing under load

Requests are processed sequentially. Under heavy load, your request may wait in a queue before synthesis begins. Long texts might take slightly longer to generate than short phrases due to this sequential processing.

Handling Errors

Sound wave illustration for: Handling Errors

Errors return standard HTTP codes with JSON details. Failed synthesis is free, so you are not charged for retries or timeouts. Handle 429s by waiting or splitting requests to stay within the 60 requests/minute limit.

429 for rate limits

Exceeding 60 requests per minute triggers a 429. New accounts start with a 10 requests/minute limit until the first top-up. Queue delays may also occur under load.

  • Implement exponential backoff for retries.
  • Split long texts into <4096 character chunks.
  • Monitor the Retry-After header if provided.

401 for invalid keys

A 401 error means the Bearer token is missing, expired, or incorrect. Generate a fresh key from your dashboard if the current one fails; the old key stops immediately.

422 for bad requests

This indicates invalid parameters, such as a missing voice or text exceeding 4096 characters. Check the JSON body structure and ensure the model is 'tts-1' or 'tts-1-hd'.

Python Code Examples

Sound wave illustration for: Python Code Examples

Generate narration for your podcast scripts with minimal boilerplate. Whether you prefer raw HTTP calls or the familiar OpenAI SDK, our API integrates directly into your Python workflow, letting you focus on content creation rather than connection management.

Using requests library

Send a POST request to https://api.apatu.cc/v1/audio/speech with your JSON payload. Include the Authorization: Bearer header with your key. The library handles the connection while you manage the audio data.

  • Install via pip install requests
  • Set base_url to our endpoint

Using openai python package

Initialize the client with base_url="https://api.apatu.cc/v1" and your API key. Use client.audio.speech.create() just like the standard OpenAI interface. This allows you to swap endpoints without changing your code logic.

Handling audio response

The API returns binary audio data. Save the response content directly to a file with your chosen format (mp3, wav, opus, flac, or pcm). For long texts, split inputs into 4096-character chunks and concatenate the resulting files.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Listen for pacing, clarity, and whether the voice matches your show’s vibe before committing to full episode narration.

Avatar of the voice aria
ariafemale
Avatar of the voice nova
novafemale
Avatar of the voice luna
lunafemale
Avatar of the voice sage
sagefemale
Avatar of the voice felix
felixmale
Avatar of the voice milo
milomale
Avatar of the voice atlas
atlasmale
Avatar of the voice orion
orionmale

23 languages

Any voice speaks any of these languages.

Sources and further reading

  1. Wikipedia
  2. openai-python on GitHub
  3. LibriTTS-R paper (arXiv 2305.18802)
  4. OpenAI API reference: create speech
  5. Python documentation
  6. LibriVox public-domain audiobooks
  7. IETF RFC 7845: Ogg Opus
  8. openai-node on GitHub
  9. ISO 639 language codes
  10. TRON developer hub: TRC-20
  11. Tether (USDT)
  12. LibriTTS-R corpus (OpenSLR 141)

More on this site