Frequently asked questions
How do I get an API key?
Sign up at /get-api-key/ using Google or email. Accounts created with Google receive a $0.50 free trial valid for 7 days. Email-based accounts start without trial credit. You receive one active key per account, which you can use immediately to authenticate your requests.
What is the base URL for the API?
The API base URL is https://api.thb168thai.com/v1. You send POST requests to /audio/speech. Other endpoints like /voices and /models are also available under this base URL for retrieving voice lists and model information.
Can I use the OpenAI SDK?
Yes. The request shape matches the OpenAI speech endpoint. Simply change the SDK's base_url to https://api.thb168thai.com/v1 and provide your site-specific key. The official OpenAI SDKs work directly with this configuration for seamless integration.
What are the rate limits?
You are limited to 60 requests per minute per key. New accounts start with a limit of 10 requests per minute until the first top-up is processed. Requests are processed sequentially, so high load may cause queuing delays.
How do I specify a voice?
Include the voice field in your JSON body with one of eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. You can also optionally set the language field to an ISO code to guide generation.
What models are available?
Two models are available: "tts-1" and "tts-1-hd". Both use the same engine and price. You can select either model in your request body, and both support the same range of voices, languages, and audio formats.
How do I handle errors?
If synthesis fails, the charge is returned in full. Monitor the response status to detect failures. Ensure your input text is under 4096 characters and your key is valid. Failed requests incur no cost to your balance.
What audio formats are supported?
You can request audio in mp3, wav, opus, flac, or pcm formats. Specify the desired format using the response_format field in your request body. Each generated file also contains an inaudible watermark marking it as synthetic speech.
How do I split long texts?
Each request supports up to 4096 characters. For longer texts, split your input into chunks of this size. Generate audio for each chunk separately, then join the resulting audio files to create the complete final audio output.
Is the API compatible with other SDKs?
Yes, it is compatible with any HTTP client or SDK that supports standard JSON POST requests. While optimized for OpenAI SDK compatibility, you can also use plain HTTP requests or other libraries by matching the required request shape.
How do I rotate my API key?
You can issue a new API key at any time from your account page. When a new key is issued, the old one stops working immediately. This allows you to securely rotate keys without service interruption if needed.
What happens if I exceed the rate limit?
Requests are processed sequentially. If you exceed the limit, your request may wait in a queue. The system handles queuing automatically. Failed requests are free, so you are not charged for retries.
How do I check available voices?
Send a GET request to /v1/voices. This endpoint returns details on all available voices, supported languages, formats, and pricing information. It provides a complete list of the eight presets and their associated metadata for integration planning.
Is there a curl example?
Yes, the /get-api-key/ page displays a ready-to-use curl example. It demonstrates the correct JSON body structure, including model, input, voice, and response_format fields, along with the required Authorization header for authenticating your requests to the API.
First request
curl
curl https://api.thb168thai.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.mp3Python (openai)
from openai import OpenAI
client = OpenAI(base_url="https://api.thb168thai.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.thb168thai.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 | |
|---|---|
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
To generate audio, you need an API key from your account dashboard. This key acts as your credential, authorizing all requests sent to the speech endpoint.
API Key Format
Your key is a string starting with tts- followed by unique characters. It is issued when you sign up or request a new key.
Bearer Token
Include your key in the Authorization header of every HTTP request. Use the format: Authorization: Bearer tts-....
Single Active Key
We support one active key per account. If you issue a new key, the previous one stops working immediately. Rotate keys anytime from your dashboard.
Endpoints
The API exposes three core endpoints to manage your speech synthesis workflow. You generate audio via a simple POST request and retrieve metadata about available voices and models using GET requests. This structure mirrors the OpenAI API, ensuring a familiar experience for developers who already know the ecosystem.
All endpoints require your Bearer token in the Authorization header. The speech endpoint handles the heavy lifting of conversion, while the list endpoints provide the necessary configuration details like supported formats and language codes without consuming your character quota.
Speech Generation
Send text to the POST /v1/audio/speech endpoint. The API returns an audio file directly in the response body. You can specify the model, voice, speed, and output format (mp3, wav, opus, flac, or pcm) within the JSON body. Text is limited to 4,096 characters per request.
Longer texts should be split into chunks by your application before sending. Each chunk generates a separate audio file that you can concatenate later. Failed requests do not consume your credit balance.
- Endpoint: POST https://api.thb168thai.com/v1/audio/speech
- Body: JSON with model, input, voice, response_format, speed
List Voices
Use GET /v1/voices to retrieve the full list of available voices, their associated languages, and supported audio formats. This endpoint helps you verify which voice best suits your content type before generating audio. There are eight presets available, ranging from warm narrators to deep documentary styles.
Each voice supports all 23 listed languages. If you do not specify a language in your speech request, the system guesses it based on the script, defaulting to English for Latin text.
List Models
Call GET /v1/models to see the available model identifiers. Currently, "tts-1" and "tts-1-hd" are supported, using the same engine and pricing tier. This endpoint confirms the available versions without affecting your account balance or character count.
Both models offer identical audio quality and speed characteristics. You can switch between them freely based on your preference, though they share the same rate limits and character restrictions.
Request Parameters
Configure the request body with the required fields. You must specify the model, input text, and voice to generate audio.
The API accepts plain text up to 4096 characters. Specify the voice preset and optional language code for accurate synthesis.
Longer texts should be split into chunks to avoid character limits. Each chunk generates a separate audio file.
Model Selection
Choose between 'tts-1' or 'tts-1-hd'. Both use the same engine and price, so pick based on your quality needs.
Input Text
Pass your text in the 'input' field. The limit is 4096 characters per request, including spaces and punctuation.
For texts exceeding this limit, split the input and join the resulting audio files in your application logic.
Voice Selection
Select one of eight preset voices, such as 'aria' for narration or 'felix' for promos. Voices are gender-neutral in capability.
Optionally set the 'language' parameter with an ISO code. If omitted, the system guesses the language from the script.
- tts-1
- tts-1-hd
- aria
- nova
- luna
- sage
Response Format
The API returns the generated audio file directly in the response body, allowing you to save the result immediately. Supported formats include MP3, WAV, Opus, FLAC, and PCM, giving you flexibility for different deployment needs.
Audio File Return
Upon successful synthesis, the response body contains the raw audio bytes. You do not receive a URL; instead, the file data is sent directly, which simplifies integration into your application’s audio pipeline.
- Direct binary response
- No intermediate storage required
- Supports all listed formats
Error Codes
If synthesis fails, the API returns a standard HTTP error code along with a JSON body detailing the issue. Failed requests are free, and any charge is returned in full, ensuring you only pay for successful generations.
- HTTP 400 for invalid parameters
- HTTP 401 for authentication issues
- HTTP 429 for rate limits
Metadata
The response headers may include useful metadata such as character count. This data helps you track usage for billing purposes and monitor performance without needing to parse the audio content itself.
- Character count verification
- Processing duration info
- Content-Type header
OpenAI SDK Integration
Integration is straightforward because the endpoint structure mirrors the OpenAI speech API. You simply update the base URL to point to our API and swap in your generated key. This allows you to use the official OpenAI SDKs without rewriting your client logic.
This compatibility means you can drop our service into existing projects with minimal code changes. It works seamlessly for both simple scripts and complex application architectures.
Base URL Change
Point your SDK configuration to https://api.thb168thai.com/v1 instead of the default OpenAI endpoint. Ensure your API key header remains Bearer <your-key>.
SDK Compatibility
The official OpenAI Python and Node.js SDKs work out of the box. Any library following the standard OpenAI API shape will recognize our endpoints correctly.
Code Example
Here is a Python example using the openai package. Replace YOUR_API_KEY with your key from the dashboard.
- import openai
- client = openai.OpenAI(api_key='YOUR_API_KEY', base_url='https://api.thb168thai.com/v1')
- response = client.audio.speech.create(model='tts-1', voice='nova', input='Hello world')
- with open('output.mp3', 'wb') as f:
- f.write(response.content)

Rate Limits
Rate limits protect service stability by capping concurrent synthesis requests. You are allowed 60 requests per minute per API key, ensuring consistent performance during steady usage.
60 Requests Per Minute
The standard limit is 60 requests per minute. This allows you to generate audio files rapidly without overwhelming the server, provided you stay within this threshold.
Initial Limit
New accounts start with a lower limit of 10 requests per minute. This helps prevent abuse while you test the API with short texts or basic integrations.
Limit Increase
Top up your account balance with USDT. Once the transfer is processed, your rate limit automatically increases to 60 requests per minute.
Audio Formats
The API supports five distinct audio formats, allowing you to choose the right balance between file size and quality for your specific use case. You specify your preferred format using the response_format parameter in your request.
All formats include an inaudible watermark to mark the output as synthetic speech, ensuring clear attribution without affecting playback.
Choose MP3 or WAV for maximum compatibility, or Opus and FLAC for efficient storage and lossless quality respectively.
MP3
MP3 is the default and most widely supported format. It offers a good balance between file size and audio quality, making it ideal for web applications and general-purpose audio playback.
Use this format when you need broad compatibility across different devices and platforms without managing large file sizes.
- Small file size
- Universal playback support
- Default format
WAV
WAV provides uncompressed, high-quality audio. It is perfect for professional editing pipelines or when you need raw audio data without any loss from compression.
This format results in larger file sizes compared to MP3, but ensures no quality degradation during storage or processing.
- Uncompressed quality
- Ideal for editing
- Larger file size
Opus, FLAC, PCM
Opus offers excellent compression with high quality, suitable for bandwidth-constrained environments. FLAC provides lossless compression, retaining full audio fidelity while reducing file size. PCM delivers raw, uncompressed audio data, ideal for direct processing.
Select these formats based on your specific needs for storage efficiency versus absolute audio fidelity.
- Opus: Efficient streaming
- FLAC: Lossless compression
- PCM: Raw audio data
Troubleshooting
When integration stalls, most issues stem from simple configuration mismatches or transient network states. This section addresses the three most frequent hurdles indie developers face when connecting their applications to the Thai TTS Dev API, ensuring your audio generation pipeline remains stable and predictable.
We focus on concrete, fixable problems rather than abstract theory. By understanding the specific error signatures and limits of our system, you can resolve issues quickly without unnecessary debugging cycles.
Common Errors
The most frequent issue is an invalid API key format. Ensure your key starts with tts- and contains no extra whitespace. If you rotate your key, remember the old one stops immediately, so update your environment variables promptly.
Another common error occurs when the input text exceeds 4096 characters. The API does not handle long-form splitting automatically. You must split your text into chunks before sending the request to avoid a 400 error.
- Check key format starts with
tts- - Split text if > 4096 characters
- Verify JSON syntax in body
Rate Limit Exceeded
New accounts start with a limit of 10 requests per minute. Once you top up your balance, this increases to 60 requests per minute. If you hit this limit, the API returns a 429 status code.
Requests are processed sequentially. During high load, your request may wait in a queue, potentially causing a timeout if your client doesn't handle delays gracefully. Implement exponential backoff in your retry logic to handle these transient limits smoothly.
- New accounts: 10 req/min
- Topped-up accounts: 60 req/min
- Handle 429 status with backoff
Invalid Voice
If you specify a voice that doesn't exist or is inactive, the API returns a 400 Bad Request. Always verify available voices using the GET /v1/voices endpoint before hardcoding them into your application. There are only 8 presets, so double-check the spelling.
Ensure the selected voice supports the language you specified. While most voices support all 23 languages, some combinations may behave unexpectedly if the language parameter is omitted for non-English text. Always set the language field for Latin-script non-English inputs.
- Use GET /v1/voices to verify
- Check voice spelling exactly
- Set language parameter explicitly
Listen to the 8 voices
Each sample below was generated by this API from the same sentence. We focus on reliable, good-quality synthetic speech that integrates quickly into apps.
23 languages
Any voice speaks any of these languages.
Sources and further reading
- Wikipedia
- LibriTTS-R paper (arXiv 2305.18802)
- W3C WAI: making audio and video accessible
- OpenAI API reference: create speech
- IETF RFC 7845: Ogg Opus
- ISO 639 language codes
- Creative Commons Attribution 4.0
- openai-python on GitHub
- LibriVox public-domain audiobooks
- FFmpeg documentation
- Python documentation
- openai-node on GitHub
