API Documentation for Text to Speech Synthesis

By VerbaClass editorial team · Updated 2026-11-18

This documentation explains how to integrate the VerbaClass text-to-speech API into your workflow. You will learn to generate audio files from lesson plans, articles, and student assignments using standard HTTP requests or the OpenAI SDK. The guide covers authentication, required parameters like model selection and voice presets, and response handling for formats such as MP3 and WAV.

Designed for product teams building accessible features for schools, this page provides practical, step-by-step instructions. You will find concrete examples for making your first request, managing rate limits of 60 requests per minute (10 before the first top-up), and handling long texts by splitting them into 4096-character segments. All technical details are based on the live API at api.playph222.com, ensuring you can implement reliable, compliant audio synthesis without managing infrastructure.

API Documentation for Text to Speech Synthesis

Frequently asked questions

How do I get an API key?

Sign up on the /get-api-key/ page using Google or an email and password. Accounts are specific to this site. The dashboard displays your active key, balance, and usage statistics. You can issue a new key at any time, which immediately invalidates the previous one.

What is the endpoint URL?

Send a POST request to https://api.playph222.com/v1/audio/speech. Include a JSON body with your text, voice selection, and format. Use https://api.playph222.com/v1/voices to list available voices and languages. The base URL for SDK configuration is https://api.playph222.com/v1.

Which SDKs are supported?

The API follows the same request shape as the OpenAI speech endpoint. You can use the official OpenAI SDKs by changing the base_url to https://api.playph222.com/v1 and providing your site-specific key. (Note: This is not an official OpenAI product.) Plain HTTP requests are also fully supported for any programming language.

What models are available?

Two models are available: 'tts-1' and 'tts-1-hd'. Both use the same engine and pricing. Select your preferred model in the 'model' field of your request body. There are no other model variations or custom voice cloning options available.

How do I specify a voice?

Include one of the eight preset voices in the 'voice' field: aria, nova, luna, sage, felix, milo, atlas, or orion. You can view all available voices and their details by calling the GET /v1/voices endpoint. Each voice supports all 23 supported languages.

What languages are supported?

We support 23 languages including Arabic, Chinese, English, French, German, Japanese, Spanish, and others. Any voice can speak any supported language. If you omit the language parameter, the system guesses it from the script, defaulting to English for Latin text.

Can I change the speed?

Yes, you can adjust the speed between 0.25 and 4.0 using the 'speed' parameter. This allows you to slow down narration for clarity or speed up content for brevity. The default speed is 1.0, which produces natural-sounding speech for most use cases.

What formats are available?

You can request audio in mp3, wav, opus, flac, or pcm formats. Specify your preferred format in the 'response_format' field of your request. These formats cover most common playback and development needs without requiring additional conversion steps on your end.

How many requests per minute?

You are limited to 60 requests per minute per API key. Before your first top-up, this limit is reduced to 10 requests per minute. If you exceed the limit, requests may be queued or rejected until the rate window resets.

What happens if I exceed limits?

Requests are processed sequentially, so high volume may cause queuing delays. If you exceed the rate limit, you may receive an error response. Failed requests are free, and the charge is returned in full if synthesis fails for any reason.

Is there an error response format?

Standard HTTP error codes are returned when requests fail or exceed limits. Failed synthesis results in a full refund of the character cost. You can monitor your status and usage directly on the /get-api-key/ dashboard to anticipate limits and errors.

Can I use the same key on multiple sites?

No, accounts and API keys are specific to each site in the network. Each site operates as an independent storefront. You must sign up separately on each site to receive a unique key for that specific domain's usage tracking.

How do I handle long texts?

Each request supports up to 4096 characters. For longer texts, split the input into parts of this size and join the resulting audio files. This ensures optimal processing speed and prevents request failures due to length constraints during synthesis.

Are responses cached?

Generated audio is returned in the response and not stored by the API. Input text is used only for production and not for training. Request metadata is kept for billing purposes. You must re-request audio if you need it again later.

First request

curl

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

Get your API key

Sound wave illustration for: Get your API key

Access your credentials by signing in at /get-api-key/. You can register using a Google account or a standard email and password combination. This page displays your current balance, trial status, and a ready-to-use curl example for immediate testing.

Sign in on /get-api-key/

Sign in on /get-api-key/

Navigate to the /get-api-key/ page on playph222.com to create your account. Accounts are specific to this site, so ensure you are on the correct domain. Once signed in, you gain access to your unique authentication details.

  • Support for Google or email/password sign-in
  • Immediate view of balance and trial credit

Copy your Bearer token

Copy your Bearer token

Locate your API key on the dashboard and copy it. Use this value in the Authorization: Bearer header of your requests. Keep this token secure, as it provides full access to your account and billing.

One active key per account

You can have only one active key per account. If you need a new key, you can issue it at any time from the dashboard. The previous key stops working immediately upon issuance, ensuring clean access control.

First request with curl

Sound wave illustration for: First request with curl

This section demonstrates the initial API call using curl. It covers the POST request to the speech endpoint, required parameters, and the binary audio response.

The example uses the standard OpenAI-compatible format, allowing you to verify connectivity and basic synthesis before integrating into your application. (Note: This is not an official OpenAI product.)

Use POST to /v1/audio/speech

Send a POST request to https://api.playph222.com/v1/audio/speech. Include your Bearer token in the Authorization header. Ensure your key is active and has sufficient balance.

  • Endpoint: POST /v1/audio/speech
  • Header: Authorization: Bearer tts-your-api-key

Include model and input text

The JSON body must contain model, input, and voice. Choose tts-1 or tts-1-hd. Provide text up to 4096 characters. Specify a voice from the 8 presets.

  • model: tts-1 or tts-1-hd
  • input: your lesson text
  • voice: e.g., aria, nova

Receive audio file in response

The response body contains the raw audio file. The format depends on your response_format parameter (mp3, wav, opus, flac, pcm). Save the binary output directly to a file.

  • Content-Type: audio/mpeg (for mp3)
  • No JSON wrapper in audio response

OpenAI SDK integration

Sound wave illustration for: OpenAI SDK integration

VerbaClass is compatible with the official OpenAI SDKs. To use them, change the base_url to https://api.playph222.com/v1 and use your site's key. This allows you to use the standard SDK methods for TTS without custom code.

Set base_url to api.playph222.com/v1

Configure your SDK client to point to our API base URL. This ensures all requests go through our infrastructure while using familiar libraries.

Use standard OpenAI SDK methods

Call the standard audio.speech.create method. Pass your parameters like model, input, and voice as you would for OpenAI.

Replace key with your token

Insert your Bearer token from the dashboard. The SDK authenticates your requests automatically using this key.

Request parameters

Sound wave illustration for: Request parameters

Configure the synthesis engine and voice output for each request. Choose the standard or high-definition model and select from eight distinct voice presets to match your content tone. These parameters define how the text is converted into audio.

model: tts-1 or tts-1-hd

Both models use the same engine and price. Select tts-1 or tts-1-hd. Both models use the same engine and price. The choice does not affect the character count or billing rate.

voice: one of 8 presets

Select one of eight licensed voices, such as Aria for narration or Felix for promos. Each voice can speak any of the 23 supported languages, allowing consistent audio style across diverse lesson plans and articles.

  • Aria (warm narrator)
  • Felix (energetic)
  • Milo (friendly)
  • Atlas (neutral)

language: optional ISO code

Specify the language using an ISO code to ensure accurate pronunciation. If omitted, the system guesses the language, defaulting to English for Latin script. Set this explicitly for non-English Latin text to avoid misinterpretation.

Response formats

Sound wave illustration for: Response formats

The API returns raw audio data in the requested format, specified by the response_format parameter. Supported options include mp3, wav, opus, flac, and pcm, allowing flexible integration into various educational platforms and classroom tools.

mp3, wav, opus, flac, pcm

Select the format that best suits your delivery needs. MP3 offers efficient compression, while WAV and FLAC provide lossless quality. OPUS is efficient for data-constrained environments, and PCM provides uncompressed raw audio data. (Note: The API does not support streaming; audio is returned as a complete file.)

  • mp3: Compressed, widely compatible
  • wav: Lossless, standard for desktop apps
  • opus: Efficient for low bandwidth
  • flac: Lossless, smaller than WAV
  • pcm: Uncompressed raw audio

Binary audio in response body

The audio file is returned directly in the response body as binary data. Your application should handle the raw bytes without parsing JSON, ensuring efficient processing for large audio files generated from longer texts.

No JSON in audio response

Unlike the request, the successful response does not contain a JSON wrapper. The entire payload is the audio file itself, streamlining integration by eliminating the need to extract audio from a JSON object.

Response formats

Rate limits

Sound wave illustration for: Rate limits

The API enforces a standard limit of 60 requests per minute for each active API key. This limit applies uniformly regardless of the model chosen, ensuring predictable throughput for typical classroom or application workloads. You can monitor your current usage and limits directly on the /get-api-key/ dashboard page.

Under normal conditions, requests are processed in the order they are received. If the system experiences high load, a request may wait in a queue before synthesis begins. This sequential processing ensures stability but may introduce slight delays during peak usage periods.

60 requests per minute per key

Each active API key allows up to 60 requests per minute. This rate is sufficient for most integration scenarios, including batch processing of lesson plans. (Note: Requests are processed sequentially, so 'real-time' classroom exercises may experience delays under load.) The limit resets every minute, allowing for bursty traffic patterns without immediate throttling.

10 requests before first top-up

Accounts are limited to 10 requests per minute before the first top-up. This lower threshold prevents excessive consumption of the trial credit while allowing educators to test the API effectively. Once you top up your balance, the limit increases to the standard 60 requests per minute.

Requests processed sequentially

Requests are handled one after another in the queue. Under heavy load, this may cause a request to wait before synthesis starts. For long texts, the system automatically splits the input into parts of up to 4096 characters and joins the resulting audio files. Typical generation speed is roughly real-time, producing about 25 characters of text per second of audio.

Error handling

Sound wave illustration for: Error handling

When the synthesis engine fails to generate audio, the request is marked as failed and your balance is not charged. This ensures you only pay for successful audio files, protecting your budget during input issues.

Failed requests are free

If the API returns an error status, no characters are deducted from your account. You can retry the same text without incurring additional costs, making it safe to test different voices or parameters.

Check status codes in response

Inspect the HTTP status code to determine the cause of failure. Common codes include 400 for invalid parameters (e.g., text too long) and 401 for authentication errors. Use these codes to adjust your request payload or API key.

  • 400: Invalid request parameters
  • 401: Unauthorized or expired key
  • 429: Rate limit exceeded

Retry on server errors

For 5xx server errors, implement a simple retry logic with exponential backoff. Since requests are processed sequentially, brief delays often resolve transient queue congestion. Failed retries remain free, so you can retry until success or a persistent error occurs.

Long text handling

Sound wave illustration for: Long text handling

Long texts require splitting because each API request accepts up to 4096 characters. This limit includes spaces and punctuation. You must divide your lesson plans, articles, or student assignments into smaller chunks before sending them to the endpoint.

After synthesis completes for each chunk, you receive individual audio files. Your application must join these files sequentially to create one continuous audio track. This ensures the final output matches the original text structure without gaps.

Split text into 4096 char parts

Divide your input text into segments of 4096 characters or fewer. Ensure you do not cut words in half if possible, though the API handles boundaries cleanly. Each segment becomes a separate POST request to the speech endpoint.

  • Count spaces and punctuation as characters
  • Max 4096 characters per request
  • Send multiple requests for longer texts

Join audio files after generation

The API returns binary audio data for each request. Your system must concatenate these audio files in the same order as the original text segments. This creates a single, coherent audio file for the entire text.

Real-time speed on long texts

Generation takes roughly real-time, about 25 characters per second. Long texts may require queuing, so requests are processed sequentially. Plan your workflow accordingly, especially for large document batches.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. It works well for daily announcements, science articles, or historical summaries.

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. ISO 639 language codes
  3. LibriVox public-domain audiobooks
  4. W3C WAI: making audio and video accessible
  5. Creative Commons Attribution 4.0
  6. FFmpeg documentation
  7. IETF RFC 7845: Ogg Opus
  8. TRON developer hub: TRC-20
  9. openai-python on GitHub
  10. LibriTTS-R corpus (OpenSLR 141)
  11. curl documentation
  12. Node.js documentation

More on this site