TTS API Quickstart: Generate Audio with OpenAI SDK

By Clarispeak editorial team · Updated 2026-11-18

This guide helps HR agencies and training teams generate scalable, natural-sounding voice-overs for e-learning modules using the Clarispeak API. You will learn to integrate our text-to-speech service with the official OpenAI SDK by simply changing the base URL, allowing you to turn any script into professional audio in minutes without hiring voice talent.

We cover authentication, available voices, and rate limits to ensure your production workflow runs smoothly. Whether you are building internal communications or training courses, this documentation provides the concrete steps and code examples you need to start generating audio immediately with our reliable, character-based pricing model.

TTS API Quickstart: Generate Audio with OpenAI SDK

Frequently asked questions

How do I get an API key?

Sign up on the /get-api-key/ page using Google or email and password. Your account is specific to playtk8.com. The dashboard displays your active key, balance, and usage statistics immediately after registration.

What is the base URL?

The base URL is https://api.playtk8.com/v1. Use this endpoint for all API calls, including the speech generation endpoint at /v1/audio/speech. This allows compatibility with standard HTTP clients and SDKs.

Does it work with OpenAI SDK?

Yes. The request shape matches the OpenAI speech endpoint. You can use the official OpenAI SDKs by changing the base_url to https://api.playtk8.com/v1 and providing your Clarispeak API key.

What is the character limit per request?

Each request supports up to 4096 characters of input text. For longer texts, split them into parts of this size and join the resulting audio files. Spaces and punctuation count toward the limit.

How do I specify the language?

Include the optional 'language' field with an ISO code in your request body. If omitted, the system guesses the language based on the script, defaulting to English for Latin text.

What are the available models?

Two models are available: 'tts-1' and 'tts-1-hd'. Both use the same engine and pricing. Select the model that best fits your quality requirements while maintaining consistent billing rates.

How do I handle rate limits?

The limit is 60 requests per minute per key (10 per minute before the first top-up). Requests are processed sequentially, so under load, a request may wait in a queue.

What formats are supported?

Supported response formats are mp3, wav, opus, flac, and pcm. Specify your preferred format in the 'response_format' field of the JSON request body to receive the audio file in that encoding.

Is the API synchronous?

Yes, the API is synchronous. You send a POST request and receive the audio file in the response. For long texts, you must split the input and join the resulting audio files.

How do I authenticate requests?

Include your API key in the Authorization header using the format: 'Authorization: Bearer tts-...'. Ensure you use the active key associated with your account for successful authentication.

What happens on error?

If synthesis fails, the charge is returned in full. Failed requests are free, so you are not billed for characters that do not result in a successful audio generation.

Can I stream the audio?

No, streaming is not supported. The API returns the complete audio file in the response body. There is no WebSocket or real-time partial audio delivery available for this endpoint.

Is SSML supported?

No, SSML is not supported. The input field accepts plain text only. You cannot use SSML tags for pronunciation or prosody control, nor are there custom pronunciation lexicons available.

How do I rotate my key?

You can issue a new API key at any time from your dashboard. When a new key is issued, the old one stops working immediately, ensuring secure access management.

First request

curl

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

Secure your API access with a single Bearer token sent in the Authorization header. This key authenticates every request to our TTS endpoint, ensuring your usage is tracked accurately against your account balance.

Bearer token in header

Bearer token in header

Include Authorization: Bearer tts-... in every HTTP request. The token validates your identity and deducts costs from your available credit automatically.

Single key per account

Single key per account

Each account holds only one active key at a time. This simplifies integration for HR and training teams managing multiple e-learning modules, ensuring consistent billing and usage tracking.

Key rotation policy

You can issue a new key at any time via the dashboard. The old key stops working immediately, allowing you to rotate credentials without downtime. This is useful if you suspect a key has been exposed in your internal comms tools.

Endpoints

Sound wave illustration for: Endpoints

Our API exposes three core endpoints to power your e-learning voice-over workflows. Start by generating audio with the speech endpoint, then discover available voices and model details via the discovery endpoints.

POST /v1/audio/speech

Send text and receive an audio file. This endpoint accepts a JSON body with your text, chosen voice, and desired format. It mirrors the OpenAI speech structure, allowing you to use existing SDKs by simply adjusting the base URL.

  • Endpoint: POST https://api.playtk8.com/v1/audio/speech
  • Returns: Audio file in the requested format

GET /v1/voices

Retrieve the full list of available voices, supported languages, and audio formats. This helps you programmatically select from the eight presets like Aria or Felix based on your training module's tone.

GET /v1/models

List available models, including tts-1 and tts-1-hd. Both use the same engine and pricing, giving you flexibility without complexity.

Request Parameters

Sound wave illustration for: Request Parameters

To generate audio, your API calls must include a valid model identifier, either tts-1 or tts-1-hd. Both utilize the same high-quality engine and pricing tier, allowing you to choose based on latency preferences without affecting cost.

Input text is capped at 4,096 characters per request. For longer scripts, split your content into chunks and join the resulting audio files. Ensure you set the language parameter explicitly for non-English Latin-script text, as the system defaults to English when guessing.

Model selection

Select tts-1 for standard quality or tts-1-hd for enhanced clarity. Both models deliver the same voice presets and support all eight available voices, ensuring consistent character across your e-learning modules regardless of the selected tier.

Input text limit

The API accepts up to 4,096 characters per request, including spaces and punctuation. For lengthy training materials, split the text into manageable segments. Generate each segment individually and concatenate the audio outputs to create a complete narration.

Each request is processed sequentially, so longer texts may experience slight delays under load. Plan your segmentation strategy to maintain smooth playback transitions.

Voice and language

Choose from eight distinct voices, ranging from the warm narration of Aria to the neutral delivery of Atlas. Each voice supports all 23 languages, including Arabic, Chinese, English, and Spanish, making it easy to localize content for global teams.

If the language is not set, it is guessed from the script (Latin text defaults to English), so for non-English Latin-script text set the language. This ensures accurate pronunciation and natural intonation for diverse training audiences.

  • Supported voices: Aria, Nova, Luna, Sage, Felix, Milo, Atlas, Orion.
  • Languages: Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, Turkish.
  • Speed range: 0.25 to 4.0x, adjustable for pacing.

Response Formats

Sound wave illustration for: Response Formats

Clarispeak returns audio as binary data, allowing your integration to handle file storage directly. You select the format via the response_format parameter, ensuring the output matches your e-learning player’s requirements without additional conversion steps.

MP3 output

MP3 is the default format, offering excellent compression for easy web delivery. It is ideal for embedding audio in learning management systems (LMS) or mobile apps where bandwidth efficiency matters. The file remains small while maintaining clear speech quality for training modules.

WAV output

WAV provides uncompressed, high-fidelity audio. Use this format when your production pipeline requires lossless quality for final master recordings or when integrating with legacy audio editing tools. It ensures no data loss during the synthesis process.

Opus and FLAC

Opus offers superior compression at low bitrates, suitable for modern web players. FLAC provides lossless compression, reducing file size while preserving audio integrity. Both formats are excellent for archiving voice-over assets without the bloat of WAV.

Rate Limits

Sound wave illustration for: Rate Limits

Clarispeak enforces a strict rate limit of 60 requests per minute for each API key. This cap applies universally, ensuring stable performance for your e-learning generation pipelines without requiring tiered planning.

60 requests per minute

Each API key is allowed up to 60 requests per minute. This steady throughput supports bulk generation for training modules, allowing you to process multiple voice-overs concurrently while staying within the system's design limits.

10 requests before top-up

Accounts start with a limit of 10 requests per minute before the first top-up. This lower threshold helps manage initial load until you verify the service works with your workflow and add funds via USDT on the TRON network (TRC-20).

Queue handling

Requests are processed one after another within the limit. If you exceed the capacity, additional requests wait in a queue rather than failing immediately. This ensures no generated audio is lost, though processing time may increase during high demand.

  • Requests are processed sequentially.
  • Excess requests wait in a queue.
  • No audio is lost during queuing.
Rate Limits

Error Handling

Sound wave illustration for: Error Handling

When your API calls fail, the response clearly indicates why, helping you fix issues quickly without wasting credits. Understanding these standard HTTP codes ensures your integration handles edge cases gracefully.

400 Bad Request

This error occurs when the input text exceeds the 4096-character limit or contains invalid JSON structure. Ensure your payload matches the required schema and split longer texts into smaller chunks before sending.

  • Check character count per request
  • Validate JSON syntax
  • Ensure input field is present

401 Unauthorized

Returned when the Authorization header is missing or the Bearer token is invalid. Verify your key format (tts-...) and ensure it hasn’t been rotated or invalidated.

  • Include Authorization: Bearer <key>
  • Check key validity in dashboard

429 Too Many Requests

Occurs when you exceed the rate limit of 60 requests per minute per key. Implement exponential backoff in your retry logic to handle temporary throttling without overwhelming the API.

  • Limit: 60 req/min
  • Use retry-with-backoff strategy

Code Examples

Sound wave illustration for: Code Examples

Get your audio files instantly with our API, designed to integrate seamlessly into your existing HR and training workflows. Whether you are automating e-learning modules or internal communications, these examples show exactly how to send text and receive professional voice-overs in minutes.

cURL command

Use this command to generate speech immediately. Replace YOUR_API_KEY with your secret key from the dashboard. This example uses the 'nova' voice to create an upbeat, bright audio file in MP3 format, perfect for quick training snippets.

  • curl -X POST https://api.playtk8.com/v1/audio/speech \
  • -H "Authorization: Bearer YOUR_API_KEY" \
  • -H "Content-Type: application/json" \
  • -d '{"model": "tts-1", "input": "Welcome to our new onboarding module.", "voice": "nova", "response_format": "mp3"}'

Python with OpenAI SDK

Leverage the official OpenAI SDK by pointing it to our base URL. This Python snippet demonstrates how to synthesize a longer training script using the 'sage' voice, which provides a calm, instructional tone ideal for detailed explanations.

  • from openai import OpenAI
  • client = OpenAI(base_url="https://api.playtk8.com/v1", api_key="YOUR_API_KEY")
  • audio = client.audio.speech.create(
  • model="tts-1-hd", voice="sage", input="Please review the safety guidelines..."

JavaScript fetch

For web-based training platforms, use the native fetch API. This example sends a request to generate a clear, neutral audio clip using the 'atlas' voice, suitable for news-style updates or standard corporate announcements.

  • fetch("https://api.playtk8.com/v1/audio/speech", {
  • method: "POST",
  • headers: { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
  • body: JSON.stringify({ model: "tts-1", voice: "atlas", input: "Meeting notes updated." })
  • })

Best Practices

Sound wave illustration for: Best Practices

Clarispeak’s API processes requests sequentially, meaning complex e-learning batches may queue during peak hours. To ensure smooth delivery of your training modules, structure your workflow to handle these queues efficiently without blocking your application’s main thread.

Optimizing your integration strategy helps you stay within the 60 requests-per-minute limit while maintaining consistent audio generation speeds for your HR and training teams.

Split long texts

Each request supports up to 4,096 characters. For longer e-learning scripts, split the text into chunks and concatenate the resulting audio files. This ensures reliable synthesis and avoids truncation or errors in your final training video.

Handle retries

Requests are processed in order, so under load, you might encounter temporary delays. Implement exponential backoff for your API calls to gracefully handle these queues. This prevents overwhelming the system and ensures your batch jobs complete successfully.

Remember that failed requests are free, so retrying on transient errors does not incur extra charges. This makes robust retry logic cost-effective for high-volume training content generation.

Cache responses

Since generated audio is returned in the response and not stored on our servers, cache the audio files locally or in your CDN. This allows you to reuse the same voice-overs for different training modules or presentations without hitting the character limit or rate limits again.

Cacheing is especially useful for standard internal communications or recurring training segments, ensuring consistent branding and saving API credits for new, unique content.

Cache responses

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. This ensures that your training materials sound professional and engaging, regardless of the target demographic.

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

More on this site