Integrate LexiCast Text-to-Speech API with OpenAI SDKs

By LexiCast editorial team · Updated 2026-11-18

This guide helps indie developers integrate LexiCast’s text-to-speech API into accessible reading tools for dyslexic users. You will learn to convert text into natural-sounding audio using standard OpenAI SDKs, leveraging our simple endpoint structure. We cover configuration, voice selection, and error handling with concrete examples tailored to your workflow.

You need an API key to start. The documentation details request parameters, supported formats like MP3 and WAV, and how to handle long texts by splitting and joining audio. We also explain rate limits, pricing, and authentication so you can build reliable, compliant reading experiences without unnecessary complexity.

Integrate LexiCast Text-to-Speech API with OpenAI SDKs

Frequently asked questions

How do I get an API key?

Sign up on the /get-api-key/ page using Google or an email and password. The page displays your active API key, which you use for authentication. Each account holds one active key; issuing a new one immediately invalidates the previous one.

What is the base URL?

The API base URL is https://api.gk999slot.com/v1. You send POST requests to https://api.gk999slot.com/v1/audio/speech. The /v1/voices and /v1/models endpoints provide details about available voices and models.

Can I use the 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.gk999slot.com/v1 and providing your LexiCast API key for authentication.

What formats are supported?

You can choose from mp3, wav, opus, flac, or pcm. Set the response_format field in your request body to select the desired audio format for the generated speech file.

How do I handle long texts?

Split your input text into parts of up to 4096 characters. Send each part in a separate request, then join the resulting audio files to create the final output.

What are the rate limits?

You are limited to 60 requests per minute per key. Before your first top-up, this limit is 10 requests per minute. Requests are processed sequentially, so queueing may occur under load.

How do I handle errors?

Failed requests are free; the charge is returned in full if synthesis fails. Check the response status for error details. Input text is not stored, but request metadata is kept for billing.

Is there a cURL example?

Yes. The /get-api-key/ page displays a ready cURL example. It demonstrates the correct JSON body structure, including model, input, voice, and authentication headers for immediate integration testing.

Can I adjust the speed?

Yes. Set the speed field between 0.25 and 4.0. This allows you to slow down or speed up the speech generation to suit your accessibility needs.

How do I select a voice?

Choose from eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Use the GET /v1/voices endpoint to list all available voices and their characteristics.

What is the character limit?

Each request supports up to 4096 characters in the input field. For longer texts, split the content into chunks of this size and process them individually.

How is billing calculated?

Billing is $10 per 1 million characters, or $0.01 per 1,000 characters. Spaces and punctuation count as characters. Failed requests incur no charge.

Can I use multiple keys?

Each account has one active key. You can issue a new key at any time via the dashboard. The old key stops working immediately when the new one is created.

How do I check my balance?

Visit the /get-api-key/ page to view your current balance, trial status, and characters remaining. The dashboard also shows your usage history and billing details.

First request

curl

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

Getting Your API Key

Sound wave illustration for: Getting Your API Key

LexiCast provides a straightforward onboarding process for indie developers building accessibility tools. You can create an account directly on our site using Google or an email and password combination. This account is tied specifically to this storefront and serves as the foundation for your API usage.

Sign Up on the Site

Sign Up on the Site

Navigate to the /get-api-key/ page to begin. Signing in with Google grants you an immediate $0.50 trial credit valid for seven days, offering roughly 50,000 characters for testing. If you prefer email and password, your account starts without trial credit, requiring a manual top-up before use.

Locate Your Key

Locate Your Key

Once registered, your dashboard displays your unique API key and current balance. You will see your characters left, usage statistics, and a ready-to-use cURL example. This key authenticates your requests to the TTS endpoint and is the only credential needed for integration.

  • Key format starts with tts-
  • One active key per account
  • Dashboard shows real-time usage

Secure Your Key

Store your API key securely in your application environment variables. You can issue a new key at any time from the dashboard; the old key stops working immediately. This allows you to rotate credentials quickly if they are exposed, ensuring your dyslexia reading tool remains secure.

First Request with cURL

Sound wave illustration for: First Request with cURL

To verify your integration, send a simple POST request to the speech endpoint. Replace YOUR_API_KEY with your credential from the dashboard and provide a short input text.

Basic cURL Command

Execute the following command in your terminal. Ensure you replace the placeholder key and adjust the text payload as needed for your initial test.

  • curl -X POST "https://api.gk999slot.com/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"}'

Understanding the Response

A successful request returns an audio file in the format you specified (e.g., MP3). The response body contains the raw binary audio data, not JSON metadata.

Testing Your Setup

Save the output to a file and play it to confirm the voice sounds correct. If you receive an error, check your API key validity and ensure the input text is under 4096 characters.

Integration with OpenAI SDK

Sound wave illustration for: Integration with OpenAI SDK

Connect the OpenAI SDK to LexiCast by overriding the default base URL. This leverages existing client libraries without requiring custom HTTP wrappers. The API endpoint mirrors the OpenAI speech structure, ensuring immediate compatibility with standard integration patterns used by indie developers building accessible reading tools.

This approach simplifies onboarding for teams already familiar with OpenAI’s ecosystem. You simply redirect the API calls to our infrastructure while retaining the familiar method signatures for generating speech from text inputs.

Base URL Configuration

Set the base_url parameter in your SDK client to https://api.gk999slot.com/v1. This directs all subsequent requests to our text-to-speech endpoint. Ensure your authentication header remains Authorization: Bearer <your-key> to maintain secure access to the service.

SDK Compatibility

The official OpenAI SDKs work directly with this configuration because the request shape is identical. You can use standard libraries in Python, JavaScript, or other supported languages without modifying the core logic of your speech generation functions.

Code Examples

```python import openai client = openai.OpenAI(base_url="https://api.gk999slot.com/v1", api_key="tts-your-key") with client.audio.speech.with_streaming_response.create( model="tts-1", voice="aria", input="Hello, this is a test." ) as response: response.stream_to_file("output.mp3") `` This snippet demonstrates a standard integration. Replace tts-your-key` with your actual API key found in your dashboard. The code handles the request-response cycle efficiently, allowing you to focus on user experience rather than network details.

Supported Audio Formats

Sound wave illustration for: Supported Audio Formats

LexiCast supports five standard audio formats to suit different playback environments. You specify the output type via the response_format field in your API request. The choice affects file size, compatibility, and quality.

All generated files include an inaudible watermark to identify synthetic speech. This ensures transparency without affecting the listening experience for end users.

MP3 Format

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

Use MP3 when you need broad compatibility across various devices and browsers without managing large file downloads.

  • Suitable for general web playback
  • Small file size
  • Wide device support

WAV Format

WAV provides uncompressed audio. It is suitable for professional editing or when bit-perfect accuracy is required.

Choose WAV for internal processing pipelines where further manipulation of the audio data is necessary.

  • Uncompressed audio
  • Larger file size than MP3
  • Ideal for editing workflows

Opus, FLAC, PCM

Opus offers high-quality compression at low bitrates. FLAC provides lossless compression, reducing file size.

PCM delivers raw audio data. It is best used when you need direct access to the sample data without any encoding overhead.

Select Opus for efficient transmission, FLAC for archival quality, or PCM for raw data processing.

  • Opus: efficient transmission
  • FLAC: lossless compression
  • PCM: raw data access

Request Parameters

Sound wave illustration for: Request Parameters

Configure the synthesis engine and voice to match your accessibility needs. The API offers two model variants that share the same underlying engine, allowing you to choose based on your specific audio quality preferences without changing the integration logic.

Model Selection

Select either "tts-1" or "tts-1-hd" in your request body. Both models use the identical voice engine and incur the same price per character, so the choice depends solely on your preference for audio fidelity versus processing latency.

Voice Selection

Choose from eight distinct presets, including female voices like Aria and Nova, or male voices like Felix and Atlas. Every voice supports all 23 available languages, ensuring consistent tone regardless of the input language, though you should explicitly set the language for non-English Latin text.

  • Female: aria, nova, luna, sage
  • Male: felix, milo, atlas, orion

Speed Adjustment

Adjust playback speed between 0.25 and 4.0 to suit reader comfort. Slower speeds aid comprehension for users with processing differences, while faster speeds reduce total audio file size and generation time for long documents.

Request Parameters

Handling Long Texts

Sound wave illustration for: Handling Long Texts

The API enforces a strict 4096-character limit per request, counting spaces and punctuation. Text exceeding this threshold must be split before submission to ensure successful synthesis. This constraint applies uniformly across all models and voices.

Character Limits

Each API call processes up to 4096 characters of input text. The character count includes all spaces, punctuation, and whitespace. If your content exceeds this limit, the request will fail, and no charge will be applied.

  • Limit: 4096 characters per request.
  • Includes spaces and punctuation.
  • Excess text causes a failed request.

Splitting Text

Divide long articles or documents into segments that respect the 4096-character boundary. Ensure each segment is a complete sentence or logical phrase to avoid awkward audio cuts. Submit each segment as a separate API request sequentially.

Joining Audio

Receive individual audio files for each segment from the API responses. Use a standard audio library to concatenate these files in the order of your original text. This creates a seamless listening experience for the user.

Error Handling

Sound wave illustration for: Error Handling

API responses include clear error codes when synthesis fails. Failed requests are free, ensuring you are not charged for wasted effort. This allows safe integration into automated pipelines without financial risk during initial testing phases.

Common Errors

Errors typically arise from invalid model names, unsupported voices, or exceeding the 4096-character limit per request. The API returns a specific error message detailing the failure, allowing you to adjust your input parameters accordingly.

  • Invalid model parameter
  • Exceeded character limit
  • Invalid voice preset
  • Rate limit exceeded

Retry Logic

Implement exponential backoff for transient errors. Since requests are processed sequentially, brief delays between retries prevent queue congestion. Failed requests incur no charge, so aggressive retrying within rate limits is financially safe.

Status Codes

Standard HTTP status codes indicate success or failure. A 200 OK confirms audio generation. Non-200 codes indicate issues like bad input or server errors. Always check the response body for detailed error descriptions to guide immediate fixes.

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

LexiCast enforces a limit of 60 requests per minute per API key, with a lower threshold of 10 requests per minute applied before your first top-up. This quota ensures stable processing for indie developers building accessible reading tools without overwhelming the infrastructure.

Requests Per Minute

Each active key is allowed a maximum of 60 requests per minute. Accounts that have not yet topped up are restricted to 10 requests per minute, which helps manage initial load while ensuring fair usage for all developers.

Queue Processing

Requests are processed sequentially. Under heavy load, a request may wait in a queue before synthesis begins. Typical speed is roughly real-time, generating about 25 characters of text per second, though short phrases may take a few seconds to complete.

  • Requests are processed one after another
  • Queueing may occur under load
  • Real-time generation speed

Monitoring Usage

You can monitor your current usage, remaining balance, and character count directly on the /get-api-key/ dashboard. The API does not return detailed per-request usage headers, so rely on the dashboard for accurate tracking of your consumption.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Failed requests are free, and there are no monthly fees or minimum spend requirements, making it easy to budget for your accessibility features.

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. LibriVox public-domain audiobooks
  4. TRON developer hub: TRC-20
  5. W3C WAI: making audio and video accessible
  6. curl documentation
  7. IETF RFC 7845: Ogg Opus
  8. Python documentation
  9. Creative Commons Attribution 4.0
  10. openai-python on GitHub
  11. MDN: Web Speech API
  12. LibriTTS-R corpus (OpenSLR 141)

More on this site