Python Integration Guide for Podcast Text-to-Speech

By Podcast TTS Lab editorial team · Updated 2026-11-19

This guide walks you through integrating the Podcast TTS Lab API into your Python workflow. It is designed for podcast creators who need to convert scripts into narration efficiently. You will learn how to authenticate, structure requests, and handle audio generation using standard tools.

We cover installing the OpenAI SDK, configuring the base URL, and passing your API key. You will also see how to manage rate limits, split long texts, and choose audio formats. By the end, you will have a working script that generates synthetic voices for your episodes.

Python Integration Guide for Podcast Text-to-Speech

Frequently asked questions

Do I need the official OpenAI SDK?

No. You can use any HTTP library. Our endpoint matches the OpenAI speech format, so the official OpenAI SDK works by changing the base URL to https://api.wtc88.cc/v1. Alternatively, you can send a standard POST request with a JSON body and handle the response manually using your preferred Python HTTP client.

How do I change the base URL in Python?

Set the base URL to https://api.wtc88.cc/v1. If using the OpenAI Python SDK, configure the base_url parameter to this address. Ensure you use your specific API key for authentication. This allows you to use standard OpenAI SDK methods without modifying the request structure.

Can I use async requests in Python?

Yes. Since the API is a standard HTTP endpoint, you can use any async library like aiohttp or httpx. The API processes requests sequentially, so under load, your async requests may queue. Ensure you handle rate limits appropriately to avoid 429 errors during high-concurrency usage.

What is the maximum input length?

The maximum input length is 4096 characters per request. If your script exceeds this, split the text into chunks of up to 4096 characters. Generate audio for each chunk separately and join the resulting audio files to create the final narration file for your podcast episode.

How do I handle 429 errors?

A 429 error indicates you have exceeded the rate limit of 60 requests per minute. Implement exponential backoff in your Python code to retry after a short delay. Note that new accounts start with a lower limit of 10 requests per minute until the first top-up is processed.

Is the API key case-sensitive?

Yes, API keys are case-sensitive strings starting with tts-. Ensure you copy the key exactly from your dashboard at /get-api-key/. Incorrect casing will result in authentication failures. The key remains valid until you issue a new one, which invalidates the previous key immediately.

Can I use the same key on multiple machines?

Yes. You can use the same API key across multiple machines or environments. There is no limit on concurrent connections or devices. However, all requests from that key count toward the same rate limit of 60 requests per minute and the same character-based billing balance.

How do I rotate my API key?

Navigate to the /get-api-key/ page in your account dashboard. Issue a new key from there. The old key stops working immediately, while the new one becomes active. Update your Python scripts to use the new key. You can rotate keys as often as needed without extra cost.

Does the API support JSON web tokens?

No. The API uses standard Bearer token authentication via the Authorization: Bearer tts-... header. It does not support JSON Web Tokens (JWT). Use the API key provided in your dashboard directly in the authorization header for all requests to the https://api.wtc88.cc/v1 endpoint.

Can I send binary data in the request?

No. The request body must be JSON containing string fields like input, model, and voice. Binary data is not sent in the request. The API returns the audio file as binary data in the response body.

How do I debug a failed request?

Check the HTTP status code and response body. Failed requests are free, so no charge is applied. Ensure your text is under 4096 characters and your key is valid. If the request fails, the API returns an error message. Verify your internet connection and retry if it was a transient network issue.

Is there a webhook for completion?

A: No. The API does not support webhooks. You must wait for the synchronous response. The API returns the audio file directly in the response. For long texts, you must split the input and join the results manually in your Python script after receiving each response.

Can I batch multiple requests?

A: No. Each request generates one audio file for up to 4096 characters. You must send separate requests for each chunk of text. Process them sequentially or concurrently using async methods. Join the resulting audio files in your Python code to create the final podcast narration file.

How do I get the audio file in Python?

The API returns the audio file in the response body. Use a library like requests or httpx to send the POST request. Access the content via response.content or response.read(). Save this binary data to a file with the appropriate extension, such as .mp3 or .wav, based on your chosen response_format.

First request

curl

curl https://api.wtc88.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.wtc88.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.wtc88.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

Get Your API Key

Sound wave illustration for: Get Your API Key

Start by visiting https://wtc88.cc/get-api-key/ to create an account using Google or email. After signing in, your dashboard displays your active API key, current balance, and a ready-to-use cURL example for immediate testing.

Keep your key secure. You can generate a new key at any time from the dashboard; the previous key stops working immediately upon creation, ensuring clean access management for your podcast production workflow.

Sign up on the site

Sign up on the site

Visit the registration page and choose Google or email authentication. Google sign-ups include a $0.50 free trial valid for 7 days, providing approximately 50,000 characters for testing your podcast narration scripts.

Generate key from dashboard

Generate key from dashboard

Once logged in, access your dashboard to view your unique API key starting with 'tts-'. This key authenticates all requests to the API base URL https://api.wtc88.cc/v1.

Rotate keys if needed

If you suspect a key has been exposed, generate a replacement directly from the dashboard. The old key is revoked instantly, preventing further use while your new key becomes active immediately.

First Request with Curl

Sound wave illustration for: First Request with Curl

Test the endpoint immediately with a simple command. This verifies your key and network connectivity before writing code. The API returns the audio file directly in the response body.

Use this method to confirm that voice selection and format options work as expected. You can save the output to a file for local playback.

POST /v1/audio/speech

Send a POST request to the endpoint. Include your bearer token in the Authorization header. The request body must be valid JSON containing the text and voice parameters.

  • Endpoint: POST https://api.wtc88.cc/v1/audio/speech
  • Header: Authorization: Bearer tts-<your-key>

JSON body structure

The body requires the input text and voice preset. You can optionally specify model, response_format, and speed. Text must be under 4096 characters per request.

Ensure the text is UTF-8 encoded. If the language is not English, set the language field to avoid incorrect voice selection.

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

Example command line

Run this command in your terminal. Replace tts-... with your actual key. The output is saved as podcast_intro.mp3.

Verify the file plays correctly. Check the character count in your dashboard to confirm the charge.

  • curl -X POST https://api.wtc88.cc/v1/audio/speech \ -H "Authorization: Bearer tts-..." \ -H "Content-Type: application/json" \ -d '{"input": "Welcome to our podcast.", "voice": "nova", "model": "tts-1", "response_format": "mp3"}' \ -o podcast_intro.mp3

Python SDK Integration

Sound wave illustration for: Python SDK Integration

Integrate the API into your Python podcast workflow by leveraging the existing OpenAI SDK. This approach allows you to use familiar code structures while directing requests to our endpoint.

The integration requires minimal configuration changes. You simply update the base URL and authenticate with your specific key, enabling seamless generation of narration files.

Install openai package

Install the official OpenAI Python library using pip. This package provides the necessary classes to handle HTTP requests and JSON parsing for the TTS endpoint.

pip install openai

  • - Use the latest stable version of the openai package

Set base_url

Configure the SDK to point to our API infrastructure. Set the base_url to https://api.wtc88.cc/v1 so all requests route correctly.

from openai import OpenAI\nclient = OpenAI(base_url="https://api.wtc88.cc/v1")

  • - Replace the default OpenAI URL with our domain

Pass API key

Authenticate requests by passing your unique API key. Include it in the client initialization to ensure proper authorization for each synthesis request.

client = OpenAI(api_key="tts-your-key-here", base_url="https://api.wtc88.cc/v1")

  • - Store keys securely in environment variables

Request Parameters

Sound wave illustration for: Request Parameters

Configure the synthesis engine and voice parameters to match your podcast production needs. The API accepts a model, voice preset, and output format within a single JSON body.

Model: tts-1 or tts-1-hd

Select "tts-1" for standard quality or "tts-1-hd" for higher fidelity. Both models use the same engine and pricing structure, charged at $0.01 per 1,000 characters.

Voice presets

Choose from eight licensed voices: aria, nova, luna, and sage (female); felix, milo, atlas, and orion (male). Each voice has a specific character, from warm storytelling to energetic promos.

  • 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

Response format options

Specify the audio format using the response_format field. Available options are mp3, wav, opus, flac, and pcm. MP3 is recommended for web playback, while WAV suits editing workflows.

  • mp3: web playback
  • wav: editing
  • opus: efficient compression
  • flac: lossless quality
  • pcm: raw audio

Handling Long Texts

Sound wave illustration for: Handling Long Texts

The API accepts a maximum of 4096 characters per request. For scripts exceeding this limit, your Python code must split the input text into manageable chunks before sending them to the endpoint.

Split into 4096 char chunks

Divide your narration text into segments of up to 4096 characters. Ensure you do not break words in the middle of a sentence to maintain audio continuity. Spaces and punctuation count toward this limit.

Join audio files

Once each chunk is processed, the API returns an audio file. Your application should concatenate these files in the original order to reconstruct the full narration track.

Manage timing

Generation speed is roughly real-time, averaging about 25 characters of text per second. Short phrases may take a few seconds, while longer texts process proportionally. Requests are queued sequentially under load, so plan your loop timing accordingly.

Handling Long Texts

Rate Limits

Sound wave illustration for: Rate Limits

Your API key allows up to 60 requests per minute. This limit applies to all synthesis calls combined, regardless of text length. Plan your batch sizes accordingly to avoid temporary throttling during high-volume production runs.

New accounts start with a lower limit of 10 requests per minute. This constraint lifts automatically after your first top-up. Monitor your usage dashboard to track your current quota and avoid interruptions in your podcast workflow.

60 requests per minute

Each API key allows up to 60 requests per minute. This limit applies to all synthesis calls combined, regardless of text length. Plan your batch sizes accordingly to avoid temporary throttling during high-volume production runs.

10 per minute initially

New accounts start with a lower limit of 10 requests per minute. This constraint lifts automatically after your first top-up. Monitor your usage dashboard to track your current quota and avoid interruptions in your podcast workflow.

Exponential backoff

If you exceed the limit, the API returns a 429 error. Implement exponential backoff in your Python script to retry requests after increasing delays. This ensures smooth processing without overwhelming the queue during peak usage.

  • Retry with increasing delays (e.g., 1s, 2s, 4s)
  • Handle 429 status codes gracefully
  • Monitor dashboard for real-time limits

Error Codes

Sound wave illustration for: Error Codes

API responses include standard HTTP status codes to indicate success or failure. Understanding these codes helps you handle errors gracefully in your podcast automation workflows.

401 Unauthorized

This error occurs when the API key is missing, invalid, or revoked. Ensure your Authorization: Bearer header contains the correct key from your dashboard.

429 Rate Limit

You exceed the limit of 60 requests per minute. New accounts start with 10 requests per minute. Implement exponential backoff to retry after the limit resets.

  • Check the Retry-After header if provided.
  • Split large texts into smaller chunks to reduce request volume.

500 Server Error

The server encountered an unexpected condition. Failed synthesis requests are free, so no charge is applied. Retry the request after a short delay.

Audio Formats

Sound wave illustration for: Audio Formats

Choose the format that matches your production pipeline. MP3 offers small file sizes and universal compatibility for direct web playback, while WAV preserves uncompressed quality for post-production editing.

MP3 for web

MP3 is the standard for web delivery. It keeps file sizes low, which speeds up loading times for listeners. Use this format when distributing audio directly to websites or apps.

  • Small file size
  • Universal player support
  • Ideal for streaming

WAV for editing

WAV provides uncompressed audio, preserving every detail of the synthesis. This is the preferred choice for podcast editors who need to mix, fade, or apply effects in software like Audacity or Adobe Audition.

  • Lossless quality
  • Best for editing
  • Larger file size

OPUS and FLAC options

OPUS offers high efficiency with smaller files than MP3 at similar quality. FLAC provides lossless compression, reducing size without quality loss. Use these if your workflow requires specific compression standards.

  • OPUS: efficient compression
  • FLAC: lossless compression
  • Alternative storage needs

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. For longer episodes, split the script into parts and concatenate the generated audio files.

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. W3C WAI: making audio and video accessible
  4. LibriTTS-R paper (arXiv 2305.18802)
  5. FFmpeg documentation
  6. LibriVox public-domain audiobooks
  7. Tether (USDT)
  8. IETF RFC 7845: Ogg Opus
  9. MDN: Web Speech API
  10. openai-node on GitHub
  11. curl documentation
  12. ISO 639 language codes

More on this site