Frequently asked questions
Does the API support streaming audio?
No, the API does not support streaming. It returns complete audio files upon request completion. You receive the full audio file in the response, which is not stored after delivery. There is no WebSocket support for real-time partial audio delivery, so you must wait for the entire synthesis to finish before receiving the data.
Can I use the official OpenAI Python SDK?
Yes, the official OpenAI SDKs work with this API. You can use them by changing the base_url to https://api.huaylan.cc/v1 and providing your Huaylan API key. The request shape is identical to the OpenAI speech endpoint, allowing you to integrate quickly without rewriting your existing code logic.
What is the maximum character limit per request?
The maximum character limit is 4096 characters per request. If your text exceeds this limit, you must split it into parts of up to 4096 characters and join the resulting audio files. Spaces and punctuation count toward this character limit, so plan your splitting logic accordingly for longer documents.
How do I specify a language for non-English text?
You can specify the language using the optional language parameter with an ISO code. If omitted, the system guesses the language from the script, defaulting to English for Latin text. For non-English Latin-script text, explicitly setting the language parameter ensures accurate synthesis and avoids incorrect language detection.
Is SSML supported for emphasis and pauses?
No, SSML is not supported. The API accepts plain text input only. There are no tags for emphasis, pauses, or pronunciation adjustments. You must rely on the natural intonation of the eight available voice presets to convey tone and pacing without additional markup instructions or custom lexicons.
What happens if I exceed the rate limit?
The rate limit is 60 requests per minute per key. If you exceed this, requests may queue or fail. Failed requests are free, so you are not charged for them. Requests are processed sequentially, so under load, a request may wait in a queue before processing.
Can I generate audio in multiple formats simultaneously?
No, each request generates a single audio file in one format. You can choose from mp3, wav, opus, flac, or pcm per request. To get multiple formats, you must send separate requests for each desired format. The API does not bundle multiple formats into a single response payload.
Do I need to handle text splitting for long books?
Yes, you must handle text splitting for texts longer than 4096 characters. You need to split the input into chunks of up to 4096 characters, generate audio for each chunk, and then join the audio files. This ensures compliance with the per-request character limit while producing a complete audio file.
Is the API available via WebSocket?
No, the API is available via standard HTTP POST requests. There is no WebSocket endpoint for real-time streaming or partial audio delivery. You send text via JSON body and receive the complete audio file in the response. This synchronous model simplifies integration but requires waiting for synthesis to complete.
How do I rotate my API key?
You can issue a new API key at any time from your account dashboard. When a new key is issued, the old one stops working immediately. This allows you to rotate keys without downtime. You only have one active key per account, so ensure you update your applications to use the new key.
What is the base URL for the API?
The base URL for the API is https://api.huaylan.cc/v1. You use this endpoint for all requests, including the speech generation endpoint at /v1/audio/speech. This URL is compatible with the official OpenAI SDKs if you configure them to point to this base URL instead of the default OpenAI endpoint.
Are there SDKs for other languages like Ruby or Go?
There is no official SDK of our own; you can use the OpenAI SDK or any standard HTTP client. You can use any HTTP client to interact with the API. The request shape matches the OpenAI speech endpoint, so you can use any library that supports standard HTTP POST requests with JSON bodies to integrate with this API effectively.
Can I use a custom domain for the API?
The API is hosted exclusively at https://api.huaylan.cc/v1. There is no option to configure a custom domain name for your account or requests. All traffic must be directed to the provided Huaylan Audio API domain for authentication and processing.
Do you provide a sandbox environment?
No, there is no separate sandbox environment. You use the same production API endpoint https://api.huaylan.cc/v1 for testing. You can use your free trial credit of $0.50 to test in the live environment (if you signed in with Google). Failed requests are free, allowing you to test without incurring charges for errors during development.
First request
curl
curl https://api.huaylan.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.mp3Python (openai)
from openai import OpenAI
client = OpenAI(base_url="https://api.huaylan.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.huaylan.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 | |
|---|---|
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
Authentication relies on a single active API key passed via the Authorization: Bearer header. This key grants access to all endpoints and is tied to your account balance.
Bearer Token Usage
Include the header Authorization: Bearer tts-... in every request. The key must be valid and active; otherwise, requests return a 401 error.
API Key Management
Each account holds one active key. You can view your current key on the /get-api-key/ dashboard alongside your balance and usage stats.
Key Rotation
Issue a new key via the dashboard at any time. The old key stops working immediately upon generation of the new one, ensuring secure access control.
Rotate keys if you suspect exposure. No downtime occurs during rotation as the new key becomes active instantly.
Endpoints Overview
The API exposes three primary endpoints for managing synthesis and discovering available resources. The core POST /v1/audio/speech endpoint accepts text and parameters to return generated audio files. Developers use GET /v1/voices to list available presets and GET /v1/models to verify engine status.
POST /v1/audio/speech
This is the main endpoint for generating audio. Send a JSON body with model, input, voice, and optional parameters like speed or language. The API returns the audio file directly in the response body.
- Endpoint:
POST https://api.huaylan.cc/v1/audio/speech - Returns audio in the requested format (mp3, wav, opus, flac, pcm).
GET /v1/voices
Returns a list of all available voice presets with their IDs, names, and supported languages. Use this to dynamically populate voice selection menus in your application without hardcoding values.
- Lists all 8 voice presets.
- Includes metadata for language support.
GET /v1/models
Returns the current available models (tts-1 and tts-1-hd). This endpoint helps verify API availability and confirms that both models are operational for synthesis requests.
- Returns
tts-1andtts-1-hd. - Useful for health checks.
Request Parameters
Configure your synthesis requests by selecting the appropriate model, managing input constraints, and tuning voice characteristics. This section details the core parameters required to generate production-ready audio files efficiently.
Model Selection
Choose between tts-1 for standard quality and tts-1-hd for high-definition output. Both models use the same underlying engine and incur identical pricing, allowing you to upgrade quality without changing your billing structure.
Input Text Limits
Each request accepts a maximum of 4096 characters in the input field. For longer texts, split your content into chunks of this size and join the resulting audio files. Note that spaces and punctuation count toward this limit.
Voice and Speed Options
Select one of eight preset voices (e.g., aria, nova, atlas) and adjust the speed parameter between 0.25 and 4.0. Optionally specify a language ISO code (e.g., de for German) to ensure correct synthesis for non-English Latin-script text, as the API defaults to English otherwise.
- 8 voice presets available
- Speed range: 0.25–4.0
- Optional language ISO code
Response Formats
The API returns binary audio data directly in the response body, allowing you to save the file or pipe it into another process. The format is determined by the response_format parameter in your request, supporting standard codecs for web and professional audio workflows.
MP3 Output
MP3 is the default format, offering a balance between file size and quality. It is suitable for web players and general distribution, ensuring broad compatibility across devices and browsers without requiring additional decoding libraries.
WAV Output
WAV provides uncompressed, lossless audio. This format is ideal for professional editing environments, archiving, or when you need to preserve the exact quality of the synthesis without any compression artifacts.
Opus, FLAC, PCM Support
Opus offers high-quality audio at low bitrates, suitable for bandwidth-constrained environments. FLAC provides lossless compression, reducing file size while retaining full quality. PCM returns raw, uncompressed audio samples, useful for low-level processing or specific hardware integrations.
Error Handling
Errors are returned as standard JSON objects with an error field containing a message and type. Understanding these responses helps you handle edge cases like character limits or temporary server queues without breaking your workflow.
Common HTTP Errors
A 401 Unauthorized error occurs if the Bearer token is missing or invalid. A 400 Bad Request indicates malformed JSON or unsupported parameters. These errors return immediately without consuming your character balance.
- 401: Invalid API key or missing Authorization header.
- 400: Malformed JSON body or invalid parameter values.
Rate Limit Errors
Exceeding the limit (60 req/min) returns a 429 Too Many Requests error. New accounts start with a 10 req/min limit until the first top-up. Failed requests do not consume your character balance, but they still count against your rate limit.
- 429: Rate limit exceeded. Retry after the specified time.
- New accounts: 10 requests/minute until top-up.
Invalid Request Body
If the input text exceeds 4096 characters or the voice ID is unknown, a 400 error is returned. The response body includes a detailed message explaining the specific validation failure, allowing you to adjust your payload before retrying.

OpenAI SDK Integration
Since the API mirrors the OpenAI speech endpoint, developers can reuse existing OpenAI SDKs with minimal configuration. By simply pointing the client to the Huaylan base URL, you integrate TTS into your workflow without learning a new library.
Base URL Configuration
Set your SDK's base_url to https://api.huaylan.cc/v1. Ensure your API key is passed via the standard Authorization: Bearer header. This allows direct compatibility with official OpenAI SDKs for Python, Node.js, and other languages.
Code Example
Initialize the client with your key and custom base URL. Pass parameters like model, input, voice, and response_format exactly as you would for OpenAI. The SDK handles the JSON serialization and multipart response parsing automatically.
Parameter Mapping
Map your text to the input field and select from the 8 voice presets available at /v1/voices. Use tts-1 or tts-1-hd for the model. Note that speed ranges from 0.25 to 4.0, and character limits apply per request.
- Use
inputfor text up to 4096 characters. - Set
modelto 'tts-1' or 'tts-1-hd'. - Select
voicefrom the 8 available presets.
Curl Example
The API accepts standard JSON payloads via POST requests. You send your text, select a voice model, and receive an audio file directly in the response body. This makes integration straightforward for audiobook production pipelines.
Below are three practical curl commands demonstrating basic synthesis, speed adjustment, and explicit language specification to ensure correct pronunciation for non-English text.
Basic Request
Send a simple request to generate speech using the default voice.
This command returns an MP3 file by default.
- `curl -X POST https://api.huaylan.cc/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "Hello world", "voice": "nova"}'`
With Speed Control
Adjust the playback speed between 0.25 and 4.0. Useful for creating faster narration for long texts.
The audio file adjusts duration accordingly while maintaining voice quality.
- `curl -X POST https://api.huaylan.cc/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "Fast narration text", "voice": "sage", "speed": 1.5}'`
With Language Code
Explicitly set the language ISO code to avoid guessing errors, especially for Latin-script languages other than English.
This ensures correct pronunciation for specific linguistic nuances.
- `curl -X POST https://api.huaylan.cc/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "Bonjour le monde", "voice": "aria", "language": "fr", "response_format": "mp3"}'`
Rate Limits and Quotas
Rate limits are enforced per API key. Under normal conditions, you can make 60 requests per minute. Each request processes one text segment up to 4,096 characters, ensuring consistent throughput for batch audiobook generation.
60 Requests Per Minute
Once your account is funded, the standard limit allows 60 synthesis requests per minute. This capacity supports steady production workflows for indie authors and small publishing teams without requiring enterprise-grade infrastructure.
10 Requests Before Top-Up
New accounts start with a restricted limit of 10 requests per minute until the first top-up is processed. This ensures minimal overhead for testing while you configure your integration with the $0.50 trial credit or initial USDT deposit.
Queue Behavior
Requests are processed one after another, so under load a request may wait in a queue. This ensures audio quality remains consistent, though generation time for short phrases may increase slightly during peak usage.
- Requests are processed one after another.
- Queuing occurs under high load or limit exceedance.
- No priority tiers; all requests follow FIFO order.
Listen to the 8 voices
Each sample below was generated by this API from the same sentence. Any voice can speak any supported language, offering flexibility without needing separate voice models per region.
23 languages
Any voice speaks any of these languages.
