Comprehensive Developer Guide for Text-to-Speech API Integration

By VoiceLayer editorial team · Updated 2026-11-19

This guide details the integration of the VoiceLayer text-to-speech API, designed for developers powering e-learning platforms and LMS systems. You will find precise specifications for generating audio files from text, including endpoint structures, parameter definitions, and response formats. The documentation covers the complete request lifecycle, from authentication setup to error handling, ensuring you can reliably synthesize speech for large student cohorts without infrastructure overhead.

We explain how to use standard OpenAI SDKs by adjusting the base URL to https://api.my36.info/v1, allowing you to leverage familiar libraries for integration. Topics include rate limits, text chunking strategies for long scripts, and language detection nuances. Whether you are building a course generation pipeline or an accessibility feature, this reference provides the concrete technical details needed for production-ready deployments.

Comprehensive Developer Guide for Text-to-Speech API Integration

Frequently asked questions

How do I get an API key?

Sign up on the /get-api-key/ page using Google or email plus password. The dashboard displays your active API key, balance, and usage statistics. You can issue a new key at any time, which immediately invalidates the previous one. Each account is tied to a specific site.

What is the base URL for the API?

The API base URL is https://api.my36.info/v1. You send POST requests to https://api.my36.info/v1/audio/speech. Other endpoints like /v1/voices and /v1/models are also available at this base path for retrieving voice details and model information.

Which SDKs are compatible?

The request shape matches the OpenAI speech endpoint. Therefore, official OpenAI SDKs work by changing the base_url to https://api.my36.info/v1 and using your site-specific key. You can also use plain HTTP requests without any specific vendor SDK.

What is the character limit per request?

Each request supports a maximum of 4096 characters in the input field. For longer texts, you must split the content into chunks of up to 4096 characters. After generating audio for each part, you join the resulting audio files to create the final output.

How do I handle rate limits?

The limit is 60 requests per minute per key. Before your first top-up, the limit is 10 requests per minute. Failed requests are free. Monitor your usage in the dashboard to avoid throttling during high-volume generation.

What happens if the API is slow?

Requests are processed sequentially, so under load, a request may wait in a queue. Typical speed is roughly real-time, but short phrases take a few seconds. Longer texts generate at about 25 characters per second. Patience is required during peak usage times.

Can I use the OpenAI Python SDK?

Yes, the OpenAI Python SDK is compatible. You must configure the base_url to https://api.my36.info/v1 and provide your API key. The endpoint structure for speech generation is identical to OpenAI’s, allowing you to use standard methods with minimal code changes.

How do I specify a voice?

Include the voice parameter in your JSON body with one of eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. These voices are based on licensed recordings. You can retrieve the full list of available voices via the GET /v1/voices endpoint.

What is the default response format?

You can specify the response format using the response_format field. Supported formats include mp3, wav, opus, flac, and pcm. If not specified, the behavior depends on the client implementation.

How do I detect the language?

If the language field is omitted, the system guesses it from the script. Latin script defaults to English. For non-English Latin text, you must explicitly set the language parameter to an ISO code. Supported languages include Arabic, Chinese, French, German, and others.

Can I change the speed of the voice?

Yes, use the speed parameter to adjust playback speed between 0.25 and 4.0. This allows you to slow down narration for clarity or speed up content for quick reviews. The value is a float representing the multiplier relative to normal speech speed.

Is the API RESTful?

Yes, it is a standard RESTful API. You use POST for speech generation and GET for retrieving voices and models. Authentication is handled via the Authorization header. The endpoints follow standard HTTP methods and return JSON responses with audio data in the specified format.

How do I handle errors in my code?

Check the HTTP status code and response body for error details. Failed synthesis requests are free, and the charge is returned in full. Implement retry logic for temporary issues, but be mindful of the 60 requests per minute rate limit to avoid throttling.

Can I use this with JavaScript?

Yes, you can use plain JavaScript fetch API or any HTTP library. Configure the base_url to https://api.my36.info/v1 and send a POST request with your JSON payload. Include the Authorization header with your Bearer token to authenticate the request successfully.

First request

curl

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

Authentication relies on a single active Bearer token per account, issued directly from the /get-api-key/ page. You can sign up via Google or email to access this dashboard, which displays your current key, balance, and usage statistics.

API Key Generation

API Key Generation

Keys are generated on the /get-api-key/ page. Each account maintains only one active key at a time. If you generate a new key, the previous one stops working immediately, ensuring secure access control without complex permission layers.

Bearer Token Usage

Bearer Token Usage

Include your key in the Authorization header as Bearer tts-... for every request. This simple standard works seamlessly with the OpenAI SDK by setting the base URL to https://api.my36.info/v1. No additional authentication headers are required.

Key Rotation

Rotate your key anytime from the dashboard. The transition is instantaneous; the old key becomes invalid the moment the new one is issued. This allows you to revoke compromised credentials without waiting for manual approval or processing delays.

Endpoints

Sound wave illustration for: Endpoints

The API exposes three core endpoints for managing speech synthesis. The primary endpoint handles audio generation, while the others provide metadata about available voices and model configurations. All endpoints require valid authentication via the Bearer token.

Speech Generation

Send a POST request to /v1/audio/speech with your text and selected voice parameters. The endpoint returns the audio file directly in the requested format, such as mp3 or wav. Ensure the input text does not exceed 4096 characters per request to avoid truncation.

  • Endpoint: POST /v1/audio/speech
  • Accepts JSON body with model, input, voice, and speed
  • Returns audio file in response body

Voice Listing

Use GET /v1/voices to retrieve a list of all available voice presets, their associated languages, and supported formats. This endpoint allows developers to dynamically populate dropdown menus in their applications, ensuring they select valid voice IDs before making synthesis requests.

  • Endpoint: GET /v1/voices
  • Returns voice ID, name, gender, and supported languages
  • Includes format and pricing details for each voice

Model Details

The GET /v1/models endpoint provides details about the underlying TTS models, specifically 'tts-1' and 'tts-1-hd'. Both models use the same engine and pricing structure, offering flexibility in quality selection without affecting cost. This endpoint helps verify model availability and specifications.

  • Endpoint: GET /v1/models
  • Lists available models: tts-1 and tts-1-hd
  • Includes model metadata and pricing equivalence

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts text input up to 4096 characters per request, with spaces and punctuation counting toward the limit. For longer course content, split the text into chunks and join the resulting audio files seamlessly.

Input Text Limits

Each request handles a maximum of 4096 characters. Exceeding this limit returns an error. To generate audio for lengthy lectures, divide the script into manageable segments and concatenate the output files.

Voice Selection

Choose from eight presets: Aria, Nova, Luna, Sage, Felix, Milo, Atlas, or Orion. Every voice supports all 23 listed languages. If the language field is omitted, the system guesses from the script, defaulting to English for Latin text.

  • 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 Control

Adjust playback speed between 0.25 and 4.0. Faster speeds compress delivery for quick reviews, while slower speeds aid comprehension for language learners. The default speed provides a natural, balanced pace suitable for most educational materials.

Response Formats

Sound wave illustration for: Response Formats

The API returns synthesized audio in the requested format via the response_format parameter. MP3 provides efficient compression suitable for web delivery, while WAV offers uncompressed PCM audio for direct integration into audio editors or learning management systems without quality loss.

MP3 Output

MP3 is a supported format, offering a balance between file size and audio fidelity. This format is suitable for embedding in course modules where bandwidth efficiency matters for large student cohorts.

WAV Output

WAV provides uncompressed, high-quality audio data. Use this format when you need raw audio files for post-production editing, quality assurance checks, or integration with systems that prefer standard PCM wave files over compressed codecs.

Lossless Formats

FLAC and OPUS are available for specialized use cases. FLAC provides lossless compression for archival purposes, while OPUS offers efficient compression suitable for voice-centric applications. PCM is also supported for raw data processing pipelines.

OpenAI SDK Integration

Sound wave illustration for: OpenAI SDK Integration

VoiceLayer is compatible with the official OpenAI SDKs. By overriding the base_url to https://api.my36.info/v1, developers can use the same client structure they already know. This eliminates the need to learn a proprietary library or write custom HTTP wrappers for basic speech synthesis.

The SDK handles the JSON request body and binary audio response transparently. You only need to provide your API key and configure the endpoint. This approach ensures that the request shape remains compatible with the OpenAI SDKs.

Base URL Configuration

Set the base_url parameter in your SDK client to https://api.my36.info/v1. This directs all requests to VoiceLayer’s infrastructure while maintaining standard OpenAI request shapes. Ensure your Authorization header includes your tts-... key.

SDK Compatibility

The official OpenAI SDKs work directly with this API. No custom client is required. The request payload matches the OpenAI speech endpoint exactly, including support for model, input, voice, response_format, and speed parameters.

Code Examples

  • Use openai.OpenAI(base_url='https://api.my36.info/v1', api_key='tts-...') to initialize the client.
  • Call client.audio.speech.create() with standard parameters like model='tts-1' and voice='nova'.
  • Handle the binary response to save audio files directly to your LMS media library.
OpenAI SDK Integration

Rate Limits

Sound wave illustration for: Rate Limits

The API enforces a strict limit of 60 requests per minute per active key. Before your first top-up, this allowance is reduced to 10 requests per minute. These limits apply to the POST /v1/audio/speech endpoint specifically.

Requests Per Minute

Each request counts toward the 60 RPM quota. If you exceed this threshold, subsequent requests will be rejected until the window resets. New accounts without a top-up start with a lower limit of 10 requests per minute.

Queue Behavior

Requests are processed sequentially. Under load, a request may wait in a queue before synthesis begins. For long texts split into multiple parts, each part is processed one after another, which can extend total generation time.

Burst Handling

To avoid rejection during high-volume course creation, batch your requests carefully. Since shorter phrases take a few seconds and long texts generate at roughly real-time speed, plan your API calls to stay within the 60 RPM or 10 RPM limit depending on your account status.

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate success or failure. Understanding these responses helps you quickly identify whether a request was processed, rejected due to validation errors, or failed during synthesis.

Common Error Codes

Use 400 for invalid parameters (e.g., voice not found), 401 for authentication issues, and 429 when you exceed the 60 requests per minute limit. Failed synthesis returns a 500-series error with a descriptive message.

  • 400: Bad Request (invalid JSON or missing fields)
  • 401: Unauthorized (invalid or expired API key)
  • 429: Too Many Requests (rate limit exceeded)
  • 500: Internal Server Error (synthesis failure)

Retry Logic

Implement exponential backoff for 429 and 500 errors. Since requests are processed sequentially, brief waits often resolve queue congestion. Failed requests are free, so retrying does not incur extra charges if the error persists.

  • Wait 1 second, then 2, then 4 seconds before retrying.

Debugging Tips

Check the response body for detailed error messages. Verify that your API key is correct and that the input text does not exceed 4096 characters. Ensure the Authorization header uses the Bearer scheme correctly.

Best Practices

Sound wave illustration for: Best Practices

Optimizing your integration ensures reliable audio delivery for large student cohorts without unnecessary latency or errors. By adhering to specific limits and configuration rules, you can maintain consistent quality across your e-learning platform.

Text Chunking

Split input text into segments of up to 4,096 characters. Concatenate the resulting audio files to handle longer course materials efficiently.

  • Maximum 4096 characters per request
  • Join audio files sequentially for longer content

Language Detection

Set the language parameter explicitly for non-English Latin-script text to ensure accurate pronunciation. Without it, the API defaults to English for Latin characters.

  • Default to English for Latin script
  • Explicitly set ISO code for other languages

Audio Quality

Use tts-1-hd for higher fidelity or tts-1 for standard quality. Choose WAV or FLAC for lossless storage, or MP3/OPUS for efficient delivery.

  • Select model based on quality needs
  • Use lossless formats for archival

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. The raw text you submit is processed in real-time to produce the audio output.

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. curl documentation
  3. openai-python on GitHub
  4. TRON developer hub: TRC-20
  5. openai-node on GitHub
  6. LibriTTS-R paper (arXiv 2305.18802)
  7. Creative Commons Attribution 4.0
  8. FFmpeg documentation
  9. IETF RFC 7845: Ogg Opus
  10. Python documentation
  11. MDN: Web Speech API
  12. Tether (USDT)

More on this site