Developer Guide: Integrating Text-to-Speech for Legal Apps

By LexiVoice editorial team · Updated 2026-11-19

This guide explains how to integrate LexiVoice’s text-to-speech API into legal applications for converting contracts, briefs, and case files into audio. You will learn to configure authentication, structure requests, and handle responses using standard JSON payloads compatible with existing OpenAI SDKs. The documentation focuses on practical implementation details relevant to legal product teams managing sensitive document workflows.

Readers will find specific instructions on voice selection, language handling, and rate limits. The guide covers character counting for long texts, output format options, and error handling procedures. All examples use concrete parameters derived from the live API specification, ensuring accurate integration without assumptions about features like streaming or SSML support.

Developer Guide: Integrating Text-to-Speech for Legal Apps

Frequently asked questions

What is the maximum input length per request?

Each request accepts up to 4096 characters. For longer legal documents, split the text into parts of this size and join the resulting audio files. Spaces and punctuation count toward this limit.

How do I specify the language for legal text?

Set the optional language field to the ISO code. If omitted, the system guesses the language, defaulting to English for Latin script. For non-English Latin text, explicitly set the language to ensure accuracy.

Does the API support SSML for legal emphasis?

No. The API does not support SSML, phoneme dictionaries, or custom pronunciation lexicons. You cannot add emphasis or pause tags.

Can I use the OpenAI SDK with this API?

Yes. The request shape matches the OpenAI speech endpoint. Change the SDK’s base_url to https://api.42c.info/v1 and use your LexiVoice key to generate audio files via standard SDK methods.

What is the base URL for the API?

The base URL is https://api.42c.info/v1. Use POST https://api.42c.info/v1/audio/speech for synthesis. List available voices and models via GET /v1/voices and GET /v1/models.

How do I rotate my API key?

Issue a new key from your account dashboard. The new key becomes active immediately, and the old key stops working at once. You can generate a new key at any time.

Are there limits on voice selection per request?

No. You may select any of the eight available voices (Aria, Nova, Luna, Sage, Felix, Milo, Atlas, Orion) for each request. All voices support all 23 languages without additional constraints.

How long does a typical request take?

Generation is roughly real-time, producing about 25 characters of text per second of audio. Short phrases take a few seconds, while longer texts process sequentially, potentially waiting in a queue under load.

What happens if the server is overloaded?

Requests are processed one after another. Under load, your request may wait in a queue before synthesis begins. Failed requests are free.

Do I need to pay for model selection?

No. The tts-1 and tts-1-hd models use the same engine and price. You pay $0.01 per 1,000 characters.

Is the audio format changeable after generation?

No. You must specify the response_format (mp3, wav, opus, flac, or pcm) in the request. The API returns the audio in the requested format; you cannot convert it server-side after generation.

How are rate limits tracked?

Limits are tracked per API key. You are allowed 60 requests per minute. New accounts start with 10 requests per minute until the first top-up is processed and credited to the account.

Can I send text with special legal symbols?

Yes. You can send any text up to 4096 characters, including special symbols, punctuation, and formatting characters. Spaces and punctuation count toward the character limit and are billed accordingly.

Is the API compatible with Python and Node.js?

Yes. Since the API matches the OpenAI speech endpoint, you can use the official OpenAI SDKs for Python and Node.js by updating the base_url to https://api.42c.info/v1 and providing your key.

First request

curl

curl https://api.42c.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.42c.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.42c.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 Setup

Sound wave illustration for: Authentication Setup

Legal teams managing contract and brief generation need reliable, secure access to the LexiVoice API. Authentication is handled via a single active API key per account, issued directly on the /get-api-key/ dashboard. This key authorizes all requests to the speech endpoint, ensuring that only verified accounts can consume characters from your balance.

The API uses standard HTTP bearer token authentication. You must include the Authorization header in every request to verify your identity and link usage to your account’s character quota.

API Key Generation

API Key Generation

Create your key by signing in on the site’s /get-api-key/ page. Accounts can be set up via Google or email/password. Once signed in, the dashboard displays your active API key, current balance, and a ready-to-use cURL example for immediate testing.

Keys are tied to your account’s character limit. If you need a fresh key, you can issue a new one at any time via the dashboard. Ensure you update your applications immediately to avoid service interruption.

  • Sign in via Google or email on /get-api-key/.
  • Locate the active API key on the dashboard.
  • Copy the key for use in your application headers.

Bearer Token Format

Bearer Token Format

Include your API key in the Authorization header using the Bearer scheme. The format is: Authorization: Bearer tts-your-api-key-here. This standard format allows compatibility with existing OpenAI SDKs by simply changing the base_url to https://api.42c.info/v1.

Ensure no extra spaces or characters are included in the token value. The API expects the exact string issued to your account.

  • Use the header: Authorization: Bearer tts-....
  • Do not include quotes or extra whitespace.
  • Verify the key starts with tts-.

Key Rotation Policy

You may rotate your API key at any time directly from the dashboard. When you issue a new key, the previous one becomes invalid immediately. This is useful for security audits or if a key is potentially exposed.

Update all active integrations before rotating. Since keys are revoked instantly, any request made with the old key after rotation will fail authentication until the new key is deployed.

  • Generate a new key from the /get-api-key/ page.
  • The old key stops working immediately.
  • Update all services to use the new key.

Core Endpoint: Speech Generation

Sound wave illustration for: Core Endpoint: Speech Generation

The core endpoint accepts text and returns synthesized audio files, enabling legal teams to convert contracts, briefs, and case files into audio formats for accessibility or review. Send a POST request to the API base URL with your Bearer token and request body to generate speech.

POST /v1/audio/speech

Send a POST request to https://api.42c.info/v1/audio/speech. Include your API key in the Authorization header as Bearer <key>. The endpoint processes the input text and returns the audio file in the specified format.

  • Endpoint: https://api.42c.info/v1/audio/speech
  • Method: POST
  • Auth: Authorization: Bearer tts-...

JSON Body Structure

The request body must be valid JSON containing the model, input, voice, and response_format fields. Optional fields include speed and language.

  • model: "tts-1" or "tts-1-hd"
  • input: The text to synthesize
  • voice: One of the 8 available presets
  • response_format: mp3, wav, opus, flac, or pcm
  • speed: Float between 0.25 and 4.0
  • language: Optional ISO code

Input Text Field Limits

Each request supports up to 4096 characters. Spaces and punctuation count toward this limit. For longer legal documents, split the text into chunks of 4096 characters or fewer and join the resulting audio files.

Available Parameters

Sound wave illustration for: Available Parameters

The API accepts tts-1 and tts-1-hd models, which share the same engine and pricing. Use tts-1-hd for higher fidelity when processing complex legal terminology, though generation time may increase slightly.

Model Selection (tts-1, tts-1-hd)

Both models deliver identical audio quality profiles for standard contracts. The choice affects only the processing priority queue during high load, not the final output format or character cost.

Voice Preset Selection

Select from eight licensed presets. For reading lengthy case files, atlas (neutral, news) or sage (calm, instructional) provide clear, non-distracting narration. Use aria or nova for client-facing summaries where a warmer tone aids comprehension.

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

Speed Adjustment Range

Adjust playback speed between 0.25x and 4.0x. For legal briefs with dense citation structures, slowing to 0.75x or 0.8x can improve listener retention without significantly extending total audio duration.

Output Formats

Sound wave illustration for: Output Formats

LexiVoice supports five audio formats to suit different legal workflows. Select response_format in your API request to define the output container and codec. Each format serves a specific purpose, from efficient delivery to high-fidelity archival.

MP3 for Streaming

MP3 is a common format, offering a balance between file size and audio quality. It is ideal for playback in web applications or mobile apps where bandwidth efficiency matters.

WAV for Archive

WAV provides uncompressed audio. Use this format for long-term storage of critical legal briefs or case files where audio quality must remain pristine.

FLAC and PCM Options

FLAC offers lossless compression. PCM provides raw, uncompressed samples, useful for direct processing in digital signal processing pipelines or specific audio editing tools.

Language Specification

Sound wave illustration for: Language Specification

Legal documents often contain mixed scripts or ambiguous phrasing that can confuse language guessing algorithms. Explicitly defining the language ensures consistent pronunciation for legal terminology, reducing the risk of misinterpretation in briefs or case files.

The API supports 23 languages, including Arabic, Chinese, German, and Japanese. Each voice preset can speak any supported language, allowing you to maintain a consistent narrator voice across multilingual contracts or translated case summaries.

ISO Code Input

Set the language field to the ISO 639-1 code (e.g., en, de, ja) in your request body. This overrides automatic detection, ensuring predictable output even if the text contains mixed-language terms common in international legal agreements.

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

Automatic Language Detection

If the language field is omitted, the API infers the language from the script. Latin script text defaults to English. Non-Latin scripts trigger detection for Chinese, Japanese, Korean, Arabic, or Russian.

Latin Script Defaults

For non-English Latin text (e.g., French or German contracts), always set the language parameter. Without it, the API may pronounce foreign terms with an English accent, affecting clarity in legal audio files.

Language Specification

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

Legal document processing often involves batch conversions of case files or briefs. Understanding your quota limits helps you schedule bulk audio generation without interruption, ensuring your TTS pipeline remains reliable during high-volume periods.

60 Requests Per Minute

Once your account is funded, you can make up to 60 requests per minute. This limit applies per API key, allowing steady throughput for converting lengthy contracts or legal briefs into audio format.

Initial 10 Requests Per Minute

New accounts start with a lower limit of 10 requests per minute. This applies until you make your first top-up. Once you add USDT (TRC-20) to your balance, the limit increases to 60 RPM automatically.

Queue Behavior Under Load

Requests are processed sequentially. If you exceed the limit, subsequent requests wait in a queue. Longer texts take more time to generate, so keep an eye on your queue depth during peak usage to avoid delays.

Handling Long Texts

Sound wave illustration for: Handling Long Texts

Legal documents often exceed the single-request character limit. You must split contracts or briefs into segments of 4096 characters or fewer before sending them to the API.

4096 Character Chunking

Each API call accepts a maximum of 4096 characters, including spaces and punctuation. Ensure your client-side logic splits the input text precisely at this boundary to avoid truncation errors.

Audio Joining Logic

Send each chunk as a separate request. Your application should receive the resulting audio files and concatenate them in the correct order to reconstruct the full document.

Processing occurs sequentially, so longer texts may experience queue delays. Plan your integration to handle asynchronous responses gracefully.

Character Count Management

Characters are billed exactly as sent. Spaces, commas, and special characters count toward the 4096 limit and your total usage.

Monitor your character count against your billing balance to prevent unexpected stops during large document synthesis.

Error Handling

Sound wave illustration for: Error Handling

When integrating LexiVoice for legal document processing, robust error handling ensures your synthesis pipeline remains resilient. Understanding HTTP status codes helps you distinguish between transient network issues and permanent configuration errors, allowing for precise retry logic in your application.

Failed requests are free: if synthesis fails, the charge is returned in full. This policy protects your budget when processing complex contracts or briefs that might occasionally trigger validation errors or engine timeouts.

Common HTTP Status Codes

Use standard HTTP responses to guide your integration. A 200 OK indicates successful audio generation. A 400 Bad Request signals invalid JSON, missing fields, or text exceeding the 4096-character limit. A 401 Unauthorized means your Bearer token is invalid or expired. A 429 Too Many Requests indicates you have hit the 60 requests per minute limit.

Retry strategies should handle 429s with exponential backoff. For 500-level server errors, implement a limited retry loop since the API processes requests sequentially and may queue under load.

  • 400: Invalid input format or character limit exceeded.
  • 401: Invalid or revoked API key.
  • 429: Rate limit exceeded (60 req/min).
  • 500: Internal server error; retry with backoff.

Failed Request Refunds

If synthesis fails due to a server error or timeout, the charge is returned in full. This ensures you are not billed for audio files that were not delivered. Check your account balance after retries to confirm credits are restored.

Failed requests do not consume your character allowance. This is critical for legal teams processing large volumes of text where occasional engine hiccups should not deplete your budget.

Debugging Input Errors

Ensure your text fits within the 4096-character limit per request. If your legal brief exceeds this, split the text into chunks and join the resulting audio files manually. Verify that the voice ID exists and the language ISO code matches your input script.

Check that your JSON body is correctly formatted. Missing the input field or using an unsupported response_format will trigger a 400 error. Review the error message in the response body for specific details on what went wrong.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Understanding these boundaries ensures smooth integration into your document processing pipeline.

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. LibriTTS-R paper (arXiv 2305.18802)
  3. TRON developer hub: TRC-20
  4. Node.js documentation
  5. openai-node on GitHub
  6. W3C WAI: making audio and video accessible
  7. LibriTTS-R corpus (OpenSLR 141)
  8. IETF RFC 7845: Ogg Opus
  9. Python documentation
  10. FFmpeg documentation
  11. openai-python on GitHub
  12. Creative Commons Attribution 4.0

More on this site