Frequently asked questions
How do I get an API key?
Navigate to /get-api-key/ on bet4x.top and sign up using Google or an email and password. The dashboard displays your unique key, current balance, and usage statistics immediately upon creation.
What is the base URL for the API?
The API base URL is https://api.bet4x.top/v1. You send POST requests to https://api.bet4x.top/v1/audio/speech for synthesis and GET requests to /v1/voices or /v1/models for metadata.
Can I use the OpenAI SDK for this API?
Yes. The request shape matches the OpenAI speech endpoint. You can use the official OpenAI SDK by changing the base_url to https://api.bet4x.top/v1 and providing your site-specific key.
What are the rate limits?
You are limited to 60 requests per minute per key. New accounts without top-ups start with a lower limit of 10 requests per minute. These limits apply to all synthesis attempts.
How do I handle long texts in Python?
Split your text into parts of up to 4096 characters. Send each part as a separate request and then join the resulting audio files programmatically to create the final continuous audio track.
What audio formats are supported?
The API supports mp3, wav, opus, flac, and pcm formats. Specify your preferred format using the response_format field in your JSON request body when sending text to the synthesis endpoint.
How do I authenticate my requests?
Include an Authorization header with the value Bearer followed by your API key. The key format is tts-... and is generated when you sign up on the /get-api-key/ page.
What happens if a request fails?
Failed requests are free. If synthesis fails, the charge is returned in full to your account balance. You can retry the request or split the text if it exceeds character limits.
Can I change my API key?
Yes, you can issue a new key at any time from your dashboard. When a new key is issued, the old one stops working immediately, ensuring secure access management for your projects.
Is there a Python SDK provided?
No official SDK is provided. However, you can use the standard OpenAI Python SDK by adjusting the base_url configuration, or use plain HTTP libraries like requests to interact with the API.
How do I set the language explicitly?
Pass the optional language field with an ISO code in your request body. This is recommended for non-English Latin-script text, as the API otherwise guesses the language based on the script used.
What is the maximum character limit?
Each request supports up to 4096 characters in the input field. For longer texts, you must split the content into chunks of this size and process them individually before combining the audio outputs.
How is speed controlled in the API?
Use the speed field in your request, which accepts values between 0.25 and 4.0. This allows you to adjust the playback rate of the generated speech to suit your educational content needs.
Do I need to install specific libraries?
No specific proprietary libraries are required. You can use any standard HTTP client or the OpenAI SDK. Just ensure your environment supports JSON parsing and HTTP POST requests to the API endpoint.
First request
curl
curl https://api.bet4x.top/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.mp3Python (openai)
from openai import OpenAI
client = OpenAI(base_url="https://api.bet4x.top/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.bet4x.top/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 | |
|---|---|
aria | female |
nova | female |
luna | female |
sage | female |
felix | male |
milo | male |
atlas | male |
orion | male |
| language | |
|---|---|
ar | العربية |
zh | 中文 |
da | Dansk |
nl | Nederlands |
en | English |
fi | Suomi |
fr | Français |
de | Deutsch |
el | Ελληνικά |
he | עברית |
hi | हिन्दी |
it | Italiano |
ja | 日本語 |
ko | 한국어 |
ms | Bahasa Melayu |
no | Norsk |
pl | Polski |
pt | Português |
ru | Русский |
es | Español |
sw | Kiswahili |
sv | Svenska |
tr | Türkçe |
Authentication
Access the /get-api-key/ page to create your account via Google or email. Your dashboard displays a single active API key alongside your current balance and character usage statistics.
Include this key in every request header as Authorization: Bearer tts-.... The key authenticates your account against the API endpoint, enabling you to start generating audio immediately.
Get your API key
Register on the /get-api-key/ page using Google or an email/password combination. Accounts created with email do not receive the free trial credit, whereas Google sign-ins start with $0.50 valid for seven days.
Bearer token format
Use the standard HTTP Bearer authentication scheme. Prefix your key with Bearer in the Authorization header, for example: Authorization: Bearer tts-xxxxxxxxxxxxxxxx.
Key rotation policy
You may issue a new API key at any time from your dashboard. The previous key stops working immediately upon generation of the new one, ensuring secure access management for your educational tools.
First Request with cURL
Begin by sending a POST request to the speech endpoint using your API key. This method requires no external libraries, making it ideal for quick testing in any terminal environment.
The command structure is straightforward, requiring only the necessary parameters to generate audio. Replace the placeholder key with your actual credential to authenticate the request.
Basic command structure
Use the following cURL command to send a simple text-to-speech request. Ensure you replace YOUR_API_KEY with the key from your dashboard.
- Endpoint:
POST https://api.bet4x.top/v1/audio/speech - Header:
Authorization: Bearer YOUR_API_KEY - Body: JSON containing model, voice, input, and format
Required fields
The request body must include the model (either tts-1 or tts-1-hd), the input text (up to 4096 characters), and a voice preset. The response_format defaults to mp3 but can be specified explicitly.
model: "tts-1" or "tts-1-hd"input: Your text stringvoice: One of the 8 available presetsresponse_format: mp3, wav, opus, flac, or pcm
Expected response
On success, the API returns the audio file directly in the response body. You can save this output to a local file using the -o flag in cURL. If the synthesis fails, you receive an error JSON, and the request is free.
Using the OpenAI SDK
The OpenAI Python SDK works directly with our API by pointing it to the correct base URL. This allows educators and school developers to use familiar code structures for generating speech from lesson plans and reading materials without learning a new library.
By adjusting the client configuration, you can send text inputs and receive audio files just as you would with standard TTS services. This approach simplifies integration into existing educational software workflows.
Install the library
Install the official OpenAI Python package using pip. This provides the necessary client classes and request handlers for making API calls.
pip install openai
Set base URL
Configure the client to point to our API endpoint. Use the base_url parameter to direct requests to https://api.bet4x.top/v1 instead of the default OpenAI servers.
from openai import OpenAI client = OpenAI( base_url="https://api.bet4x.top/v1", api_key="tts-..." )
Configure parameters
Pass your text input, voice preset, and desired response format into the speech creation method. The SDK handles the JSON serialization and HTTP POST request automatically.
audio_response = client.audio.speech.create( model="tts-1", voice="nova", input="Hello, this is a test sentence.", response_format="mp3" )
Request Parameters
The API accepts two model identifiers: tts-1 and tts-1-hd. Both utilize the same underlying engine and pricing structure, allowing you to switch between them without cost implications. Select the model that best fits your current audio quality requirements for lesson plans or reading materials.
While the model choice is binary, the voice preset defines the auditory character of the output. The API provides eight distinct voices, categorized by gender and tonal quality, ensuring you can match the appropriate tone for educational content, from clear narration to conversational instruction.
Model selection (tts-1, tts-1-hd)
Both tts-1 and tts-1-hd map to the same engine and price tier ($10 per 1 million characters). There is no functional difference in pricing or capability between the two identifiers. You may choose either based on future-proofing or specific client preferences, though the underlying audio generation remains identical.
Voice presets
Choose from eight licensed voices, derived from LibriTTS-R and LibriVox recordings. Female voices include Aria (warm narrator), Nova (upbeat), Luna (storytelling), and Sage (instructional). Male options are Felix (energetic), Milo (conversational), Atlas (neutral news), and Orion (deep documentary). Each voice supports all 23 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
Speed and language settings
Adjust speed between 0.25 and 4.0 to control playback rate. The language field accepts an 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 texts using Latin characters, such as German or Dutch.
- Speed range: 0.25–4.0
- Language: Optional ISO code
- Default: English for Latin script
Response Formats
The API returns audio files in the format you specify, allowing you to choose the best balance between file size and quality for your educational materials. Each generated file includes an inaudible watermark to identify it as synthetic speech.
You can select from MP3, WAV, OPUS, FLAC, or PCM. This flexibility ensures compatibility with various learning management systems and audio players used in schools.
MP3 support
MP3 is the default and most widely supported format. It offers a good balance between audio quality and file size, making it ideal for web delivery and mobile apps.
This format is suitable for most lesson plan audio files where storage efficiency matters.
- Compressed for smaller file sizes
- Universal compatibility with players
- Default choice for web delivery
WAV support
WAV provides uncompressed, high-quality audio. It is ideal for editing or archival purposes where bit-perfect fidelity is required.
Use this format when you need to process the audio further in professional editing software.
- Uncompressed audio quality
- Ideal for editing workflows
- Larger file sizes than MP3
Other formats (OPUS, FLAC, PCM)
OPUS offers high-quality compression, suitable for bandwidth-constrained environments. FLAC provides lossless compression, retaining full audio quality while reducing file size compared to WAV.
PCM is raw, uncompressed audio data. It is useful for low-level processing or when you need the raw audio stream without any container overhead.
Choose FLAC for archival needs where storage space is less critical than perfect audio fidelity.
- OPUS: Efficient compression
- FLAC: Lossless compression
- PCM: Raw audio data

Rate Limits
The API enforces a strict rate limit of 60 requests per minute per active key. This ceiling ensures stable generation times and prevents sudden traffic spikes from degrading the service.
60 requests per minute
Once you have topped up your account, you can send up to 60 synthesis requests within any 60-second window. This limit applies globally to your single API key, so ensure your Python scripts do not exceed this threshold to avoid temporary rejection.
Initial limit of 10 requests
New accounts or those without a recent top-up start with a reduced limit of 10 requests per minute. This applies immediately upon key creation. You can increase this capacity by adding USDT to your balance.
Queue behavior under load
Requests are processed sequentially. If you hit the 60-request cap, additional requests may wait in a queue rather than failing immediately. Short phrases typically take a few seconds to generate, while longer texts take longer. Under heavy load, your script should handle temporary delays gracefully.
Error Handling
The API returns standard HTTP status codes to indicate request outcomes. A 200 OK means the audio was generated successfully, while 4xx errors typically indicate authentication or parameter issues. Understanding these codes helps developers debug integration problems quickly without unnecessary support tickets.
Common error codes
Use 401 for invalid or expired API keys, and 429 for rate limit exceeded. If the input text exceeds 4096 characters or the voice is unknown, you will receive a 400 Bad Request response. These errors are immediate and do not consume your character balance.
- 401 Unauthorized: Check your Bearer token format.
- 429 Too Many Requests: Wait before retrying.
- 400 Bad Request: Validate input length and voice ID.
Retry logic
Implement exponential backoff for 429 and 500 errors. Since requests are processed sequentially, under load a request may wait in a queue. Retrying immediately after a 429 may fail again; a short delay is recommended.
Failed request refunds
If synthesis fails due to a server error, the charge is returned in full. Failed requests do not deduct from your balance, ensuring you only pay for successfully generated audio files.
Handling Long Texts
The API accepts a maximum of 4096 characters per request. For longer lesson plans or reading materials, you must split the input text into chunks that fit this limit before sending them to the endpoint.
After receiving the audio files for each chunk, you need to join them into a single continuous file. This ensures the final audio matches the original text structure without gaps or delays between segments.
Splitting into 4096 char chunks
Break your text into segments of up to 4096 characters. Spaces and punctuation count toward this limit. Send each chunk as a separate request to the /v1/audio/speech endpoint.
- Count characters carefully, including spaces.
- Use a simple string split function in Python.
Joining audio files
Once you receive the audio files, concatenate them in the same order as the text chunks. The API returns the audio data directly, so you can save and merge them using standard libraries.
This approach keeps the process simple. The final file plays as a single coherent recording.
Python script example
Use the requests library to send chunks. Iterate through the text, collect the audio bytes, and merge them. The code below shows a basic structure for this workflow.
Ensure you handle the response content correctly to avoid corrupting the audio file. The speed and voice settings apply to each chunk individually.
- Install
requestsandpydub. - Loop through text chunks.
- Merge audio bytes.
- Save the final file.
Listen to the 8 voices
Each sample below was generated by this API from the same sentence.
23 languages
Any voice speaks any of these languages.
Sources and further reading
- Wikipedia
- openai-python on GitHub
- LibriTTS-R paper (arXiv 2305.18802)
- W3C WAI: making audio and video accessible
- OpenAI API reference: create speech
- ISO 639 language codes
- openai-node on GitHub
- LibriVox public-domain audiobooks
- FFmpeg documentation
- Python documentation
- IETF RFC 7845: Ogg Opus
- TRON developer hub: TRC-20
