API Documentation for Text-to-Speech Integration

By Compliance Audio editorial team · Updated 2026-11-18

This documentation explains how to integrate Compliance Audio’s text-to-speech API into your startup’s workflow. You’ll find clear examples for generating audio files from legal texts, configuring the OpenAI-compatible SDK, and managing your API key. Everything is built for reliable, character-based billing without enterprise complexity.

Designed for teams generating legal documents, this guide covers voice selection, audio formats, and rate limits. You’ll learn how to handle long texts, interpret error codes, and rotate keys securely. No fluff—just the technical details you need to start sending requests and receiving audio files immediately.

API Documentation for Text-to-Speech Integration

Frequently asked questions

How do I get my API key?

Sign up on the /get-api-key/ page using Google or an email and password combination. Once registered, your account dashboard displays your single active API key along with your balance and usage statistics. You can generate a new key at any time, which immediately invalidates the previous one.

Can I use the OpenAI Python SDK with this API?

Yes, the official OpenAI SDKs work perfectly. You simply need to change the base_url to https://api.playk138.com/v1 and use your Compliance Audio key. This allows you to use the same request shape as the OpenAI speech endpoint without needing a custom client library.

What is the base URL I need to configure?

Configure your SDK or HTTP client to use https://api.playk138.com/v1 as the base URL. All requests are sent via POST to the /audio/speech endpoint. This URL structure ensures compatibility with standard OpenAI SDK configurations, making integration straightforward for existing developers.

Does the API support streaming audio?

No, the API does not support streaming, WebSockets, or real-time partial audio delivery. You send a text payload and receive the complete audio file in the response. This synchronous approach simplifies integration for legal document generation workflows where immediate streaming is not required.

How do I handle texts longer than 4096 characters?

Split your input text into chunks of up to 4096 characters each. Send each chunk as a separate request to the API. Once you receive all the audio files, join them together to create the final continuous audio file. This ensures compatibility with the single-request character limit.

What happens if the API is rate-limited?

You are limited to 60 requests per minute per key (10 per minute before your first top-up). Requests are processed sequentially, so under load, your request may wait in a queue. If synthesis fails, the charge is returned in full.

Can I rotate my API key?

Yes, you can issue a new API key at any time through your account dashboard. When you generate a new key, the old one stops working immediately. This ensures that your previous key cannot be used for future requests, maintaining security for your account.

Is there a webhook for long audio generation?

No, there is no webhook support for long audio generation or status updates. The API is synchronous: you send a request and wait for the audio file in the response. For long texts, you must split them manually and process each part sequentially.

How do I specify the language explicitly?

Include the language field in your JSON body with the ISO code for the desired language. This is recommended for non-English Latin-script text to ensure accurate synthesis. Supported languages include Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, and Turkish.

What is the default language if not specified?

If the language field is omitted, the system guesses the language from the script. Text in Latin script defaults to English. For other Latin-script languages, you should explicitly set the language parameter to avoid incorrect synthesis or misinterpretation of the input text.

Do I need to pay for each format change?

No, changing the response_format (mp3, wav, opus, flac, pcm) does not incur additional costs. You pay based on the character count of the input text, regardless of the output format. Each request costs $0.01 per 1,000 characters, with failed requests being free.

Are the audio files returned in the response?

Yes, the generated audio file is returned directly in the API response. The audio is not stored on our servers after delivery. Input text is used only to produce the audio and is not used for training.

How do I authenticate with Bearer token?

Include your API key in the Authorization header as Bearer tts-.... You receive one active key per account. Ensure you use the correct key from your dashboard, as using an expired or revoked key will result in authentication errors for your requests.

Can I use multiple API keys?

No, each account has only one active API key at a time. If you generate a new key, the previous one is immediately invalidated. You can rotate keys for security purposes, but you cannot use multiple keys simultaneously with a single account.

First request

curl

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

Compliance Audio uses a single active API key for authentication. You receive this key when you sign up via /get-api-key/. It is prefixed with "tts-" and acts as your sole credential for all requests.

API Key Format

API Key Format

Your key follows the format tts-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Keep it secure and pass it with every request. Only one key is active per account.

Bearer Token

Bearer Token

Include the key in the Authorization header using the Bearer scheme: Authorization: Bearer tts-your-key-here. This standard header ensures your requests are authenticated by our API gateway.

Key Rotation

If you suspect your key is compromised, issue a new one from your dashboard. The old key stops working immediately, so update your applications to avoid interruptions.

Quickstart: First Request

Sound wave illustration for: Quickstart: First Request

Send a POST request to https://api.playk138.com/v1/audio/speech with your Bearer token to generate audio. This endpoint accepts text up to 4096 characters and returns an audio file directly, making it easy to integrate into your document workflow.

Curl Example

Use this command to generate speech immediately. Replace YOUR_API_KEY with your credential from the dashboard.

  • curl -X POST https://api.playk138.com/v1/audio/speech \
  • -H "Authorization: Bearer YOUR_API_KEY" \
  • -H "Content-Type: application/json" \
  • -d '{"model": "tts-1", "input": "Please review the attached contract terms.", "voice": "sage", "response_format": "mp3"}'

JSON Body Structure

The request body is a simple JSON object. The model accepts tts-1 or tts-1-hd. The voice field selects one of eight presets, such as sage for calm, instructional narration ideal for legal contexts.

  • input: The text string (max 4096 chars)
  • voice: e.g., aria, nova, luna, sage, felix, milo, atlas, orion
  • response_format: mp3, wav, opus, flac, or pcm
  • speed: Optional float between 0.25 and 4.0

Response Format

A successful response returns the audio file directly in the body with the specified response_format. Failed requests return a JSON error object and incur no charge, ensuring you only pay for delivered audio.

OpenAI SDK Compatibility

Sound wave illustration for: OpenAI SDK Compatibility

Our API mirrors the OpenAI speech endpoint structure, allowing you to swap in your existing OpenAI SDK clients with minimal code changes. This compatibility simplifies integration for teams already familiar with standard TTS workflows.

By pointing your client to our base URL, you can use familiar methods like client.audio.speech.create without rewriting your request logic. This ensures a smooth transition from other enterprise tools.

Base URL Configuration

Set your SDK’s base URL to https://api.playk138.com/v1 instead of the default OpenAI endpoint. This directs all speech requests to our infrastructure while maintaining standard request shapes.

You can keep using the official OpenAI SDKs, adjusting only the base URL and your API key for authentication.

  • Base URL: https://api.playk138.com/v1
  • Auth Header: Authorization: Bearer tts-...

SDK Usage

Initialize your client with your unique API key. Pass your text input and desired voice directly into the speech creation method. The SDK handles the JSON serialization and HTTP POST automatically.

For languages other than English, explicitly pass the language parameter (e.g., "de" for German) to ensure correct pronunciation, as the API guesses from script by default.

Model Parameters

Use model set to either "tts-1" or "tts-1-hd". Both models use the same engine and pricing, so you can switch freely based on your quality needs without changing code structure.

Other parameters like voice, response_format, and speed (0.25–4.0) map directly to the standard fields. No custom SSML or phoneme tags are required for basic integration.

  • Models: tts-1, tts-1-hd
  • Speed: 0.25–4.0
  • Format: mp3, wav, opus, flac, pcm

Supported Audio Formats

Sound wave illustration for: Supported Audio Formats

Choose the right format for your legal audio delivery. MP3 offers high compression for smaller file sizes, while WAV provides uncompressed quality for archival needs. Select based on your bandwidth and storage constraints.

MP3 Compression

MP3 is ideal for web playback and mobile apps where bandwidth matters. It reduces file size significantly while maintaining clear speech intelligibility for legal documents.

  • Best for web delivery
  • Small file sizes
  • Universal player support

WAV Lossless

WAV delivers uncompressed audio, preserving every detail of the synthesis. Use this for high-fidelity archival or when downstream processing requires lossless input.

  • Uncompressed quality
  • Archival standard
  • No data loss

Opus and FLAC

Opus and FLAC are supported formats for specific use cases. Both are supported for specific use cases beyond standard MP3 or WAV.

  • Opus: efficient streaming
  • FLAC: lossless compression
  • Flexible storage options

Voice Selection Guide

Sound wave illustration for: Voice Selection Guide

Choosing the right voice ensures your legal documents sound professional and clear. Our eight presets cover narrators, instructional guides, and conversational tones, all optimized for readability.

Each voice is built from licensed recordings, providing a consistent, neutral baseline that works well for reading contracts, terms of service, or compliance updates without distracting listeners.

Voice Presets List

Select from eight distinct voices. Female options include Aria (warm narrator), Nova (bright), Luna (soft storyteller), and Sage (calm instructor). Male options offer Felix (energetic), Milo (friendly), Atlas (neutral news), and Orion (deep documentary).

All voices support the full range of our 23 languages, allowing you to maintain a consistent tone across different jurisdictions or languages.

  • 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

Gender and Tone

Match the voice to the document's gravity. Use Atlas or Sage for straightforward legal terms, where clarity is paramount. Orion works well for longer, detailed compliance reports.

Avoid high-energy voices like Felix for serious contracts, as their upbeat tone might clash with the formal nature of the text.

Language Matching

Set the language parameter explicitly for non-English Latin text. While the system guesses from the script, explicit codes prevent errors in languages like Greek or Hebrew.

All 23 supported languages work with any voice, ensuring consistent audio quality regardless of the language used in your legal documents.

Voice Selection Guide

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

Understanding request limits is essential for maintaining smooth audio generation workflows, especially when processing bulk legal documents. Our API enforces strict quotas to ensure consistent performance for all users without requiring complex tiered plans or sudden rate drops during peak usage hours.

Knowing your limits helps you plan integration strategies effectively. Whether you are generating a single clause or a full contract, the system handles the load predictably, allowing your startup to scale audio production without worrying about unexpected throttling or service interruptions.

60 Requests Per Minute

Each API key is limited to 60 requests per minute. This limit applies to all requests per key. If you exceed this threshold, the API returns a 429 Too Many Requests error, indicating that you should pause and retry shortly.

  • Limit is per key, not per IP or account.

Pre-Topup Limit

New accounts or those without a recent top-up start with a reduced limit of 10 requests per minute. This ensures fair usage while balances are being processed. Once your USDT transfer is confirmed, your limit increases to the full 60 requests per minute immediately.

Queue Behavior

Requests are processed sequentially. Under heavy load, your request may wait in a queue before synthesis begins. Short phrases typically take a few seconds, while longer texts take longer depending on the total character count.

Handling Long Texts

Sound wave illustration for: Handling Long Texts

Our API limits each request to 4,096 characters, which is ideal for individual legal clauses but insufficient for entire contracts. To handle longer documents, you must split the text into chunks of this maximum size before sending them to the endpoint.

Once you receive the audio files for each chunk, you need to join them in the correct order to reconstruct the full document.

4096 Character Split

Count characters carefully, including spaces and punctuation, as they all count toward the limit. Split your legal text at logical boundaries, such as paragraph breaks or clause endings, to maintain semantic coherence.

Audio Joining

Concatenate the returned audio files sequentially. Since the API returns discrete files, you are responsible for assembling them into a single coherent file using your preferred audio library or tool.

Chunk Processing

Requests are processed sequentially, so longer texts may take time as chunks queue up. Generate chunks in order to avoid mixing audio segments, ensuring the final document matches the original text structure.

Error Codes and Handling

Sound wave illustration for: Error Codes and Handling

Our API returns standard HTTP status codes to help you handle integration issues efficiently. Understanding these responses ensures your legal audio generation pipeline remains stable without unnecessary downtime or repeated failed requests.

Errors are clearly categorized so you can adjust your implementation logic quickly, whether dealing with temporary network hiccups or permanent configuration mistakes.

Rate Limit Errors

If you exceed the limit of 60 requests per minute, you will receive a 429 Too Many Requests response. During the initial period before your first top-up, the limit is stricter at 10 requests per minute. Simply wait and retry; queued requests are processed in order.

We recommend implementing exponential backoff in your client logic to handle these bursts gracefully without overwhelming the server.

  • Status Code: 429
  • Cause: Exceeded 60 req/min (or 10 req/min pre-top-up)
  • Action: Wait and retry with backoff

Invalid Model

The API only accepts "tts-1" and "tts-1-hd" as valid model identifiers. Sending any other string results in a 400 Bad Request error. Ensure your code strictly uses these two values to avoid unnecessary processing delays.

  • Status Code: 400
  • Valid Models: "tts-1", "tts-1-hd"
  • Action: Check model parameter value

Authentication Failures

A 401 Unauthorized error indicates an invalid or missing API key. Ensure your Authorization header is formatted correctly as "Bearer tts-...". If you rotated your key, the old one becomes invalid immediately.

Double-check that you are using the active key from your account dashboard to avoid service interruptions.

  • Status Code: 401
  • Cause: Invalid or missing Bearer token
  • Action: Verify API key and header format

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Teams must carefully monitor character counts to avoid unexpected costs.

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. IETF RFC 7845: Ogg Opus
  3. LibriTTS-R corpus (OpenSLR 141)
  4. FFmpeg documentation
  5. Creative Commons Attribution 4.0
  6. TRON developer hub: TRC-20
  7. Tether (USDT)
  8. W3C WAI: making audio and video accessible
  9. curl documentation
  10. OpenAI API reference: create speech
  11. LibriTTS-R paper (arXiv 2305.18802)
  12. Node.js documentation

More on this site