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. The dashboard displays your active API key, current balance, and usage statistics. You can issue a new key at any time, which immediately invalidates the previous one.
What is the base URL for the OpenAI SDK?
Set your SDK's base URL to https://api.loboki.info/v1. Use the standard OpenAI SDKs by passing your API key via the Authorization header. This allows you to use the same request shape as the OpenAI speech endpoint for seamless integration.
Does the API support SSML tags?
No. The API does not support SSML tags, phoneme dictionaries, or custom pronunciation lexicons. You must provide plain text input. For precise control, split your text into separate requests using different voices or adjust the speed parameter within the allowed range.
What happens if I exceed the rate limit?
Requests are processed sequentially. If you exceed 60 requests per minute, subsequent requests will wait in a queue until capacity is available. Failed requests are free.
Can I stream audio in real-time?
No. There is no streaming, WebSocket, or real-time partial audio support. The API returns the complete audio file in the response body after synthesis is finished. You must wait for the full file before playing or processing the audio.
How do I handle connection timeouts?
Implement standard HTTP retry logic with exponential backoff for your client. Since requests are queued under load, longer texts may take several seconds to generate. Ensure your client timeout is sufficiently high to accommodate processing delays during peak usage periods.
Is the API key secure enough for production?
Yes. The API uses standard Bearer token authentication via the Authorization header. Each account has one active key, which you can rotate instantly via the dashboard. The key is sufficient for production use when kept secure in your environment variables.
What languages are supported in the API?
The API supports 23 languages, including English, Spanish, German, French, Chinese, Japanese, and Arabic. Any voice can speak any supported language. If the language is not specified, it is guessed from the script, defaulting to English for Latin text.
Can I mix voices in a single response?
No. Each request accepts only one voice preset. To mix voices, you must send multiple requests, one for each voice segment, and then join the resulting audio files on the client side or via your own audio processing pipeline.
How is the audio file delivered?
The audio file is returned directly in the HTTP response body. Supported formats include mp3, wav, opus, flac, and pcm. The file is generated synchronously, so the response contains the complete audio data once synthesis is complete.
Do I need a specific library for MP3 decoding?
No. The API returns standard MP3, WAV, or other common audio formats. You can use any standard audio library or player compatible with these formats. No proprietary decoder or specific SDK is required to play the returned audio files.
Is there a WebSocket endpoint for live audio?
No. There is no WebSocket endpoint for live or streaming audio. The API is request-response based. You receive the full audio file after the synthesis process completes. Use standard HTTP POST requests to generate and retrieve your audio.
How do I test the API before production?
Sign up with Google to receive a $0.50 free trial credit valid for 7 days. Use the provided curl example on the /get-api-key/ page to make your first request. This allows you to verify integration and voice quality before spending real funds.
What is the maximum input text length?
The maximum input text length is 4096 characters per request. For longer texts, split the text into parts of up to 4096 characters and join the audio files.
First request
curl
curl https://api.loboki.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.mp3Python (openai)
from openai import OpenAI
client = OpenAI(base_url="https://api.loboki.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.loboki.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 | |
|---|---|
aria | female |
nova | female |
luna | female |
sage | female |
felix | male |
milo | male |
atlas | male |
orion | male |
| language | |
|---|---|
ar | العربية |
zh | 中文 |
da | Dansk |
nl | Nederlands |
en | English |
fi | Suomi |
fr | Français |
de | Deutsch |
el | Ελληνικά |
he | עברית |
hi | हिन्दी |
it | Italiano |
ja | 日本語 |
ko | 한국어 |
ms | Bahasa Melayu |
no | Norsk |
pl | Polski |
pt | Português |
ru | Русский |
es | Español |
sw | Kiswahili |
sv | Svenska |
tr | Türkçe |
Authentication
Access the Loboki TTS API using a valid API key issued to your account. Keys are generated via the /get-api-key/ dashboard and authenticate all requests to the speech endpoint.
Each account holds one active key. You can rotate the key at any time; the previous key becomes invalid immediately upon issuance of the new one, ensuring secure access control for your transport announcement services.
API Key Generation
Generate your key through the Loboki dashboard after signing in with Google or email. The key is displayed immediately and can be copied for use in your application's configuration.
Keys are unique per site account and must be kept secure. Store them in environment variables rather than hardcoding them in your source code.
- Keys are generated via the /get-api-key/ page.
- One active key per account.
- No monthly plan required.
Bearer Token Format
Include the API key in the Authorization header of every request. The format must be Bearer <your-api-key>, where <your-api-key> is the string starting with tts-.
Example: Authorization: Bearer tts-abc123def456. Ensure no extra spaces are included before or after the token value.
Key Rotation Policy
You can issue a new key at any time from the dashboard. The old key stops working immediately, preventing any further use of the compromised or old credential.
This allows rapid response to potential security incidents without downtime for key regeneration.
Speech Endpoint
Send a POST request to https://api.loboki.info/v1/audio/speech with your JSON payload. The endpoint accepts text input and configuration parameters to generate synthetic speech audio files suitable for transport announcements.
Requests are processed sequentially. Under load, a request may wait in a queue. Typical speed is roughly real-time (25 characters per second), though short phrases take a few seconds.
POST Request Structure
Use the standard OpenAI-compatible endpoint structure. Send a JSON body containing the model, input text, voice selection, and desired audio format.
- Endpoint:
POST https://api.loboki.info/v1/audio/speech - Content-Type:
application/json
JSON Body Parameters
Key fields include model ("tts-1" or "tts-1-hd"), input (up to 4096 characters), voice (one of 8 presets), response_format (mp3, wav, opus, flac, pcm), and speed (0.25–4.0). The language field is optional but recommended for non-English Latin-script text to ensure correct pronunciation.
Failed requests are free. If synthesis fails, the charge is returned in full. Input text is used only to produce the audio and is not used for training.
Response Format
The API returns the generated audio file directly in the response body. The format matches the response_format parameter you specified (e.g., MP3, WAV, OPUS).
Generated audio is not stored on our servers. Request metadata (time, characters, status) is kept for billing purposes.
Voice Parameters
Loboki’s TTS API supports eight distinct voice presets optimized for clarity and readability in public address systems. Select voices based on context: Aria for calm narration, Felix for energetic announcements, or Atlas for neutral news-style delivery. Each voice is engineered for distinct tonal characteristics without requiring complex configuration.
Voice ID Selection
Choose from eight licensed voices, including female options like Aria and Nova, and male options like Felix and Atlas. All voices support any of the 23 supported languages, allowing consistent audio quality across multilingual transport hubs. Select the ID that matches your announcement’s tone, from soft storytelling to clear instructional cues.
- Aria (warm narrator)
- Felix (energetic promo)
- Atlas (neutral news)
- Orion (deep documentary)
Speed Range (0.25-4.0)
Adjust speech rate between 0.25x and 4.0x to fit dynamic environments. Standard speed is 1.0x, which approximates real-time generation for long texts. Lower speeds aid comprehension in noisy stations, while higher speeds suit quick status updates. The API processes requests sequentially, so extreme speeds may slightly alter total latency.
Language Code Usage
Specify the ISO 639-1 language code (e.g., 'en', 'de', 'zh') to ensure accurate pronunciation. Without this parameter, the system guesses the language based on script, defaulting to English for Latin text. Explicitly setting the language prevents errors in mixed-language announcements, such as bilingual station names.
- Arabic, Chinese, Danish, Dutch
- English, French, German, Greek
- Hindi, Italian, Japanese, Korean
- Russian, Spanish, Turkish
Audio Formats
Select the response format that matches your deployment constraints. MP3 offers small file sizes for efficient storage and transmission, while WAV provides uncompressed audio for high-fidelity playback systems. OPUS reduces bandwidth usage significantly without sacrificing intelligibility.
MP3 for Efficiency
Use MP3 when minimizing storage and network overhead is critical. This format is ideal for caching announcements on devices with limited memory or for transmitting over constrained mobile networks.
WAV for Quality
Choose WAV for uncompressed, high-quality audio suitable for professional public address systems. This format ensures no lossy compression artifacts affect the clarity of critical transit information.
OPUS for Bandwidth
OPUS reduces bandwidth usage significantly without sacrificing intelligibility. It is optimal for scenarios where bandwidth conservation is a priority without compromising speech intelligibility.
Rate Limits
Rate limits protect the service during high load. Requests are processed sequentially, so under heavy traffic, synthesis may queue. Failed requests do not consume your limit or balance.
60 Requests Per Minute
After topping up, your account supports 60 requests per minute. This throughput handles typical transport announcement volumes, such as batch-generating station names or route updates.
- Standard limit after initial top-up.
- Sufficient for most indie deployment scenarios.
Initial Limit (10/min)
New keys start with a 10 requests per minute limit. This prevents accidental bursts from unoptimized clients during testing phases.
Limit Increase via Top-Up
You can increase this limit by topping up your balance. Once you add USDT (TRC-20), the limit rises to 60 requests per minute.

Error Handling
Transport announcements often run in strict queues; understanding error codes helps you manage audio generation failures without blocking your deployment pipeline. Most issues stem from client-side misconfigurations, which are resolved by checking request parameters or key validity.
4xx Client Errors
Errors in the 400–499 range indicate issues with your request, such as an invalid API key, exceeded character limits, or unsupported voice IDs. These failures are free and do not consume your balance.
- 401 Unauthorized: Invalid or expired Bearer token.
- 429 Too Many Requests: You have exceeded the 60 requests per minute limit.
- 422 Unprocessable Entity: Text exceeds 4096 characters or parameters are malformed.
5xx Server Errors
Server errors (500–599) are rare and indicate temporary processing failures on our end. These requests are also refunded if the synthesis fails completely. If you encounter persistent 5xx errors, contact support via email.
- 503 Service Unavailable: Temporary overload; wait and retry.
- 500 Internal Server Error: Unexpected processing failure.
Retry Logic
For 429 errors, implement an exponential backoff strategy before retrying. For 5xx errors, a simple immediate retry is often sufficient. Always check the response body for specific error codes to determine the appropriate retry interval.
OpenAI SDK Integration
The Loboki API mirrors the OpenAI speech endpoint structure, allowing you to reuse existing OpenAI SDK clients with minimal configuration. By simply adjusting the base URL, you can integrate Loboki’s TTS engine into your transport announcement systems without rewriting your HTTP client logic.
This compatibility allows developers familiar with the OpenAI ecosystem to deploy multilingual public transport announcements quickly, leveraging standard libraries for authentication and request handling.
Base URL Configuration
Set your client’s base URL to https://api.loboki.info/v1. This directs all speech requests to Loboki’s endpoint while maintaining the standard OpenAI path structure (/v1/audio/speech).
Ensure your environment variables or configuration files point to this domain to route traffic correctly. The endpoint accepts the same JSON body as the official OpenAI speech endpoint.
- Base URL:
https://api.loboki.info/v1 - Endpoint:
/v1/audio/speech - Method:
POST
Client Initialization
Initialize the OpenAI SDK client using your Loboki API key. Pass the key via the api_key parameter and specify the custom base URL.
Example in Python: client = OpenAI(api_key='tts-your-key', base_url='https://api.loboki.info/v1'). This configuration ensures all subsequent requests, including speech generation, use Loboki’s infrastructure.
Remember to import the necessary modules from the OpenAI SDK and handle exceptions as you would with any external API service.
- Use standard OpenAI SDK clients
- Pass
api_keyandbase_url - No custom client class required
SDK Compatibility
The API is compatible with any SDK that supports the OpenAI speech endpoint format. This includes official OpenAI SDKs for Python, Node.js, and other languages.
You can use the same request parameters (model, input, voice, etc.) as defined in the OpenAI documentation. Adjust the model field to tts-1 or tts-1-hd as needed.
Note that while the request shape is identical, Loboki’s rate limits and character counts apply. Ensure your code handles retries for rate limit errors (429) appropriately.
- Compatible with OpenAI SDKs
- Same request shape
- Use
tts-1ortts-1-hd
Curl Example
Use curl to verify integration before building your transport announcement pipeline. This example demonstrates a standard request to generate an audio file for a bus stop announcement.
The response returns a binary audio file. Ensure your script handles the binary stream correctly to avoid corruption in your public information system.
Basic Request
Send a POST request to the speech endpoint with your text payload. The model "tts-1" provides standard quality, while "tts-1-hd" offers higher fidelity.
- curl -X POST https://api.loboki.info/v1/audio/speech \
- -H "Authorization: Bearer tts-..." \
- -H "Content-Type: application/json" \
- -d '{"model": "tts-1", "input": "Next stop, Central Station.", "voice": "aria", "response_format": "mp3"}'
Headers Configuration
Include your API key in the Authorization header using the Bearer scheme. Set Content-Type to application/json to ensure proper parsing of the request body.
- Authorization: Bearer tts-your-api-key-here
- Content-Type: application/json
Response Parsing
The API returns the audio file directly in the response body. Save the output to a local file using the -o flag for immediate playback testing.
- curl -o announcement.mp3 -X POST ...
- Verify the file size matches expected character count.
Listen to the 8 voices
Each sample below was generated by this API from the same sentence. Its distinct tone stands out in crowded acoustic environments, ensuring the message is heard clearly even with background noise.
23 languages
Any voice speaks any of these languages.
