Cloud Text-to-Speech API: Quickstart & Integration

By Civispeech editorial team · Updated 2026-11-18

This documentation provides the technical specifications for the Civispeech cloud text-to-speech API, designed for government agencies and non-profit organizations requiring scalable speech synthesis. It covers integration methods, including direct HTTP requests and OpenAI SDK compatibility, ensuring seamless implementation into existing digital infrastructure without additional overhead.

The guide details authentication protocols, endpoint structures, and voice selection for the eight available presets. It also specifies rate limits, supported output formats, and billing mechanics for high-volume content generation, enabling technical teams to deploy reliable audio services with predictable costs and clear data handling procedures.

Cloud Text-to-Speech API: Quickstart & Integration

Frequently asked questions

How do I get an API key?

Navigate to /get-api-key/ and sign up using Google or an email and password combination. The dashboard displays your active API key, current balance, and usage statistics. You may issue a new key at any time, which immediately invalidates the previous one.

Can I use the OpenAI SDK with this API?

Yes. The API accepts the same request shape as the OpenAI speech endpoint. Configure your OpenAI SDK by changing the base_url to https://api.rpg89thai.com/v1 and providing your Civispeech API key. This allows direct integration using standard OpenAI client libraries.

What is the correct base URL?

The API base URL is https://api.rpg89thai.com/v1. Use this endpoint for all requests, including POST /v1/audio/speech for generation, GET /v1/voices for metadata, and GET /v1/models. Ensure your authorization header includes your Bearer token.

How do I specify a language?

Include the optional 'language' field in your request body with a valid ISO code. If omitted, the system guesses the language from the script, defaulting to English for Latin text. Explicitly setting the language ensures accuracy for non-English Latin-script content.

What happens if I exceed the rate limit?

The limit is 60 requests per minute per key. Exceeding this may cause requests to queue or fail. Failed requests incur no charge. Monitor your usage via the dashboard to manage high-volume generation effectively.

Are there limits on audio file size?

There is no explicit limit on the output audio file size. However, each request accepts up to 4096 characters of input text. For longer texts, split the input into parts, generate separate audio files, and join them to create the final output.

Can I use multiple voices in one request?

No. Each request accepts a single 'voice' parameter from the eight available presets. To use different voices, you must send separate requests for each segment and concatenate the resulting audio files. The API does not support multi-voice synthesis in a single call.

How do I handle audio streaming?

The API does not support streaming, WebSockets, or real-time partial audio. It returns the complete audio file upon request completion. Use standard HTTP POST to receive the file. For large texts, split the input and join the resulting files manually.

Is there a SDK for Python?

We do not provide an official proprietary SDK. However, you can use the official OpenAI Python SDK by configuring the base_url to https://api.rpg89thai.com/v1. This allows you to leverage standard Python libraries for integration with our text-to-speech API.

How do I revoke an API key?

Navigate to the /get-api-key/ dashboard page and issue a new API key. The new key becomes active immediately, and the previous key is invalidated at once. This effectively revokes access for any service using the old key without manual deletion steps.

What is the difference between tts-1 and tts-1-hd?

Both models use the same engine and price. 'tts-1' and 'tts-1-hd' are functionally identical for this API. Select either based on your preference; both cost $10 per 1 million characters and support all eight voice presets and available response formats.

Can I customize the speed of the audio?

Yes. Include the 'speed' field in your request body with a value between 0.25 and 4.0. This allows you to adjust the playback rate of the generated audio. The default speed is 1.0, but you can fine-tune it for specific use cases.

How do I detect errors in the response?

Check the HTTP status code and the response body for error details. Failed requests are free. Monitor your dashboard for usage logs and status indicators to track successful and failed synthesis attempts accurately.

Is the API documented for SOAP or GraphQL?

The API is documented for RESTful JSON requests, not SOAP or GraphQL. It uses standard HTTP methods with JSON bodies. Use the OpenAI SDK or plain HTTP to interact with the endpoints. No other protocols are supported.

First request

curl

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

The API utilizes standard Bearer token authentication. Include the header Authorization: Bearer <your_key> in every request. The key format begins with tts- followed by alphanumeric characters.

Bearer token format

Bearer token format

Transmit your unique API key in the HTTP Authorization header. The value must be prefixed with Bearer . For example: Authorization: Bearer tts-abc123def456. Ensure no extra spaces exist between the prefix and the token.

API key management

API key management

Each account holds one active key. You can generate a new key at any time via the dashboard. The new key becomes active immediately upon creation.

Key revocation

Issuing a new key instantly invalidates the previous one. The old key stops working immediately, ensuring secure access control without manual deactivation steps.

First Request

Sound wave illustration for: First Request

The API accepts text input and returns synthesized audio via a standard HTTP POST request. This method eliminates infrastructure overhead for government agencies and non-profits, ensuring predictable billing for high-volume content generation without maintaining complex speech synthesis servers.

Use the provided cURL example to verify connectivity. The request must include a valid Bearer token in the Authorization header. The engine processes the text and returns the audio file directly in the response body, ready for immediate playback or storage.

cURL example

Send your text to the speech endpoint using the following command. Replace YOUR_API_KEY with your active key from /get-api-key/. This example generates a short MP3 file using the default model.

```bash curl -X POST "https://api.rpg89thai.com/v1/audio/speech" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "This is a test phrase.", "voice": "aria", "response_format": "mp3"}' \ -o output.mp3 ```

JSON body structure

The request body is a JSON object containing the text and synthesis parameters. The input field accepts up to 4096 characters. Spaces and punctuation count toward this limit. The voice field selects one of eight presets, such as aria or atlas. You may optionally specify language using ISO codes or speed between 0.25 and 4.0.

```json { "model": "tts-1", "input": "Text content here", "voice": "sage", "response_format": "wav", "speed": 1.0 } ```

Response handling

On success, the API returns the audio file directly in the response body with the specified response_format. The HTTP status code is 200. Failed requests incur no charge. Store the returned file immediately, as the response is not persistent. For texts exceeding 4096 characters, split the input and join the resulting audio files.

OpenAI SDK

Sound wave illustration for: OpenAI SDK

Configure the OpenAI SDK by overriding the base URL to point to our API endpoint. This allows agencies to use standard client libraries by changing the base_url, as our endpoint uses the same request shape as the official OpenAI speech endpoint. Simply update the base_url to https://api.rpg89thai.com/v1 and provide your Bearer token in the standard authorization header.

The SDK compatibility ensures seamless integration with existing codebases, reducing development overhead for government and NGO technical teams. Standard parameters such as model, input, voice, and response_format are supported directly. This approach eliminates the need for custom HTTP wrappers while maintaining predictable billing and rate limit adherence.

Base URL configuration

Set the API base URL to https://api.rpg89thai.com/v1 in your SDK initialization. This redirects all standard speech synthesis requests to our infrastructure. Ensure your authentication header uses the format Authorization: Bearer tts-... with your active key.

SDK compatibility

Our endpoint accepts the same JSON body structure as the OpenAI speech endpoint. You can utilize official OpenAI SDKs for Python, Node.js, or other languages without custom adaptation. This ensures consistent parameter handling for model, voice, and speed settings.

Error handling

The API returns standard HTTP status codes to indicate success or failure. If a request fails, no charge is applied to your account. Implement retry logic for transient network issues, keeping in mind the rate limit of 60 requests per minute for established accounts.

Voices Endpoint

Sound wave illustration for: Voices Endpoint

The /v1/voices endpoint returns available audio presets, supported languages, and output formats. This metadata allows government agencies to programmatically select appropriate voices for public service announcements or non-profit communications without manual lookup.

GET /v1/voices

Send a GET request to https://api.rpg89thai.com/v1/voices with your Bearer token to receive a JSON object listing all available voices, their associated languages, and supported response formats.

Voice presets list

Eight presets are available, including female voices like aria (warm, clear narrator) and luna (soft, storytelling), and male voices such as atlas (neutral, news) and orion (deep, documentary). Voices are based on licensed recordings: LibriTTS-R (CC BY 4.0), from LibriVox public-domain audiobook readings.

  • Female: aria, nova, luna, sage
  • Male: felix, milo, atlas, orion

Language codes

The API supports 23 languages, including English, Spanish, French, German, Japanese, and Chinese. While the system guesses language from script, explicitly setting the language parameter ensures accuracy for non-English Latin-script texts.

Models Endpoint

Sound wave illustration for: Models Endpoint

The /v1/models endpoint returns the available synthesis engines. Both tts-1 and tts-1-hd utilize the same underlying engine and incur identical pricing.

GET /v1/models

Send a GET request to https://api.rpg89thai.com/v1/models to retrieve the list of available model identifiers. This endpoint confirms the two supported models: tts-1 and tts-1-hd.

tts-1 vs tts-1-hd

The distinction between tts-1 and tts-1-hd is the model identifier; they use the same engine and price. There is no difference in engine performance, voice selection, or cost. Both models charge $0.01 per 1,000 characters.

Engine details

The engine processes requests sequentially. Longer texts are split into 4096-character segments and joined. Generation speed is approximately real-time, with short phrases taking a few seconds. Requests may queue under load.

Models Endpoint

Output Formats

Sound wave illustration for: Output Formats

The API accepts input text up to 4,096 characters per request and returns audio in the specified format. This ensures predictable file sizes for government archival systems and efficient bandwidth usage for field deployments.

MP3 support

MP3 is the default and most widely supported format for web players and legacy government audio systems. It provides a balanced compression ratio suitable for general announcement playback and internal distribution.

WAV, OPUS, FLAC, PCM

WAV and FLAC provide lossless quality for high-fidelity archival needs. PCM offers raw uncompressed data for immediate processing. OPUS delivers efficient compression for bandwidth-constrained environments.

  • WAV: Lossless, uncompressed standard.
  • FLAC: Lossless, compressed storage.
  • PCM: Raw binary audio data.
  • OPUS: Efficient compression.

Format selection

Specify the desired format using the response_format field in the JSON body. Accepted values are mp3, wav, opus, flac, and pcm. The API returns the audio file directly in the response body.

Rate Limits

Sound wave illustration for: Rate Limits

Rate limits are enforced per API key to ensure stable service during high-volume generation. The standard limit is 60 requests per minute, which supports consistent throughput for bulk audio production workflows.

60 requests per minute

Once your account is funded, you may submit up to 60 synthesis requests within a 60-second window.

10 requests before top-up

New accounts or those with an exhausted balance are limited to 10 requests per minute. This restriction applies immediately upon key activation until a top-up is processed via TRON (TRC-20).

Queue behavior

Requests exceeding the per-minute limit are processed sequentially. Under load, a request may wait in a queue before synthesis begins. This ensures fair usage but may increase total latency for large batches.

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate request outcomes. A 200 OK response confirms successful audio generation, while 4xx errors indicate client-side issues such as invalid keys or malformed JSON bodies. Failed requests incur no charge.

Common error codes

Authentication errors (401) occur when the Bearer token is missing or invalid. Request validation errors (400) return details if the input text is empty or the voice ID is unknown. Rate limit exceeded errors (429) indicate that the 60 requests-per-minute threshold has been reached.

Retry logic

Implement exponential backoff for transient 5xx errors and 429 rate limit responses. Since requests are processed sequentially under load, brief pauses between retries prevent queue congestion. Failed synthesis requests incur no charge, so retrying on non-fatal errors is safe.

Character limit errors

Each request supports a maximum of 4096 characters. Exceeding this limit returns a 400 error. Split long texts into chunks and join the resulting audio files programmatically to ensure consistent playback without truncation.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. While short phrases may take a few seconds, long texts generate at roughly real-time speed.

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. LibriTTS-R corpus (OpenSLR 141)
  3. TRON developer hub: TRC-20
  4. Python documentation
  5. IETF RFC 7845: Ogg Opus
  6. openai-node on GitHub
  7. OpenAI API reference: create speech
  8. MDN: Web Speech API
  9. openai-python on GitHub
  10. FFmpeg documentation
  11. LibriVox public-domain audiobooks
  12. Creative Commons Attribution 4.0

More on this site