Integrate Our Cloud TTS API with OpenAI SDK

By LexiFlow Team · Updated 2026-11-19

This documentation provides the technical specifications for integrating the LexiFlow text-to-speech API into your accessibility workflows. You will find exact endpoint definitions, required headers, and parameter constraints necessary for converting text into compliant audio files for dyslexic readers. The guide assumes familiarity with standard HTTP practices and uses the OpenAI SDK as the primary integration pattern.

Developers working with publisher platforms will learn how to configure authentication, manage rate limits, and handle language-specific voice synthesis. Use this reference to build reliable, auditable audio generation pipelines that meet enterprise compliance standards without unnecessary complexity.

Integrate Our Cloud TTS API with OpenAI SDK

Frequently asked questions

How do I authenticate with the API?

Include your API key in the request header as Authorization: Bearer tts-.... You obtain this key by signing up on the /get-api-key/ page. Each account maintains one active key. If you issue a new key, the previous one stops immediately. Ensure your key is valid before sending requests to the endpoint.

Can I use the OpenAI SDK with this API?

Yes. The request shape matches the OpenAI speech endpoint. You can use the official OpenAI SDKs by changing the base_url to https://api.ar777.cc/v1 and providing your site-specific key. This allows you to leverage existing client libraries without writing custom HTTP logic for standard TTS operations.

What is the base URL for the API?

The base URL is https://api.ar777.cc/v1. The primary endpoint for generating audio is POST /v1/audio/speech. You can also retrieve available voices via GET /v1/voices and model information via GET /v1/models. Use this base URL when configuring your SDK or HTTP client.

How do I specify a different language?

Pass 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, you must explicitly set the language parameter to ensure correct synthesis. Supported languages include Arabic, Chinese, Danish, and others.

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). Requests are processed sequentially, so exceeding the limit or high load may cause your request to wait in a queue. Failed requests do not consume credits, but successful ones are charged immediately.

Is the API key reusable?

Yes, the key remains active until you issue a new one. Each account holds one active key. You can generate a new key at any time via the dashboard. When a new key is issued, the old one stops working immediately, ensuring you can rotate credentials without downtime if needed.

How do I generate WAV files?

Set the response_format field in your JSON body to wav. The API supports mp3, wav, opus, flac, and pcm formats. The audio file is returned directly in the response body. WAV files are uncompressed, resulting in larger file sizes compared to mp3 or opus for the same duration.

Can I adjust the speaking speed?

Yes, use the speed parameter with a value between 0.25 and 4.0. The default speed is 1.0. Adjusting speed affects the duration of the generated audio. This applies to all voices and models. Ensure your application handles the varying audio lengths if you modify this parameter significantly.

What models are available?

The available models are tts-1 and tts-1-hd. Both use the same engine and price. You can select either model in your requests. Both models support the same voices, languages, and response formats defined in the API specification.

How do I handle long texts?

Split your text into parts of up to 4096 characters per request. Generate audio for each part, then join the resulting audio files in your application. The API does not support streaming or partial audio. This manual splitting ensures you stay within the character limit for each synthesis job.

Is the API key secure?

The key is a standard bearer token included in the Authorization header. Request metadata (time, characters, status) is kept for billing. You can rotate the key at any time, invalidating the previous one instantly. Ensure you transmit your key over HTTPS to prevent interception during API calls.

Can I rotate my API key?

Yes, you can issue a new key at any time from the dashboard. When a new key is generated, the old one stops working immediately. This allows you to rotate credentials without service interruption. You should update your application configuration with the new key to continue using the API.

What is the maximum text length?

The maximum input text length is 4096 characters per request. Spaces and punctuation count toward this limit. For longer texts, you must split the content into smaller chunks, generate audio for each, and concatenate the results in your client application. This ensures compatibility with the API's processing constraints.

How do I get the list of voices?

Send a GET request to /v1/voices. This endpoint returns available voices, languages, formats, and pricing information. You can use this data to dynamically select voices in your application. The response includes details for all eight presets, including aria, nova, luna, sage, felix, milo, atlas, and orion.

First request

curl

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

Authentication is handled via a Bearer token sent in the Authorization header of every request. Each account maintains a single active key; the header format is Authorization: Bearer tts-....

Keys are issued upon account creation on /get-api-key/. Management is straightforward: generating a new key immediately invalidates the previous one, ensuring only one active credential exists at any time. Accounts are per site.

Bearer token usage

Bearer token usage

Include the full key string after Bearer in the HTTP header. This token authorizes all subsequent API calls, including speech generation and voice listing.

API key management

API key management

The key is displayed on your dashboard alongside your balance and usage metrics. Store it securely in your environment variables or configuration files.

Key revocation process

Revocation is instantaneous. When you issue a new key from the dashboard, the old key stops working immediately. There is no delay or grace period.

Use this feature if a key is compromised. Generate a new key via the dashboard to secure your account.

Endpoint Overview

Sound wave illustration for: Endpoint Overview

The API exposes three primary endpoints for integration. The speech endpoint accepts text and configuration parameters to return synthesized audio. The voices endpoint lists available presets, languages, formats, and price. The models endpoint provides metadata for the available synthesis engines.

These endpoints support standard OpenAI SDK compatibility. Developers can configure their clients by pointing the base URL to https://api.ar777.cc/v1. This allows immediate use of existing client libraries with minimal code changes.

POST /v1/audio/speech

This endpoint accepts a JSON body containing the text input, voice selection, and output format. It returns the generated audio file directly in the response. The maximum input length is 4096 characters per request.

Failed requests do not incur charges. The system returns an error object if the synthesis process fails, allowing for safe retry logic without billing impact.

  • Accepts text up to 4096 characters
  • Returns audio in mp3, wav, opus, flac, or pcm
  • Requires Bearer token authentication

GET /v1/voices

Retrieves a list of all available voice presets. Each voice object includes metadata about the voice name, gender, and supported languages. This endpoint helps developers select the appropriate voice for their content.

The response also lists available output formats and current pricing details. This allows applications to dynamically adjust to format requirements without hardcoding values.

  • Lists 8 voice presets
  • Shows supported languages
  • Displays available audio formats

GET /v1/models

Returns metadata for the available text-to-speech models. Currently, the system supports tts-1 and tts-1-hd, which use the same engine and pricing. This endpoint allows clients to verify model availability before making speech requests.

The response includes model IDs and associated metadata. This information is essential for configuring the OpenAI SDK correctly when switching base URLs.

  • Returns tts-1 and tts-1-hd
  • Includes engine metadata
  • Supports standard model identification

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts model ("tts-1" or "tts-1-hd") and voice parameters to define synthesis quality and timbre. Input text is limited to 4096 characters per request. Both model options use the same engine and pricing tier, ensuring consistent output regardless of selection.

Model selection (tts-1)

Specify tts-1 or tts-1-hd in the request body. Both models utilize identical underlying synthesis engines and incur the same charge of $0.01 per 1,000 characters. Spaces and punctuation count as characters. The selection does not alter the audio generation speed or latency characteristics.

Voice preset selection

Select from eight licensed presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Any voice can speak any of the 23 available languages. The voice field accepts the preset name as a string. If language is omitted, the system guesses the language based on the input script, defaulting to English for Latin text.

  • Aria (warm narrator)
  • Nova (bright upbeat)
  • Luna (soft storytelling)
  • Sage (calm instructional)
  • Felix (energetic promo)
  • Milo (friendly conversational)

Response format options

The response_format field accepts mp3, wav, opus, flac, or pcm. MP3 is the default and recommended format for most accessibility workflows due to its balance of quality and file size. Raw PCM audio is uncompressed and requires explicit sample rate handling by the client.

Speed Control

Sound wave illustration for: Speed Control

The speed parameter accepts values between 0.25 and 4.0, allowing precise control over the synthesis rate. This capability ensures that generated audio matches specific accessibility needs, such as slowing down complex texts for dyslexic readers or accelerating simple content for efficiency.

Speed range 0.25–4.0

Adjust the speed value in your request to modify the playback rate. Lower values produce slower, clearer enunciation, while higher values increase tempo. This range accommodates various listening preferences without altering the voice preset.

Adjustable playback rate

The API applies the speed factor directly during synthesis. A value of 1.0 represents normal speed. Values below 1.0 extend the audio duration, while values above 1.0 compress it. This adjustment is applied uniformly across the entire input text.

Impact on generation time

Generation time scales with the speed setting. Slower speeds increase processing duration, while faster speeds reduce it. Typical generation speed is roughly real time (about 25 characters of text per second of generation). Requests are processed sequentially, so higher speeds may reduce queue wait times during high load.

Language Handling

Sound wave illustration for: Language Handling

LexiFlow supports 23 languages, allowing any voice preset to generate audio in Arabic, Chinese, English, German, Hindi, Japanese, Korean, Spanish, and others. This flexibility ensures consistent audio quality for diverse accessibility workflows regardless of the source text's origin.

ISO language codes

The API accepts standard ISO 639-1 language codes in the language field. This explicit parameter ensures precise synthesis when the text script does not uniquely identify the language, such as Latin script text that could be English, Dutch, or Portuguese.

  • Supported codes include: ar, zh, da, nl, en, fi, fr, de, el, he, hi, it, ja, ko, ms, no, pl, pt, ru, es, sw, sv, tr.

Automatic detection

If the language field is omitted, the system attempts to infer the language from the character script. Latin script text defaults to English. Non-Latin scripts are mapped to their respective languages automatically.

Explicit language setting

For multi-lingual content or ambiguous scripts, always set the language parameter explicitly. This prevents mispronunciation and ensures the voice generates audio in the correct dialect for your readers.

Language Handling

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate request outcomes. Successful synthesis returns 200 with the audio binary. Client errors (4xx) indicate invalid parameters or authentication failures, while server errors (5xx) suggest temporary processing issues.

HTTP status codes

A 200 OK response contains the audio file in the requested format. Use 400 Bad Request for malformed JSON or invalid voice IDs. A 401 Unauthorized indicates an invalid API key. Rate limit errors return 429.

Error message structure

Errors return a JSON object with an 'error' key containing a 'message' string and a 'code'. The message describes the specific issue, such as input exceeding 4096 characters or an unsupported response format. Use these codes to programmatically handle failures.

Retry logic recommendations

Implement exponential backoff for 429 and 5xx errors. Do not retry 4xx errors as they indicate permanent client-side issues. For 503 Service Unavailable, wait briefly before retrying, as generation queues may cause temporary delays during high load.

  • Retry 5xx errors with exponential backoff
  • Do not retry 4xx errors
  • Handle 429 Rate Limit errors by waiting

Rate Limits

Sound wave illustration for: Rate Limits

Rate limits protect API availability during high-volume accessibility workflows. Limits apply per API key and are enforced at the gateway level. Exceeding the threshold returns a 429 Too Many Requests error, allowing publishers to implement exponential backoff strategies for reliable batch processing of long-form content.

The system enforces a standard maximum of 60 requests per minute for established keys. This ensures consistent throughput for publishers converting large catalogs of text to audio without throttling legitimate traffic during peak usage windows.

60 requests per minute

The standard rate limit is 60 requests per minute per active API key. This capacity supports steady-state generation for accessibility tools converting lengthy articles or books. Requests are processed sequentially, so high concurrency may introduce queuing delays for individual synthesis tasks.

10 requests initially

New keys start with a reduced limit of 10 requests per minute. This constraint applies until the first top-up is credited to the account. After a successful USDT transfer, the limit increases to the standard 60 requests per minute automatically.

Key-specific limits

Limits are tied to the specific API key, not the account. If you issue a new key, the old key stops immediately, and the new key begins with the 10 requests/minute baseline. Each key maintains its own independent rate counter.

Exceeding the limit results in a 429 status code. Implement retry logic with exponential backoff to handle transient throttling during peak publishing hours.

  • Max 60 requests/minute per key
  • Initial limit: 10 requests/minute
  • Limit resets after first top-up
  • Returns HTTP 429 when exceeded

Code Examples

Sound wave illustration for: Code Examples

Integration is straightforward using standard HTTP clients or the OpenAI SDK with a modified base URL. The API accepts standard JSON bodies, ensuring compatibility with existing TTS workflows without requiring custom middleware or proprietary libraries.

cURL request example

Send a POST request to https://api.ar777.cc/v1/audio/speech with your Bearer token. The following command generates 5 seconds of speech using the nova voice in MP3 format:

  • ```bash
  • curl -X POST https://api.ar777.cc/v1/audio/speech \
  • -H "Authorization: Bearer tts-..." \
  • -H "Content-Type: application/json" \
  • -d '{"model": "tts-1", "input": "Accessibility audio generated for compliance.", "voice": "nova", "response_format": "mp3"}' \
  • -o audio.mp3
  • ```

OpenAI SDK configuration

Configure the OpenAI SDK by overriding the base_url to point to our infrastructure. This allows you to use familiar methods like client.audio.speech.create() without changing your core logic.

  • ```python
  • from openai import OpenAI
  • client = OpenAI(api_key="tts-...", base_url="https://api.ar777.cc/v1")
  • # Use standard OpenAI speech endpoints
  • ```

Python integration snippet

Use the Python requests library for direct control. This approach is suitable for batch processing large texts into audio files for accessibility libraries.

  • ```python
  • import requests
  • resp = requests.post("https://api.ar777.cc/v1/audio/speech", json={"model": "tts-1", "voice": "sage", "input": "Text"}, headers={"Authorization": "Bearer tts-..."})
  • with open("output.mp3", "wb") as f: f.write(resp.content)
  • ```

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. This energy helps prevent listener fatigue during repetitive ad rotations.

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

More on this site