TTS API Documentation for JavaScript Developers

By AccessiVoices editorial team · Updated 2026-11-19

This guide provides the essential documentation for integrating AccessiVoices’ text-to-speech API into JavaScript applications. It covers authentication, endpoint usage, and parameter configuration, ensuring product teams can generate clear, accessible audio for users with dyslexia and reading difficulties. You will find concrete examples for standard HTTP requests and OpenAI SDK compatibility.

Designed for developers, the page details request limits, error handling, and advanced features like speed adjustment and language specification. By following these steps, you can reliably convert text into speech using standard JavaScript workflows, maintaining consistent audio quality without requiring custom voice cloning or proprietary SDKs.

TTS API Documentation for JavaScript Developers

Frequently asked questions

How do I get an API key?

Sign up on https://11bets.cc/get-api-key/ using Google or email. Accounts created via Google receive a $0.50 trial credit valid for 7 days. Email-based accounts start without trial credit. Your key appears on the dashboard, prefixed with 'tts-'. You can issue a new key at any time, which immediately invalidates the old one.

What is the base URL for the API?

The API base URL is https://api.11bets.cc/v1. Use this when configuring your OpenAI SDK or setting the base_url in your client. All requests, including speech synthesis and voice listing, originate from this endpoint. Ensure your Authorization header uses this base URL for proper authentication and routing.

Which models are available?

Two models are available: 'tts-1' and 'tts-1-hd'. Both use the same engine and pricing. Select either model for your requests. The choice does not affect cost or voice quality, as they share the same underlying synthesis engine. Use 'tts-1' or 'tts-1-hd' in your model field.

How do I set the voice?

Include the 'voice' field in your JSON body with one of eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Each voice has a distinct tone, such as warm, upbeat, or neutral. Voices are based on licensed recordings and carry an inaudible synthetic watermark.

Can I use the OpenAI SDK?

Yes. The API request shape matches the OpenAI speech endpoint. Change the SDK's base_url to https://api.11bets.cc/v1 and use your AccessiVoices key. The official OpenAI SDKs work directly without modification. This allows easy integration into existing JavaScript projects using standard client libraries.

What are the rate limits?

Limits are 60 requests per minute per key. Before the first top-up, the limit is 10 requests per minute. Requests are processed sequentially, so load may cause queuing. Failed requests are free. Monitor your usage via the dashboard to stay within bounds.

How do I handle errors?

If synthesis fails, the charge is returned in full. Check your request payload for valid model, voice, and input fields. Ensure text does not exceed 4096 characters. Review the API response status code for details. Failed requests incur no cost, so retrying is safe if the issue is transient.

What formats are supported?

Supported response formats are mp3, wav, opus, flac, and pcm. Specify the desired format in the 'response_format' field of your request. The API returns the audio file directly in the response body. Choose the format that best fits your web application's audio player capabilities.

How do I adjust speed?

Use the 'speed' field to set playback speed between 0.25 and 4.0. The default speed is 1.0. Adjusting speed affects the audio output but not the character count or cost. Set this value in your JSON request body to tailor the speech pace for your users.

How do I specify a language?

Include the 'language' field with an ISO code (e.g., 'en', 'de', 'fr'). If omitted, the system guesses the language from the script, defaulting to English for Latin text. Explicitly setting the language ensures accurate synthesis for non-English Latin-script texts.

What happens if I exceed the limit?

Requests are processed sequentially. If you exceed 60 requests per minute, subsequent requests may wait in a queue or be rejected. This can increase latency, especially for longer texts. Failed requests are free. Monitor your dashboard to track usage and adjust your integration strategy if queuing becomes frequent.

How do I rotate my API key?

Issue a new key from your dashboard at any time. The new key becomes active immediately, and the old key stops working at once. This allows seamless rotation without downtime. Generate a new key whenever needed, such as after a potential security event or routine maintenance.

Is there a WebSocket endpoint?

No. The API uses standard HTTP POST requests. There is no WebSocket endpoint for real-time partial audio or streaming. Audio is returned as a complete file after synthesis. Use HTTP for all interactions, including speech generation and voice listing, via the standard REST interface.

How do I process long texts?

Split text into parts of up to 4096 characters per request. Send each part to the API and join the resulting audio files. This ensures all text is processed within the character limit. Use your application logic to handle splitting and concatenation before or after API calls.

First request

curl

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

AccessiVoices requires a Bearer token for all API requests. Generate your key via the /get-api-key/ page using Google or email authentication.

Include the token in the Authorization: Bearer <key> header. One active key per account ensures secure, straightforward integration.

Generating Your API Key

Generating Your API Key

Create an account on the /get-api-key/ page. Sign up with Google or an email/password pair. The dashboard displays your unique key and current balance.

Bearer Token Usage

Bearer Token Usage

Pass your key as a Bearer token in the HTTP Authorization header. The API validates this token for every request to https://api.11bets.cc/v1.

  • Format: Authorization: Bearer tts-...
  • Include in all POST and GET requests.

Key Rotation Policy

You can issue a new key at any time from your dashboard. The old key becomes inactive immediately upon generation, ensuring no concurrent usage conflicts.

Endpoint Overview

Sound wave illustration for: Endpoint Overview

The API exposes three primary endpoints for generating audio and managing resources. The speech endpoint accepts text and configuration to return audio files, while the voices and models endpoints provide metadata for integration.

Speech Generation Endpoint

Send a POST request to /v1/audio/speech with your text and voice selection. The API processes the input and returns the synthesized audio file in the requested format. This is the core endpoint for converting text to speech.

  • Endpoint: POST /v1/audio/speech
  • Returns: Audio file (mp3, wav, opus, flac, or pcm)

Voices Listing Endpoint

Retrieve available voices, languages, and formats via GET /v1/voices. This endpoint provides the list of eight presets (e.g., aria, nova, felix) and their supported languages, allowing your application to dynamically update voice selection options.

  • Endpoint: GET /v1/voices
  • Returns: Voice ID, name, gender, and supported languages

Models Endpoint

Query GET /v1/models to list available models.

  • Endpoint: GET /v1/models
  • Returns: Model ID and object type

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts two model variants, tts-1 and tts-1-hd, which use the same underlying engine and pricing tier. You select the model via the model parameter in your JSON payload. Both deliver consistent audio quality, with no functional difference in voice generation.

Input text is limited to 4096 characters per request, with spaces and punctuation counted toward the total. For longer content, split your text into chunks and concatenate the resulting audio files. The API processes requests sequentially, so queue times may occur during high load, though typical generation speed approximates real-time playback.

Model Selection

Choose between tts-1 and tts-1-hd. Both models use identical voice engines and pricing. The model field does not affect voice characteristics, speed, or output format options.

  • tts-1: Standard model
  • tts-1-hd: High-definition model
  • Same pricing: $10 per 1M characters
  • Same voice presets available

Input Text Limits

Send up to 4096 characters per API call. Longer texts require client-side splitting. Each chunk generates a separate audio file that you must join. This approach ensures reliable processing even for extensive documentation or articles.

Note that all characters, including spaces and punctuation, count toward the limit. This affects your billing calculation directly. Plan your chunking strategy to minimize overhead while staying within the single-request constraint.

  • Max 4096 characters per request
  • Spaces and punctuation count
  • Split long texts manually
  • Concatenate output files client-side

Voice Selection

Select one of eight presets using the voice parameter. Voices include female options like Aria and Nova, and male options like Felix and Milo. Each voice supports all 23 listed languages, regardless of the voice’s default style.

If you do not specify a language, the system guesses based on the script. For non-English Latin text, always set the language field explicitly to ensure correct pronunciation. This is critical for accurate accessibility output in multilingual applications.

  • 8 preset voices available
  • Supports 23 languages
  • Explicit language code recommended
  • No custom voice cloning

Response Formats

Sound wave illustration for: Response Formats

The API returns audio in the format specified by the response_format field, allowing you to optimize for file size or playback compatibility. Supported formats include MP3, WAV, Opus, FLAC, and PCM, with each choice affecting bandwidth and decoding requirements differently.

MP3 Output

MP3 is the default and most widely supported format. It offers a good balance between file size and audio quality, making it ideal for general web integration and mobile applications where bandwidth efficiency is important.

WAV Output

WAV provides uncompressed audio, ensuring maximum fidelity without any lossy compression artifacts. This format is suitable for applications requiring high-quality audio for immediate playback or further processing, though it results in larger file sizes compared to compressed formats.

Opus and FLAC Options

Opus provides efficient compression with high quality. FLAC offers lossless compression, preserving audio quality. Both options allow you to tailor storage and transmission costs based on specific needs.

Code Examples

Sound wave illustration for: Code Examples

Generate audio directly from the command line or integrate seamlessly into Node.js applications. The API accepts standard JSON payloads, making it easy to trigger speech synthesis for accessibility features without complex setup. Below are concrete examples for immediate testing and production use.

For quick validation, use cURL to send a request to the speech endpoint. This method is ideal for verifying your API key and understanding the raw response structure before building your integration layer.

cURL Command Example

Use this command to generate a 3-second MP3 clip. Replace YOUR_API_KEY with your actual key. The response returns the audio binary directly to stdout, which you can redirect to a file.

curl -X POST https://api.11bets.cc/v1/audio/speech \

-H "Authorization: Bearer YOUR_API_KEY" \

-H "Content-Type: application/json" \

-d '{"model":"tts-1","input":"Hello, this is a test.","voice":"aria","response_format":"mp3"}' \

-o output.mp3

Node.js Fetch Example

Integrate synthesis into your JavaScript backend using the native fetch API. This example demonstrates sending a POST request and saving the resulting audio buffer to disk.

const response = await fetch('https://api.11bets.cc/v1/audio/speech', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'tts-1-hd', input: 'Accessible text for dyslexic readers.', voice: 'sage', response_format: 'wav' }) }); const buffer = await response.arrayBuffer(); fs.writeFileSync('speech.wav', buffer);

OpenAI SDK Integration

Since the API follows the same request shape as OpenAI, you can use the official OpenAI Node SDK by simply pointing it to our base URL. This allows you to leverage existing SDK features like retries and error handling.

const { OpenAI } = require('openai'); const client = new OpenAI({ apiKey: 'YOUR_API_KEY', baseURL: 'https://api.11bets.cc/v1' }); const audio = await client.audio.speech.create({ model: 'tts-1', voice: 'nova', input: 'Clear narration for web apps.', response_format: 'mp3' });

Code Examples

Rate Limits

Sound wave illustration for: Rate Limits

Rate limits govern how quickly your application can send synthesis requests. Understanding these constraints ensures your users experience consistent audio delivery without unexpected delays or billing surprises.

60 Requests Per Minute

Each API key allows up to 60 requests per minute. This limit applies per key, so a single active key can handle standard batch processing efficiently. If your app generates audio for many users simultaneously, consider this ceiling when designing your request queue.

Initial Limit for New Keys

New keys start with a lower limit of 10 requests per minute until the first top-up is processed. This ensures system stability for new accounts. Once you add funds via USDT (TRC-20), the limit increases to the standard 60 requests per minute.

  • Initial limit: 10 requests/minute
  • Standard limit: 60 requests/minute
  • Limit increases after first top-up

Queue Behavior Under Load

Requests are processed sequentially. Under heavy load, a request may wait in a queue before synthesis begins. Typical speed is roughly real-time (25 characters per second), but short phrases may take a few seconds to generate. Plan your UI accordingly to show loading states during these waits.

Error Handling

Sound wave illustration for: Error Handling

API errors are explicit and actionable. Most failures return standard HTTP status codes with a JSON body detailing the issue, such as invalid input or rate limit violations. Failed synthesis requests are free, so you are not charged for errors, ensuring predictable billing even during integration testing.

Common Error Codes

Use the response status to distinguish between client and server issues. A 400 error indicates malformed JSON or invalid parameters, while a 429 signals you have exceeded the 60 requests per minute limit. Check the error field in the JSON response for a concise description to debug quickly.

  • 400: Invalid request parameters or malformed JSON.
  • 401: Invalid or expired API key.
  • 429: Rate limit exceeded (60 req/min).
  • 500: Internal server error during synthesis.

Handling Timeouts

Longer texts or high queue load may cause delays. The API processes requests sequentially, so short phrases might take a few seconds, while longer texts take time proportional to their length. If the generation takes too long, assume the request is still processing rather than failing immediately.

Retry Logic

Implement exponential backoff for transient 5xx errors or rate limits. Do not retry 4xx errors unless you are fixing the input data. Since failed requests are free, you can safely retry failed synthesis attempts without worrying about duplicate charges.

Advanced Usage

Sound wave illustration for: Advanced Usage

The API offers granular control over audio generation through speed modulation and precise language targeting. These features allow product teams to tailor the listening experience for users with specific cognitive needs or regional preferences.

Speed Adjustment

You can adjust the playback speed between 0.25 and 4.0 times the normal rate. This is useful for users who process text faster or slower than average. The API handles the resampling automatically, maintaining voice quality across the range.

  • Minimum speed: 0.25x
  • Maximum speed: 4.0x
  • Default speed: 1.0x

Language Specification

While the system guesses language from the script, you can explicitly set the language parameter using an ISO code. This prevents misidentification for Latin-script texts that are not English, ensuring accurate pronunciation for the 23 supported languages.

  • Supports 23 languages
  • ISO code parameter available
  • Guessed by script if omitted

Handling Long Texts

Each request accepts up to 4,096 characters. For longer content, split the text into parts, generate audio for each, and join the files. This approach ensures consistent quality and avoids truncation, keeping the output manageable for web players.

  • Max input: 4,096 characters
  • Split and join manually
  • Characters include spaces and punctuation

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. You can use any voice with any language, giving you flexibility in tone without restricting linguistic options.

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. Python documentation
  3. openai-node on GitHub
  4. openai-python on GitHub
  5. OpenAI API reference: create speech
  6. MDN: Web Speech API
  7. LibriTTS-R paper (arXiv 2305.18802)
  8. W3C WAI: making audio and video accessible
  9. ISO 639 language codes
  10. Creative Commons Attribution 4.0
  11. LibriVox public-domain audiobooks
  12. TRON developer hub: TRC-20

More on this site