Python Integration Guide for Text-to-Speech API

By Kayabet88 editorial team · Updated 2026-11-19

This guide details the Python integration for AccessTalk’s cloud text-to-speech API, designed for large teams standardizing audio output in corporate communications. You will find the exact request structure, authentication methods, and voice selection parameters required to generate accessible content. The documentation covers all essential endpoints, from initial setup to error handling, ensuring your Python workflows integrate seamlessly with our infrastructure.

Readers will learn how to manage API keys, configure speed and language settings, and handle response formats like MP3 and WAV. We outline the 60 requests-per-minute rate limit and explain the queue behavior under load. This resource assumes basic Python knowledge and focuses on practical implementation details, including character limits and billing metadata, so your team can deploy reliable TTS solutions for accessibility projects immediately.

Python Integration Guide for Text-to-Speech API

Frequently asked questions

How do I generate an API key?

Navigate to /get-api-key/ and sign in using Google or an email/password combination. The dashboard displays your active API key, which you use for authentication. You can issue a new key at any time; the previous key stops immediately upon the new one’s creation.

What is the maximum input text length?

The maximum input text length is 4096 characters per request. For longer texts, split the content into parts of up to 4096 characters and join the resulting audio files. Spaces and punctuation count toward this character limit.

Which Python SDK should I use?

Use the official OpenAI SDK. Change the base_url to https://api.kayabet88.cc/v1 and provide your site’s key. The request shape matches the OpenAI speech endpoint, allowing seamless integration into existing Python workflows without requiring a proprietary SDK.

Can I change the voice mid-stream?

No. The API does not support streaming or WebSocket connections. Each request generates a complete audio file. To change voices, you must make separate API calls for each segment and join the resulting audio files.

How do I handle rate limit errors?

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

Is the API key unique per account?

Yes, there is one active key per account. You can issue a new key at any time, which immediately invalidates the old one. This ensures a single point of authentication for your corporate communications workflow.

What formats are supported for output?

Supported formats are mp3, wav, opus, flac, and pcm. Specify the desired format using the response_format field in your JSON request body. Each generated file carries an inaudible watermark marking it as synthetic speech.

How do I specify a language explicitly?

Pass the ISO code in the language field. If omitted, the system guesses the language, defaulting to English for Latin script. Explicitly setting the language is recommended for non-English Latin-script text to ensure accuracy.

Does the API support streaming audio?

No, the API does not support streaming, WebSockets, or real-time partial audio. It returns complete audio files via POST requests. You must wait for the full response before processing the next segment in your workflow.

What happens if the server is down?

If synthesis fails, the charge is returned in full. There is no SLA or uptime guarantee. Failed requests incur no cost, ensuring your billing remains accurate even during service interruptions or high-load queuing delays.

Can I use the same key on multiple servers?

Yes, a single API key can authenticate requests from multiple servers or clients. The rate limit applies per key, so coordinate your total request volume across all servers to stay within the 60 requests per minute limit.

How do I test my API key?

Use the ready curl example provided on the /get-api-key/ dashboard page. Send a POST request to https://api.kayabet88.cc/v1/audio/speech with your key in the Authorization header to verify connectivity and correct authentication setup.

Is there a curl example available?

Yes, the /get-api-key/ page displays a ready-to-use curl example. It demonstrates the correct JSON body structure, including model, voice, and input fields, allowing you to quickly verify your API key and integration setup.

How long are responses cached?

Generated audio is returned in the response and not stored by the API. Input text is used only for synthesis and not for training. Request metadata is kept for billing purposes. No caching duration is guaranteed.

First request

curl

curl https://api.kayabet88.cc/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.kayabet88.cc/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.kayabet88.cc/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 and Setup

Sound wave illustration for: Authentication and Setup

To begin integrating AccessTalk’s text-to-speech API into your Python workflow, navigate to the /get-api-key/ page and authenticate via Google or email. Upon successful sign-in, your unique API key is displayed immediately alongside your current balance and character allowance.

Store this key securely in your environment variables. It serves as the sole credential for all API requests, ensuring that audio generation is billed accurately against your account balance without requiring additional authentication tokens.

API Key Generation

API Key Generation

Keys are issued upon account creation. If you signed up with an email and password, no trial credit is applied automatically; only Google sign-ups receive the initial $0.50 trial credit valid for 7 days.

  • Access keys via the /get-api-key/ dashboard.
  • One active key per account.
  • Keys are visible immediately after login.

Bearer Token Configuration

Bearer Token Configuration

Include your key in the HTTP Authorization header as a Bearer token. The standard format is Authorization: Bearer tts-.... This token is required for every POST request to the speech endpoint.

Ensure the token is passed correctly in your Python HTTP library (e.g., requests or openai SDK) to avoid 401 Unauthorized errors.

  • Header: Authorization: Bearer tts-<your_key>
  • Use standard HTTP libraries.
  • Keep the key in environment variables.

Key Regeneration Process

You may regenerate your API key at any time from the dashboard. When a new key is issued, the previous key stops working immediately, ensuring tight control over access.

Update your production configurations promptly after regeneration to avoid service interruption for your audio delivery pipelines.

  • Regenerate anytime from the dashboard.
  • Old key becomes inactive instantly.
  • No downtime during switch if updated quickly.

Core Speech Endpoint

Sound wave illustration for: Core Speech Endpoint

The synthesis endpoint accepts text input and returns generated audio files. This core functionality enables large teams to integrate text-to-speech directly into their Python workflows, standardizing voice output for corporate communications and accessibility content delivery without requiring custom infrastructure.

Requests are processed sequentially, meaning under load a request may wait in a queue. Typical generation speed is roughly real time, approximately 25 characters of text per second of audio. Short phrases may take a few seconds to complete.

POST /v1/audio/speech

Send a POST request to https://api.kayabet88.cc/v1/audio/speech. Use the official OpenAI SDK by setting the base_url to https://api.kayabet88.cc/v1. The request shape matches the OpenAI speech endpoint, allowing direct integration with existing Python libraries.

Authentication requires a Bearer token in the Authorization header. Ensure your API key is active and has sufficient balance. Failed requests are free, ensuring no charge for synthesis errors.

  • Endpoint: POST https://api.kayabet88.cc/v1/audio/speech
  • Method: HTTP POST
  • Content-Type: application/json

JSON Body Structure

The request body is a JSON object containing the model, input text, voice selection, and optional parameters. The model field accepts "tts-1" or "tts-1-hd", both using the same engine and pricing. The voice field specifies one of eight available presets.

Optional fields include response_format, speed, and language. The speed parameter ranges from 0.25 to 4.0. If language is omitted, the system guesses from the script, defaulting to English for Latin text.

  • model: "tts-1" or "tts-1-hd"
  • input: string (required)
  • voice: string (required)
  • response_format: mp3, wav, opus, flac, pcm
  • speed: float (0.25–4.0)
  • language: ISO code (optional)

Input Text Limits

Each request supports a maximum of 4096 characters of input text. Spaces and punctuation count toward this limit. For texts exceeding this length, split the content into parts and join the resulting audio files.

The API does not support SSML. Input text is used only to produce the audio and is not used for training. Generated audio is returned in the response and not stored.

  • Maximum length: 4096 characters
  • Spaces and punctuation count
  • Split long texts manually
  • No SSML support

Voice and Model Selection

Sound wave illustration for: Voice and Model Selection

To generate audio, specify either tts-1 or tts-1-hd in the model field. Both models use the same underlying engine and pricing structure ($0.01 per 1,000 characters), differing only in output fidelity. The input text must not exceed 4,096 characters per request; larger texts require client-side splitting and audio concatenation.

The API supports eight voice presets categorized by gender and tone, including female options like Aria and Nova, and male options like Felix and Milo. Each voice can render any of the 23 supported languages. If the language parameter is omitted, the system guesses the language based on the script, defaulting to English for Latin text. Explicitly setting the language code ensures accurate pronunciation for non-English content.

tts-1 and tts-1-hd Models

Both tts-1 and tts-1-hd utilize identical synthesis engines and incur the same charge of $10 per million characters. There is no performance or feature difference between the two model identifiers; they are functionally interchangeable for standard corporate communications and accessibility workflows.

Available Voice Presets

Select a voice from eight licensed presets. Female voices include Aria (warm narrator), Nova (bright), Luna (soft storytelling), and Sage (calm instructional). Male voices include Felix (energetic), Milo (friendly), Atlas (neutral news), and Orion (deep documentary). All voices are derived from LibriTTS-R and LibriVox recordings.

  • 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

Language Parameter Usage

The language parameter accepts a standard ISO code. While the system auto-detects language from the input script, explicitly setting this field is recommended for Latin-script texts that are not English. The API supports 23 languages, including Arabic, Chinese, German, Japanese, and Spanish, among others.

  • Supported: Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, Turkish
  • Not supported: Vietnamese, Indonesian, Thai, Ukrainian, Romanian, Czech, Bengali

Response Formats

Sound wave illustration for: Response Formats

The API returns synthesized audio directly in the response body, eliminating the need for intermediate storage or polling. The response_format parameter determines the encoding, with MP3 as the default for efficient bandwidth usage and broad compatibility across corporate media players and accessibility tools.

MP3 Audio Output

MP3 is the standard format for most integration scenarios, offering a balance between file size and audio quality. This format is suitable for storing in corporate asset libraries or playing back in web players.

WAV and FLAC Options

WAV and FLAC provide lossless quality, suitable for archival purposes or high-fidelity accessibility standards. FLAC offers compression without data loss, reducing storage costs while maintaining the integrity of the original synthesis.

PCM Raw Data Handling

PCM returns uncompressed linear audio, which may require client-side encoding for playback. This format is useful for low-level audio processing pipelines where the application handles codec conversion directly.

Rate Limits and Throttling

Sound wave illustration for: Rate Limits and Throttling

AccessTalk enforces a strict rate limit of 60 requests per minute per API key. This ensures stable throughput for large teams generating accessible audio content. Requests are processed sequentially, meaning under high load, subsequent requests may queue briefly.

60 Requests Per Minute

Each account key is allocated a maximum of 60 API calls within any one-minute window. Exceeding this limit results in a 429 Too Many Requests response. Teams should implement exponential backoff in their Python workflows to handle these delays gracefully.

Initial Queue Limits

New accounts or those without recent top-ups start with a reduced limit of 10 requests per minute. This initial cap prevents resource exhaustion before the first deposit is processed. Balance increases once USDT is credited.

Load Balancing Behavior

Requests are processed in the order received. Longer texts take more time to synthesize, potentially increasing queue wait times. Short phrases typically complete within a few seconds, while longer documents may take longer due to sequential processing.

Rate Limits and Throttling

Error Handling and Status Codes

Sound wave illustration for: Error Handling and Status Codes

Errors from the API indicate either invalid request parameters or transient server issues. Client errors (4xx) typically result from missing fields, exceeded character limits, or invalid voice IDs. Server errors (5xx) suggest temporary processing failures during synthesis.

4xx Client Errors

Review your JSON body for required fields like model and voice. Ensure the text does not exceed 4096 characters and that the voice ID exists in the /v1/voices list.

5xx Server Errors

These indicate temporary processing issues. The API processes requests sequentially, so high load may cause delays or timeouts. Check your request metadata to confirm the status code.

Retry Logic Implementation

Implement exponential backoff for transient errors. For rate limit errors (429), wait before retrying. Failed synthesis requests are free, so retrying is cost-effective.

  • Retry on 429, 500, 502, 503, 504
  • Use exponential backoff starting at 1 second
  • Verify 429 is due to rate limits (60 req/min)

Voices and Languages Endpoint

Sound wave illustration for: Voices and Languages Endpoint

The GET /v1/voices endpoint provides a complete list of available voice presets, supported languages, and output formats. This metadata allows your Python scripts to dynamically select the appropriate voice and ensure compatibility with your audio processing pipeline without hardcoding values.

Language Code Support

Each voice supports 23 specific languages, including English, Spanish, German, and Japanese. You may optionally specify the ISO 639-1 language code in the request. If omitted, the system guesses the language from the text script, defaulting to English for Latin characters. Explicitly setting the language is recommended for non-English Latin text to ensure accurate synthesis.

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

Format Metadata Retrieval

The endpoint returns metadata for all supported response formats: mp3, wav, opus, flac, and pcm. This information helps you configure your audio clients correctly. Use this data to validate format compatibility before sending synthesis requests, ensuring that your generated audio files are processed correctly by downstream accessibility tools.

Model Information Endpoint

Sound wave illustration for: Model Information Endpoint

The GET /v1/models endpoint provides metadata about the current synthesis engines. It returns structured data confirming the availability of tts-1 and tts-1-hd models, allowing your integration to verify engine support before dispatching requests.

GET /v1/models

Send a GET request to https://api.kayabet88.cc/v1/models. The response confirms the active model versions and their current status, ensuring your batch processing pipelines align with available infrastructure.

Engine Specifications

The API serves two models: tts-1 and tts-1-hd. Both utilize the same underlying engine and incur identical pricing. The distinction lies in audio fidelity, with tts-1-hd providing higher quality output.

Feature Availability

This endpoint confirms standard capabilities such as speed adjustment (0.25–4.0) and format selection. It does not indicate support for SSML or custom voice cloning, as these features are not part of the current engine specification.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Reliable integration requires handling transient failures gracefully.

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

More on this site