Text-to-Speech API Documentation and Integration Guide

By Narratex Team · Updated 2026-11-19

This documentation provides a technical reference for integrating the Narratex text-to-speech API into production workflows. It covers authentication, endpoint configuration, request parameters, and response handling for developers building high-volume voice-over generation systems. The guide assumes familiarity with standard HTTP requests and JSON payloads, offering concrete examples for immediate implementation.

Designed primarily for YouTube agencies and production studios, this page details the specific constraints and capabilities of the CG11 infrastructure. You will find precise instructions on managing rate limits, processing long texts, and handling audio formats like MP3, WAV, and FLAC. Use this reference to ensure reliable, predictable audio synthesis at scale.

Text-to-Speech API Documentation and Integration Guide

Frequently asked questions

How do I generate an API key?

Sign up on the /get-api-key/ page using Google or an email and password combination. Your account is specific to this site. The dashboard displays your active API key, which you use for authentication via the Authorization header in your requests.

Can I use the official OpenAI SDK?

Yes. The request shape matches the OpenAI speech endpoint. You can use the official OpenAI SDKs by changing the base_url to https://api.cg11.info/v1 and providing your Narratex API key. This allows for seamless integration into existing codebases without major refactoring.

What is the base URL for the API?

The API base URL is https://api.cg11.info/v1. You send POST requests to https://api.cg11.info/v1/audio/speech for synthesis. Other endpoints include GET /v1/voices and GET /v1/models for retrieving available voices, languages, formats, and pricing information.

What is the maximum input length?

Each request supports up to 4096 characters of input text. For longer texts, you must split the content into parts of this size, send separate requests, and join the resulting audio files. Spaces and punctuation count toward this character limit.

Which models are available?

Two models are available: tts-1 and tts-1-hd. Both use the same engine and pricing structure. You select the model in the request body. The choice does not affect the cost per character or the processing speed.

How do I specify the language?

Include an optional ISO language code in the request body. 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.

What happens if the request fails?

Failed requests are free. If synthesis fails, the charge is returned in full to your account balance. This ensures you only pay for successfully generated audio files. You can retry the request with the same text and parameters.

Is there a WebSocket endpoint?

No. There is no WebSocket endpoint or streaming capability. You must send a POST request and wait for the complete audio file to be returned in the response. The API processes requests sequentially, so latency depends on the queue.

Can I stream audio in real-time?

No. The API does not support real-time partial audio streaming. You receive the full audio file only after synthesis completes. For long texts, you must manage splitting and joining the audio files yourself after receiving each response.

How do I handle rate limits?

The limit is 60 requests per minute per key. Before the first top-up, the limit is 10 requests per minute. Monitor your usage via the dashboard. Implement exponential backoff in your client code to handle throttling during high-volume generation periods.

What formats are supported?

Supported response formats are mp3, wav, opus, flac, and pcm. Specify the desired format in the request body. You can specify the format in the request body.

Do I need to manage connections manually?

No. As a standard REST API, you do not need to manage persistent connections. Each request is independent. You send a POST request with your parameters and authentication header, and the server returns the audio file or an error.

Is the API RESTful?

Yes. The API follows RESTful principles. You use standard HTTP methods like POST for speech generation and GET for retrieving resources like voices and models. Requests are stateless, and authentication is handled via Bearer tokens in the Authorization header.

How do I rotate my API key?

You can issue a new API key at any time via the dashboard. When a new key is generated, the old one stops working immediately. This ensures that only the current key is active, enhancing security without downtime.

First request

curl

curl https://api.cg11.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.cg11.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.cg11.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 and Keys

Sound wave illustration for: Authentication and Keys

Authenticate requests by including your API key in the HTTP header as Authorization: Bearer tts-.... This key identifies your account for billing and rate-limiting purposes. Ensure the token is sent with every POST request to the speech endpoint.

Bearer Token Usage

Bearer Token Usage

Include the header Authorization: Bearer <your_key> in all API calls. The key remains valid until revoked or replaced. Do not expose the key in client-side code if the endpoint is accessible from browsers.

Key Rotation Policy

Key Rotation Policy

You may issue a new key at any time via the dashboard. The old key stops working immediately upon issuance of the new one, ensuring no overlap in active credentials.

  • Issue new keys instantly
  • Old keys invalidate immediately
  • No grace period

Single Active Key Rule

Each account maintains exactly one active key. Generating a new key replaces the current one entirely. This simplifies access control and auditing for agency workflows.

  • One key per account
  • Immediate replacement
  • Simplified auditing

Endpoint Configuration

Sound wave illustration for: Endpoint Configuration

The API operates on a strict cloud infrastructure. All synthesis requests are sent to a single endpoint, while metadata and voice listings are accessible via separate GET routes. This separation ensures predictable routing for high-volume agency workflows.

Configuration requires minimal changes to existing HTTP clients. By adjusting the base URL, developers can leverage standard OpenAI SDKs without rewriting core logic, maintaining compatibility with established integration patterns.

Speech Endpoint URL

All audio generation requests must be sent via POST to https://api.cg11.info/v1/audio/speech. This endpoint accepts JSON bodies containing the model, input text, voice selection, and output format parameters.

Base URL Modification

To use the official OpenAI SDKs, set the base URL to https://api.cg11.info/v1. This allows the use of standard client libraries by simply updating the API key in your configuration.

SDK Compatibility

The request shape mirrors the OpenAI speech endpoint. Standard HTTP clients and OpenAI-compatible SDKs work out of the box. No proprietary client library is required for basic integration.

For voice discovery, use GET /v1/voices. Model details are available via GET /v1/models. These endpoints return JSON arrays of available voices and technical specifications.

  • POST https://api.cg11.info/v1/audio/speech
  • GET https://api.cg11.info/v1/voices
  • GET https://api.cg11.info/v1/models
  • Base URL: https://api.cg11.info/v1

Request Parameters

Sound wave illustration for: Request Parameters

Configure the synthesis request by specifying the model, input text, voice, and optional language. The API accepts two model variants with identical pricing and engine performance.

Model Selection

Select either tts-1 or tts-1-hd for the model field. Both utilize the same underlying engine and incur the same charge of $0.01 per 1,000 characters. There is no functional difference in audio quality between the two identifiers for standard API usage.

Input Text Limits

Pass the source text in the input field, limited to 4096 characters per request. Spaces and punctuation count toward this limit. For longer scripts, your application must split the text into chunks and join the resulting audio files sequentially.

Voice and Language Codes

Assign one of eight voice presets (e.g., aria, nova, felix) to the voice parameter. Each voice supports all 23 listed languages. If the language field is omitted, the system guesses the language, defaulting to English for Latin script. Explicitly set the language code (e.g., de, fr) for non-English Latin text to ensure accuracy.

  • Supported voices: aria, nova, luna, sage, felix, milo, atlas, orion
  • Supported formats: mp3, wav, opus, flac, pcm
  • Speed range: 0.25 to 4.0

Response Formats

Sound wave illustration for: Response Formats

The API returns the synthesized audio as a binary response body. Content-Type headers indicate the specific codec used. Clients must handle the raw bytes directly without parsing JSON wrappers for the audio data itself.

Audio File Delivery

Audio files are delivered immediately upon synthesis completion. The response body contains only the audio data. No additional metadata is included in the binary stream.

Supported Codecs

Select your preferred format via the response_format parameter. Available options include mp3, wav, opus, flac, and pcm. Each format serves different storage and playback needs.

  • mp3: Standard compressed audio for web delivery
  • wav: Uncompressed lossless audio for editing
  • opus: High efficiency format
  • flac: Lossless compression for archiving
  • pcm: Raw uncompressed linear audio

Binary Stream Handling

Clients should read the response stream directly. Do not attempt to parse the binary data as JSON. Ensure your HTTP client supports large binary payloads for long-text generations.

Rate Limits and Throttling

Sound wave illustration for: Rate Limits and Throttling

Rate limits are enforced per API key, not per account or IP. Under normal conditions, each key supports 60 requests per minute. This limit applies to all synthesis attempts, regardless of text length or voice selected. Requests are processed sequentially, meaning complex or long-text jobs may occupy the quota for longer durations.

60 Requests Per Minute

The standard limit is 60 requests per minute per active key. If you exceed this threshold, the API returns an error indicating the limit has been reached. Ensure your integration handles this response by implementing exponential backoff or queuing logic to avoid wasting characters on failed attempts.

Pre-Payment Limit

New accounts without a top-up start with a reduced limit of 10 requests per minute. This applies immediately upon key generation. The limit increases to 60 requests per minute once you add funds.

Queue Behavior

Requests are processed in the order received. Under high load, synthesis jobs may wait in a queue before processing begins. This can increase latency for long texts, as each part is generated sequentially. Plan your submission timing accordingly to maintain predictable delivery speeds.

Rate Limits and Throttling

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate request success or failure. Clients must parse these codes to determine if audio generation completed or if an error occurred during processing.

Common Error Codes

A 400 error indicates invalid parameters, such as exceeding the 4096 character limit or using an unsupported voice. A 401 error signifies an invalid or expired authentication key. A 429 error means the rate limit of 60 requests per minute has been exceeded.

  • 400: Bad Request
  • 401: Unauthorized
  • 429: Too Many Requests

Retry Logic

Implement exponential backoff for transient errors (5xx) and rate limits (429). Do not retry 400 errors without modifying the request body, as they indicate a client-side configuration issue.

Billing Disputes

Failed synthesis requests are free, and any charge is returned in full. If a request succeeds but audio is defective, contact support via email. Reference the request timestamp and key in your inquiry.

Long Text Processing

Sound wave illustration for: Long Text Processing

Long-form content exceeds the 4096-character limit per request. The client must split input text into sequential chunks, ensuring each segment stays within the boundary while preserving linguistic coherence.

Character Splitting

Split text into segments of up to 4096 characters. Spaces and punctuation count toward this limit. Ensure boundaries do not truncate words mid-sentence where possible to maintain natural audio flow.

Audio Joining

Each request returns a distinct audio file. The client application must concatenate these files in the exact order of the original text segments. This process creates a single continuous audio stream from the multiple parts.

Sequential Processing

Requests are processed one after another. Under load, subsequent requests may wait in a queue. Typical generation speed is roughly 25 characters of text per second of generation. Plan your batch processing accordingly to avoid latency.

Example Implementations

Sound wave illustration for: Example Implementations

The following examples demonstrate how to integrate the Narratex TTS API into standard development workflows. Each snippet targets a specific environment, ensuring that developers can quickly generate audio files using the correct base URL and authentication headers.

These implementations cover the core request structure, including model selection, voice presets, and output format configuration. They are designed for immediate use in production environments where reliability and predictable cost structures are required.

cURL Command

Send a POST request to the speech endpoint with your Bearer token. Replace <YOUR_API_KEY> with your key from the dashboard.

curl -X POST "https://api.cg11.info/v1/audio/speech" \ -H "Authorization: Bearer <YOUR_API_KEY>" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "Hello world", "voice": "nova", "response_format": "mp3"}' \ -o output.mp3

Python SDK Example

Use the OpenAI Python SDK, pointing to the CG11 base URL. This allows direct compatibility with existing OpenAI client code.

from openai import OpenAI client = OpenAI(api_key='<YOUR_API_KEY>', base_url='https://api.cg11.info/v1') response = client.audio.speech.create( model='tts-1', voice='nova', input='Text to synthesize', response_format='mp3' ) response.stream_to_file('output.mp3')

Node.js Configuration

Configure the axios instance or fetch API to send JSON payloads to the API endpoint. Ensure the Authorization header includes the Bearer token.

const axios = require('axios'); const fs = require('fs'); axios.post('https://api.cg11.info/v1/audio/speech', { model: 'tts-1', voice: 'nova', input: 'Hello world', response_format: 'mp3' }, { headers: { 'Authorization': 'Bearer <YOUR_API_KEY>', 'Content-Type': 'application/json' }, responseType: 'arraybuffer' }).then(response => { fs.writeFileSync('output.mp3', Buffer.from(response.data)); });

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Ensure the text is concise to avoid sounding mumbled or unclear at higher speeds.

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. FFmpeg documentation
  4. LibriTTS-R paper (arXiv 2305.18802)
  5. Creative Commons Attribution 4.0
  6. curl documentation
  7. W3C WAI: making audio and video accessible
  8. Node.js documentation
  9. openai-python on GitHub
  10. OpenAI API reference: create speech
  11. LibriVox public-domain audiobooks
  12. MDN: Web Speech API

More on this site