API Documentation for Text-to-Speech Integration

By LocaleVoice Editorial Team · Updated 2026-11-18

This documentation outlines the technical integration steps for LocaleVoice’s text-to-speech API, tailored for localization and dubbing agencies managing multilingual projects. It covers the essential components for sending text requests and receiving audio files, including authentication, parameter configuration, and response handling. The guide assumes familiarity with standard RESTful APIs and provides concrete examples for immediate implementation.

Readers will find specific details on the POST endpoint structure, voice selection across 23 languages, and rate limit behaviors. The documentation confirms compatibility with the official OpenAI SDK by adjusting the base URL, ensuring a familiar development experience. All technical specifications, including character limits, supported formats, and error codes, are presented to support high-volume audio generation workflows.

API Documentation for Text-to-Speech Integration

Frequently asked questions

How do I set the base URL for the OpenAI SDK?

Configure the OpenAI SDK by setting the base_url parameter to https://api.ppvpbet.com/v1. This allows you to use the official OpenAI client libraries directly, ensuring compatibility with the standard request shape and authentication methods required for our text-to-speech endpoint.

What is the correct authorization header format?

Include the header Authorization: Bearer tts-... where the value is your unique API key. Each account holds one active key; issuing a new key immediately invalidates the previous one, so ensure you update your configuration promptly after rotation.

Can I stream audio as it generates?

No. The API does not support streaming, WebSocket connections, or real-time partial audio delivery. You must send a POST request to the speech endpoint and wait for the complete audio file response.

How do I handle rate limit errors?

The limit is 60 requests per minute per key (10 per minute before the first top-up). Implement exponential backoff in your integration logic to handle 429 errors gracefully. Requests are processed sequentially, so queueing may occur under load.

What happens if the input text exceeds 4096 characters?

The API rejects requests with text longer than 4096 characters. You must split your input into smaller parts, generate audio for each segment, and then join the resulting audio files to create the final continuous output for your project.

Does the API support SSML tags?

No. The API does not support SSML, phoneme dictionaries, or custom pronunciation lexicons. You cannot control pauses, emphasis, or pronunciation details via markup. Input is plain text, and the engine handles natural phrasing based on the specified voice and language.

How do I specify the language for Arabic text?

Set the language parameter to the ISO code for Arabic. Although the API guesses language from the script, explicitly setting the language ensures accurate synthesis for non-English Latin-script text or when precise localization control is required for your Arabic content.

Is the response format always MP3?

No. You can specify the response_format field in the request body to receive audio in mp3, wav, opus, flac, or pcm formats. This flexibility allows you to choose the codec that best fits your localization pipeline and storage requirements.

Can I change the voice after the request is sent?

No. The voice is determined by the voice parameter in the initial request body. Once the synthesis process begins, the audio generation uses that specific voice preset. To use a different voice, you must send a new request.

How do I detect a failed request in the response?

A: Failed requests are free. You can detect failures by checking the HTTP status code of the response. Successful requests return the audio file directly, while errors indicate issues like rate limits or invalid parameters.

What is the default speed setting?

The default speed is 1.0. You can adjust the speed parameter between 0.25 and 4.0 to modify the playback rate of the generated audio. This allows you to match the pacing required for specific localization contexts or dubbing styles.

Do I need to install a specific library?

No. You can use the official OpenAI SDKs by changing the base_url, or use plain HTTP requests. There is no proprietary SDK required. Any standard HTTP client capable of sending JSON POST requests and handling binary audio responses will work.

Is the API endpoint stable?

A: The endpoint POST https://api.ppvpbet.com/v1/audio/speech is the standard interface for synthesis. The infrastructure is designed for reliable, high-volume processing consistent with the described character-per-second generation speeds.

How do I generate a new API key?

Generate a new key from your account dashboard on /get-api-key/. Issuing a new key immediately invalidates the previous one. Ensure your systems are updated to use the new key to avoid service interruption, as the old key stops at once.

First request

curl

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

Authentication

Sound wave illustration for: Authentication

LocaleVoice authenticates API requests using a Bearer token passed in the Authorization header. This key, issued upon account creation, is the sole credential required to access the text-to-speech endpoint for your localization projects.

Bearer Token Structure

Bearer Token Structure

The token must be formatted as Authorization: Bearer tts-<your_key>. Ensure no extra whitespace is included. This string validates your account and tracks usage against your current balance.

Key Issuance and Revocation

Key Issuance and Revocation

A new key can be issued at any time via the dashboard. When a new key is generated, the previous one becomes invalid immediately, ensuring strict control over access points.

Single Active Key Policy

Each account maintains one active key at any given time. Use the /get-api-key/ page to view or regenerate your current credential for your integration scripts.

  • One active key per account
  • Instant revocation of old keys
  • View key at /get-api-key/

Endpoint Configuration

Sound wave illustration for: Endpoint Configuration

Configure your client by setting the base URL to https://api.ppvpbet.com/v1. This endpoint handles all text-to-speech synthesis requests for your localization pipeline.

Base URL Setup

Point your HTTP client to https://api.ppvpbet.com/v1. This base URL ensures compatibility with standard OpenAI SDK structures, requiring only a base URL override in your configuration.

POST Request Method

All synthesis operations use the POST method directed at /v1/audio/speech. The API expects a JSON payload containing the model, input text, and voice selection parameters.

JSON Body Requirements

The request body must include the model (tts-1 or tts-1-hd), input (string up to 4096 characters), and voice presets. Optional fields include response_format, speed, and language.

  • Model: tts-1 or tts-1-hd
  • Input: Max 4096 characters
  • Voice: One of 8 presets
  • Format: mp3, wav, opus, flac, pcm

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts text input up to 4096 characters per request. Spaces and punctuation are counted as characters. For longer texts, split the input into 4096-character chunks and join the resulting audio files. Short phrases may take a few seconds to generate, while longer texts process at roughly real-time speed (25 characters per second).

Requests are processed sequentially. Under high load, synthesis may queue, extending total delivery time. Failed requests incur no charge, ensuring cost efficiency for bulk localization workflows.

Input Text Limits

The input field supports a maximum of 4096 characters per request. Characters include all spaces and punctuation marks. To process longer content, split the text into valid chunks and concatenate the resulting audio files.

Generation speed averages approximately 25 characters of text per second of audio. Short phrases may require a few seconds to complete. Processing is sequential; under load, requests may enter a queue before synthesis begins.

  • Maximum 4096 characters per request
  • Spaces and punctuation count toward the limit
  • Sequential processing may cause queuing delays

Voice Selection Options

Select from 8 presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Any voice can speak any of the 23 supported languages. If the language parameter is omitted, the system guesses the language from the script, defaulting to English for Latin text. Set language explicitly for non-English Latin-script content.

Voices are based on licensed recordings from LibriTTS-R (CC BY 4.0) and LibriVox public-domain audiobooks. Every generated file contains an inaudible watermark marking it as synthetic speech.

  • aria, nova, luna, sage (female)
  • felix, milo, atlas, orion (male)
  • All voices support 23 languages
  • Explicit language code recommended for non-English Latin text

Speed Adjustment Range

The speed parameter accepts values between 0.25 and 4.0. Adjusting speed alters the playback rate without changing the pitch. This allows fine-tuning audio for synchronization with video dubbing projects.

The default speed is 1.0. Values below 1.0 slow the speech, while values above 1.0 accelerate it. Ensure the adjusted speed remains within the supported range to avoid errors.

  • Range: 0.25 to 4.0
  • Default speed: 1.0
  • Alters playback rate, not pitch

Response Formats

Sound wave illustration for: Response Formats

The API returns the generated audio file directly in the response body. Supported formats include mp3, wav, opus, flac, and pcm, allowing seamless integration into existing localization pipelines.

Audio File Delivery

Audio data is returned as a binary file corresponding to the requested response_format. The file contains synthetic speech with an inaudible watermark marking it as generated. No additional metadata is stored with the file; it is delivered immediately upon successful synthesis.

  • Formats: mp3, wav, opus, flac, pcm

Error Response Codes

Failed requests incur no charge. Standard HTTP error codes indicate issues such as invalid input or rate limits. The response body includes a JSON object with an error code and message for programmatic handling.

  • 400: Bad Request (invalid parameters)

Status Code Handling

Use standard HTTP status codes to determine success or failure. A 200 OK response contains the audio bytes. Non-200 responses contain error details in JSON format, enabling automated retry logic based on the specific error type returned.

SDK Integration

Sound wave illustration for: SDK Integration

LocaleVoice uses the same request structure as the OpenAI speech endpoint, allowing localization agencies to integrate our TTS API using the official OpenAI SDKs. This compatibility allows teams to leverage existing infrastructure and familiarity with standard HTTP clients.

OpenAI SDK Compatibility

The API accepts identical JSON bodies and returns audio in the same format. This ensures that existing codebases targeting OpenAI can be adapted with minimal refactoring, reducing integration time for high-volume multilingual projects.

Base URL Override

To direct requests to LocaleVoice, modify the SDK configuration to use https://api.ppvpbet.com/v1 as the base URL. This single configuration change routes all synthesis requests through our infrastructure while maintaining standard SDK behavior.

Standard Method Usage

Use the standard audio.speech.create method with the provided API key. The SDK handles the POST request, JSON serialization, and audio response parsing automatically, consistent with standard OpenAI client implementations.

SDK Integration

Curl Example

Sound wave illustration for: Curl Example

The API accepts standard JSON payloads for text synthesis. This section demonstrates the minimal command structure required to generate audio from Arabic or other supported languages using cURL.

Configure your bearer token and select a voice preset. The response delivers the binary audio file directly to your terminal or file system.

Basic Request Structure

Send a POST request to the speech endpoint with the text input and desired voice. Ensure the input does not exceed 4096 characters.

  • - Endpoint: /v1/audio/speech
  • - Method: POST
  • - Body: JSON with model, input, voice

Header Configuration

Include the Authorization header with your Bearer token. This authenticates the request against your account's active key.

  • - Authorization: Bearer tts-...
  • - Content-Type: application/json

Audio Output Handling

The response contains the raw audio bytes. Redirect output to a file using standard shell operators.

  • - Save to .mp3 or .wav
  • - Handle binary data correctly

Rate Limits

Sound wave illustration for: Rate Limits

The API enforces a strict limit of 60 requests per minute per active key. New accounts start with a reduced limit of 10 requests per minute until the first top-up is processed. This constraint applies uniformly across all endpoints and ensures stable infrastructure for high-volume localization workflows.

Exceeding the limit results in a 429 Too Many Requests error. No billing charges occur if synthesis fails, preserving your credit balance during traffic spikes or batch processing delays.

Requests Per Minute

Each API key is capped at 60 requests per minute. This limit is consistent regardless of the voice model or audio format selected. The counter resets every 60 seconds, allowing for predictable throughput in automated dubbing pipelines.

  • Standard limit: 60 requests/minute/key
  • New account limit: 10 requests/minute until first top-up
  • Limit applies per key, not per account

Queue Processing Behavior

Requests are processed sequentially rather than in parallel. Under normal load, generation speed matches real-time audio duration (approx. 25 characters per second). During high traffic, requests may wait in a queue before processing begins, potentially increasing total latency for large batches.

  • Sequential processing order
  • Real-time generation speed for long texts
  • Queuing occurs during high load periods

Throttle Management

Implement exponential backoff in your integration to handle 429 errors gracefully. Monitor your usage dashboard to anticipate peak times. Distribute large batch jobs across multiple minutes to avoid hitting the per-minute cap, ensuring consistent delivery for client deliverables.

  • Use exponential backoff for retries
  • Monitor usage via dashboard
  • Distribute large batches over time

Voices Endpoint

Sound wave illustration for: Voices Endpoint

The /v1/voices endpoint provides a structured list of the eight available voice presets, including gender, tone description, and supported formats. This allows localization agencies to programmatically verify voice availability before initiating synthesis jobs, ensuring consistent audio styling across multilingual projects.

Listing Available Voices

Retrieve the full catalog of voices with metadata. The eight presets range from warm narrators to deep documentary styles, all capable of speaking any of the 23 supported languages regardless of their original recording source.

  • Aria, Nova, Luna, Sage (Female)
  • Felix, Milo, Atlas, Orion (Male)

Language Support Details

Support covers Arabic, Chinese, English, German, Japanese, Korean, Spanish, and 16 others. If the language parameter is omitted, the system guesses from the script, defaulting to English for Latin text. Explicitly set the language code for non-English Latin scripts to ensure accuracy.

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

Format Options

Voices can output audio in MP3, WAV, OPUS, FLAC, or PCM formats. Select the format that best fits your delivery pipeline, balancing file size and quality requirements for bulk localization projects.

  • MP3, WAV, OPUS, FLAC, PCM

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. We transform global narratives into localized audio experiences that truly resonate with international audiences.

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. Tether (USDT)
  3. curl documentation
  4. LibriTTS-R corpus (OpenSLR 141)
  5. Node.js documentation
  6. Python documentation
  7. TRON developer hub: TRC-20
  8. MDN: Web Speech API
  9. Creative Commons Attribution 4.0
  10. IETF RFC 7845: Ogg Opus
  11. ISO 639 language codes
  12. openai-python on GitHub

More on this site