Speech API Documentation for JavaScript Developers

By LinguaCode editorial team · Updated 2026-11-19

This documentation outlines the JSON API for generating speech audio from text, designed for JavaScript developers integrating SonoSpeak into language learning platforms. You will find precise specifications for authentication, request parameters, and response handling, enabling seamless integration with existing educational tools.

The guide covers the speech synthesis endpoint, the voices endpoint, and supported audio formats. It includes ready-to-use JavaScript examples using the native fetch API and the OpenAI SDK, ensuring you can quickly implement pronunciation drills and accessible content generation.

Speech API Documentation for JavaScript Developers

Frequently asked questions

How do I get an API key?

Sign up on https://iclub88.cc/get-api-key/ using Google or email. Your key starts with 'tts-'. One active key per account; issuing a new one invalidates the old immediately. Keys are used in the Authorization header as 'Bearer tts-...'. Accounts are per site.

What is the base URL?

The API base URL is https://api.iclub88.cc/v1. All requests, including speech synthesis and voice listing, use this domain. For OpenAI SDK compatibility, set your base_url configuration to this address. The speech endpoint is POST https://api.iclub88.cc/v1/audio/speech.

Can I use the OpenAI SDK?

Yes. The request shape matches the OpenAI speech endpoint. Configure your OpenAI SDK client to use base_url https://api.iclub88.cc/v1 and provide your SonoSpeak API key. This allows you to use standard OpenAI JavaScript libraries without custom HTTP client code.

How do I specify a language?

Pass the optional 'language' field with an ISO code. If omitted, the system guesses from the script, defaulting to English for Latin text. For non-English Latin-script text, explicitly set the language to ensure correct pronunciation. Supported languages include English, Spanish, German, and others.

What is the character limit per request?

Each request supports up to 4096 characters in the 'input' field. Spaces and punctuation count toward this limit. If your text exceeds this, you must split it into smaller chunks and join the resulting audio files manually in your application logic.

How do I handle long texts?

Split your input text into segments of 4096 characters or fewer. Send each segment in a separate POST request to the speech endpoint. Concatenate the returned audio files in your application to create the final output. This ensures compliance with the per-request character limit.

What is the speed range?

You can adjust the 'speed' parameter between 0.25 and 4.0. The default speed is 1.0. Values below 1.0 slow down the speech, while values above 1.0 increase the pace. This applies to all voices and languages supported by the API.

Can I change the voice after sending?

No. The voice is determined by the 'voice' field in the request body (e.g., 'nova', 'felix'). Once the request is processed, the audio is generated with that specific voice. You cannot modify the voice of an already generated audio file via the API.

Is SSML supported?

No, SSML is not supported. The API accepts plain text in the 'input' field. You cannot use SSML tags for pauses, emphasis, or pronunciation changes. For custom pronunciation, you must rely on the standard spelling of the text provided in the input.

How do I handle errors?

Check the HTTP status code and response body for error details. Failed synthesis requests are free, and charges are returned in full. Common errors include invalid API keys, rate limits, or invalid parameters. Implement retry logic with exponential backoff for transient network issues.

What happens if I exceed the rate limit?

The limit is 60 requests per minute per key (10 per minute before the first top-up). Exceeding this results in HTTP 429 errors. Requests are processed sequentially, so high load may cause queuing delays. Monitor your usage via the dashboard to avoid throttling.

Can I use the API in the browser?

Yes, you can call the API directly from browser JavaScript. Since it uses standard HTTP POST requests, you can send text and receive audio blobs. Ensure you protect your API key if exposing it in client-side code.

Is the API key secret?

Yes, treat your API key as a secret. It authenticates all requests to your account. Anyone with the key can use your balance. You can issue a new key at any time, which immediately invalidates the old one, allowing you to revoke access instantly.

How do I test the API?

Use the curl example on the /get-api-key/ page. Send a POST request to https://api.iclub88.cc/v1/audio/speech with a short text input. Verify you receive an audio file in the requested format. Check your balance and usage metrics in the account dashboard.

First request

curl

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

Sound wave illustration for: Authentication

Access the SonoSpeak API using a Bearer token generated from your account dashboard. Each account holds one active key at a time, ensuring simple authentication for language learning integrations.

API key format

API key format

Your API key starts with the prefix tts- followed by a unique string of characters. This key is issued when you sign in via Google or email on the /get-api-key/ page.

  • Keys begin with tts-
  • One active key per account
  • Visible in your dashboard

Bearer token usage

Bearer token usage

Include the key in the HTTP header as Authorization: Bearer tts-.... This standard format works with both the official OpenAI SDK (by changing base_url) and plain fetch calls.

Key rotation

You can issue a new key at any time from your dashboard. The previous key stops working immediately.

Endpoint: POST /v1/audio/speech

Sound wave illustration for: Endpoint: POST /v1/audio/speech

The core synthesis endpoint is POST https://api.iclub88.cc/v1/audio/speech. Send a JSON body containing the text and configuration parameters. The API processes the request and returns the generated audio file directly in the response body.

Text input is limited to 4,096 characters per request. For longer content, split the text into chunks, generate audio for each, and concatenate the files.

Request body structure

The request body is a standard JSON object. It mirrors the structure used by the OpenAI speech endpoint, allowing you to reuse existing integration code by simply changing the base_url to https://api.iclub88.cc/v1.

Required fields

You must provide the model and input fields. The model accepts either tts-1 or tts-1-hd, which use the same engine and pricing. The input field contains the text string to be synthesized.

  • model: "tts-1" or "tts-1-hd"
  • input: text string (max 4096 characters)
  • voice: one of the 8 available presets

Optional parameters

Adjust audio properties using optional fields. Set response_format to mp3, wav, opus, flac, or pcm. Use speed to adjust playback rate between 0.25 and 4.0. Specify language with an ISO code to ensure correct pronunciation, especially for non-English Latin script text.

  • response_format: mp3, wav, opus, flac, pcm
  • speed: 0.25–4.0
  • language: optional ISO code

Models: tts-1 and tts-1-hd

Sound wave illustration for: Models: tts-1 and tts-1-hd

Both tts-1 and tts-1-hd use the same synthesis engine and are priced identically at $10 per million characters. There is no performance or quality difference between them; they generate audio with the same accuracy and latency characteristics.

Same engine and price

Since the underlying model is identical, switching between models does not affect audio fidelity or processing time. Both support the full range of 8 voices and 23 languages with identical output quality.

Same request shape

The API request structure is exactly the same for both models. You simply swap the model identifier in the JSON body while keeping all other parameters (voice, speed, format) unchanged.

Choosing the right model

Select tts-1 for standard processing or tts-1-hd if your system requires a specific model name for compatibility with existing OpenAI SDK configurations. Functionally, they are interchangeable.

  • Use tts-1 for direct simplicity.
  • Use tts-1-hd if porting from OpenAI configs.
  • Both incur $0.01 per 1,000 characters.
  • Both support 0.25–4.0 speed range.

Voices and Languages

Sound wave illustration for: Voices and Languages

Select from eight preset voices. Each voice supports all 23 languages without modification, ensuring consistent pronunciation for language learning drills.

The API supports 23 languages including Arabic, Chinese, English, French, German, Hindi, Japanese, Korean, Spanish, and more. Any voice can speak any supported language, allowing flexible voice assignment regardless of the target language.

voices

8 preset voices

Choose from eight distinct voice presets optimized for clarity and pedagogical use. Female voices include Aria (warm, clear narrator), Nova (bright, upbeat), Luna (soft, storytelling), and Sage (calm, instructional). Male options feature Felix (energetic, promo), Milo (friendly, conversational), Atlas (neutral, news), and Orion (deep, documentary). All voices are based on licensed LibriTTS-R recordings.

voices

23 supported languages

The API supports 23 languages: Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, and Turkish. Unsupported languages include Vietnamese, Indonesian, Thai, Ukrainian, Romanian, Czech, and Bengali.

Language code handling

Pass the ISO language code in the request to ensure correct pronunciation. If omitted, the API guesses the language from the script; Latin script defaults to English. For non-English Latin text, always set the language parameter explicitly.

Response Formats

Sound wave illustration for: Response Formats

The API returns audio in five standard formats: MP3, WAV, OPUS, FLAC, and PCM. Select the format that best fits your language learning platform’s playback requirements. MP3 offers efficient compression for web delivery, while WAV and FLAC provide lossless quality. PCM is available for raw audio processing.

MP3, WAV, OPUS, FLAC, PCM

Choose MP3 for balanced size and quality in web applications. Use WAV or FLAC when precise audio analysis is needed for educational tools. OPUS provides high efficiency for bandwidth-constrained environments. PCM delivers uncompressed audio for maximum compatibility with legacy systems.

  • MP3: Compressed, ideal for web streaming and general playback.
  • WAV: Lossless, uncompressed, suitable for detailed audio analysis.
  • OPUS: High compression efficiency, good for low-bandwidth scenarios.
  • FLAC: Lossless compression, preserves audio quality without file bloat.
  • PCM: Raw uncompressed audio.

Streaming audio not supported

The API does not support streaming or WebSocket connections. Audio is generated fully before being returned in the response body. For long texts, split the input into chunks of 4096 characters or less to manage processing time effectively. Each chunk is processed sequentially.

Audio in response body

The synthesized audio is embedded directly in the HTTP response body. Use the OpenAI JavaScript SDK or the native fetch API to handle binary data. The SDK automatically parses the response, while fetch requires manual handling of the response stream to obtain the audio buffer.

Response Formats

Rate Limits

Sound wave illustration for: Rate Limits

The API enforces a strict rate limit of 60 requests per minute per key. Since requests are processed sequentially, longer texts or high-volume drills may queue, causing latency. This limit applies uniformly regardless of the model chosen.

New accounts start with a reduced limit of 10 requests per minute until the first top-up is processed. This ensures stable performance for initial testing before scaling to full production volume.

60 requests per minute

Each API key allows up to 60 concurrent or queued requests within a one-minute window. If your language learning platform sends multiple pronunciation drills simultaneously, requests may wait in line. Typical generation speed is roughly real-time, so processing 4096-character texts takes time, potentially filling the queue faster than the limit allows.

10 requests before top-up

Upon account creation, you are restricted to 10 requests per minute. This applies even if you have sufficient balance. The limit lifts automatically once your first top-up is credited, usually within minutes of the TRON network transfer.

Handling rate limits

When the limit is reached, the API returns a 429 Too Many Requests error. Implement exponential backoff in your JavaScript client to retry after a short delay. Since failed requests are free, ensure your retry logic does not penalize your balance for transient throttling.

  • Check X-RateLimit-Remaining header
  • Implement exponential backoff
  • Retry on 429 status

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate request success or failure. Understanding these codes helps you implement robust retry logic in your language learning tools without unnecessary delays or wasted credits.

Failed synthesis attempts are refunded automatically. If the server cannot process your text due to internal errors or timeout, you are not charged, ensuring accurate billing for your educational platform.

Common error codes

Use 4xx codes for client-side issues like invalid keys or malformed JSON. Use 5xx codes for temporary server issues that may resolve on retry.

  • 400 Bad Request: Invalid JSON or missing required fields.
  • 401 Unauthorized: Invalid or expired API key.
  • 429 Too Many Requests: Exceeded 60 requests per minute limit.
  • 500 Internal Server Error: Temporary processing failure; retry recommended.

Failed request refunds

If synthesis fails completely, the character count is not deducted from your balance. Check the response body for error details to confirm the charge was reversed.

Debugging tips

Verify the input text length does not exceed 4096 characters. Ensure the voice and model parameters match the supported presets. Use the /v1/voices endpoint to confirm available voices.

JavaScript Code Example

Sound wave illustration for: JavaScript Code Example

JavaScript developers can integrate SonoSpeak’s TTS API using standard fetch or the OpenAI SDK, adapting the base URL to https://api.iclub88.cc/v1. Both methods support the same JSON request body, allowing seamless switching between libraries for pronunciation drills or reading practice.

Audio responses are returned as binary data in the response body. Developers must handle these bytes correctly, either by converting them to Base64 for web playback or saving them directly to files for educational content libraries.

Using fetch API

Use the native fetch API to send a POST request to the speech endpoint. Include the Authorization: Bearer header with your API key and specify the model, voice, and input text in the JSON body. The response contains the audio binary.

  • Endpoint: POST https://api.iclub88.cc/v1/audio/speech
  • Header: Authorization: Bearer tts-your-api-key
  • Body: JSON with model, voice, input, and response_format

Using OpenAI SDK

Install the openai npm package and initialize the client with baseURL: 'https://api.iclub88.cc/v1' and your API key. Call client.audio.speech.create() with the same parameters as the REST API. This approach simplifies error handling and type definitions.

  • Initialize: new OpenAI({ apiKey: 'tts-key', baseURL: 'https://api.iclub88.cc/v1' })
  • Method: audio.speech.create({ model: 'tts-1', voice: 'nova', input: 'Hello' })
  • Supports Node.js and browser environments

Handling binary data

The API returns audio data as a binary stream. For web playback, convert the response to a Blob and create an object URL using URL.createObjectURL(). For file storage, write the buffer directly to disk. Note that streaming is not supported, so the entire audio file is returned at once.

  • Convert response to Blob: const blob = await response.blob()
  • Create URL: const audioUrl = URL.createObjectURL(blob)
  • Play audio: new Audio(audioUrl).play()

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Each voice is independent and does not require custom configuration.

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. Python documentation
  4. TRON developer hub: TRC-20
  5. MDN: Web Speech API
  6. FFmpeg documentation
  7. curl documentation
  8. LibriVox public-domain audiobooks
  9. Tether (USDT)
  10. IETF RFC 7845: Ogg Opus
  11. W3C WAI: making audio and video accessible
  12. ISO 639 language codes

More on this site