Generate Audio with Our Text-to-Speech API

By Svajpa Editorial Team · Updated 2026-11-19

This guide helps indie developers integrate synthetic speech into restaurant and dining platforms without custom voice design overhead. You will find exact parameters for our TTS API, including how to select from eight distinct voice presets that suit various dining contexts, from calm instructional menus to upbeat promotional announcements.

We cover the technical essentials: generating your API key, configuring the OpenAI SDK, and handling rate limits for high-volume audio generation. The documentation includes concrete cURL examples and explains how to manage character limits and response formats like MP3 and WAV, ensuring you can deliver clear, natural-sounding audio to your users efficiently.

Generate Audio with Our Text-to-Speech API

Frequently asked questions

What is the base URL for the API?

The API base URL is https://api.svajpa.net/v1. You send POST requests to https://api.svajpa.net/v1/audio/speech. This endpoint accepts JSON bodies with model, input, voice, and other parameters. It follows the same request shape as the OpenAI speech endpoint, allowing you to use existing OpenAI SDKs by simply changing the base_url configuration.

Do I need the OpenAI SDK to use this API?

No, you do not need the OpenAI SDK. You can use any HTTP client to send POST requests to the speech endpoint. However, the official OpenAI SDKs work perfectly if you update the base_url to https://api.svajpa.net/v1. This allows you to use familiar code structures without learning a new library from scratch.

How do I set the language in the request?

Include the 'language' field in your JSON body 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 English, Spanish, German, and 20 others.

Can I change the speed of the audio?

Yes, you can adjust the speed using the 'speed' parameter in the request body. The valid range is 0.25 to 4.0. A value of 1.0 is normal speed. Lower values slow down the narration, while higher values increase it. This allows you to fine-tune the pacing for your specific dining platform use case.

What happens if I exceed the rate limit?

The rate limit is 60 requests per minute per key. If you exceed this, requests may be queued or rejected. New accounts start with a limit of 10 requests per minute until the first top-up. Exceeding the limit does not incur extra charges, but it may delay audio generation if requests are queued behind others.

Is the API compatible with Python SDKs?

Yes, it is compatible with the official OpenAI Python SDK. You can use it by setting the base_url to https://api.svajpa.net/v1. The request shape matches the OpenAI speech endpoint exactly. This allows you to leverage existing Python libraries and code patterns for integrating text-to-speech into your restaurant or dining applications.

Can I request audio in FLAC format?

Yes, you can request audio in FLAC format by setting the 'response_format' parameter to 'flac'. Other supported formats include mp3, wav, opus, and pcm. FLAC provides lossless compression, which is useful for high-quality archival or professional audio workflows.

How do I rotate my API key?

You can issue a new API key from your account dashboard at any time. When a new key is issued, the old one stops working immediately. This ensures that only active keys are used. You can manage your keys and view your balance and usage statistics on the /get-api-key/ page of the site.

What is the maximum character limit per request?

The maximum character limit per request is 4096 characters. If your text exceeds this limit, you must split it into parts of up to 4096 characters and join the resulting audio files. Spaces and punctuation count towards the character limit. This ensures efficient processing and predictable billing for your audio generation tasks.

Do I need to handle streaming manually?

No. The API returns the complete audio file in the response, so you must wait for the full file to be generated before playing it. There is no WebSocket or real-time partial audio support. You receive the full audio data once synthesis is complete. This simplifies implementation, as you just download the file and play it.

Are there headers required for requests?

Yes, you must include the 'Authorization: Bearer tts-...' header with your API key. This authenticates your request. The key is provided in your account dashboard. Without this header, the API will reject your request. Ensure the header is correctly formatted to avoid authentication errors during your integration.

How do I test the API before production?

Sign up with Google to receive $0.50 of trial credit, valid for 7 days. This allows you to test the API without immediate payment. Use the curl example provided on the /get-api-key/ page. You can experiment with different voices, formats, and speeds to find the best fit for your dining platform.

Is there a sandbox environment?

There is no separate sandbox environment. The API endpoint is the same for testing and production. You can use your trial credit or top-up balance to test in the live environment. This ensures that your testing reflects the actual production experience, including latency and response formats, without needing to manage multiple endpoints.

How do I handle audio playback in the app?

Receive the audio file in the requested format (mp3, wav, etc.) from the response body. Save it to a temporary file or stream it directly to your audio player. Since there is no streaming endpoint, you must wait for the full file to be generated. Then, play the file using standard HTML5 audio or native player components.

First request

curl

curl https://api.svajpa.net/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.svajpa.net/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.svajpa.net/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 relies on a single active API key per account, issued via the /get-api-key/ dashboard. This key authorizes all requests to the speech endpoint and tracks your usage balance against the character-based pricing model.

Each request must include the key in the HTTP header as a Bearer token. The system validates this token before processing your text, ensuring only authorized accounts can generate audio files.

API Key Generation

API Key Generation

Sign up on the /get-api-key/ page using Google or email to receive your initial key. Accounts created with email do not start with trial credit, while Google sign-ins receive $0.50 valid for seven days.

Bearer Token Usage

Bearer Token Usage

Include your key in every request header: Authorization: Bearer tts-.... This token is the sole identifier for your account, linking all generated audio to your specific billing profile and usage limits.

  • Format: Authorization: Bearer tts-<your_key>
  • Case-sensitive string provided in your dashboard

Key Rotation

Issue a new key from your dashboard at any time. The new key becomes active immediately, and the previous one stops working at once. This allows instant revocation without downtime.

Endpoint Overview

Sound wave illustration for: Endpoint Overview

The API exposes three primary endpoints to manage your text-to-speech workflow. Each endpoint serves a distinct purpose, from generating audio files to retrieving metadata about available voices and models.

Speech Endpoint

POST https://api.svajpa.net/v1/audio/speech accepts your text and voice parameters, returning an audio file. It follows the standard JSON request shape, allowing you to use existing OpenAI SDKs by simply changing the base URL.

Voices Endpoint

GET /v1/voices returns the full list of eight presets, supporting 23 languages. This endpoint provides the necessary details to select the correct voice and format for your specific use case without guessing.

Models Endpoint

GET /v1/models lists the available generation engines. Currently, this includes "tts-1" and "tts-1-hd," which share the same engine and pricing structure, simplifying your integration logic.

Request Parameters

Sound wave illustration for: Request Parameters

Configure the core synthesis parameters to balance audio quality, voice character, and input constraints. The API requires specific model, voice, and text inputs to generate the final audio file.

Model Selection

Choose between tts-1 for standard efficiency or tts-1-hd for higher fidelity. Both models use the same underlying engine and incur identical pricing, so select based on your bandwidth and quality preferences.

Voice Selection

Select one of eight presets, such as nova for upbeat restaurant promos or atlas for neutral news updates. Each voice supports all 23 languages; if language is omitted, the system guesses from the script, defaulting to English for Latin text.

Input Text Limits

Each request accepts up to 4,096 characters of input text. For longer scripts, split the text into chunks, generate each part, and join the resulting audio files. Spaces and punctuation count toward this limit.

Response Formats

Sound wave illustration for: Response Formats

Choose the output format that best balances quality and bandwidth for your dining platform. The API supports five standard audio codecs, allowing you to optimize delivery for mobile apps or web players without re-encoding.

MP3 Output

MP3 is the default format, offering broad compatibility with nearly all web browsers and mobile devices. It provides a good balance between file size and audio fidelity, making it ideal for general-purpose restaurant menus or promotional content.

WAV Output

WAV delivers uncompressed, lossless audio with perfect fidelity. Use this format when you need the highest quality for local playback or further editing, though file sizes will be significantly larger compared to compressed options.

Opus and FLAC

Opus provides excellent compression for audio files, suitable for low-bandwidth environments. FLAC offers lossless compression, retaining full audio quality while reducing file size compared to WAV. Select these based on your storage and bandwidth constraints.

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

The official OpenAI SDKs work seamlessly with our API by simply adjusting the base URL. This allows indie developers to use familiar code structures without learning a new client library.

We provide the SDK for convenience; our API follows the same request shape as OpenAI’s speech endpoint. You only need to point the client to our endpoint and supply your API key.

Base URL Configuration

Set the base URL to https://api.svajpa.net/v1. This directs all requests to our infrastructure while maintaining compatibility with standard OpenAI SDK methods.

Client Initialization

Initialize the client with your API key using the standard environment variable or direct argument. Ensure the key starts with tts- and is active.

Accounts created with email start without trial credit; Google sign-ins receive $0.50. Use the key from your dashboard to authenticate requests.

Request Structure

Pass parameters like model, input, and voice exactly as defined in our endpoint specification. The SDK handles serialization automatically.

Use tts-1 or tts-1-hd for the model. The API returns audio files directly, so no additional parsing is needed beyond saving the response.

Using the OpenAI SDK

cURL Example

Sound wave illustration for: cURL Example

cURL commands provide a direct, transparent way to test the TTS endpoint before integrating into your restaurant platform’s backend. By sending simple HTTP requests, you can verify voice output quality and latency without writing complex application code first.

Basic Request

Use this command to generate speech using the default model. Replace YOUR_API_KEY with your key from /get-api-key/.

  • ```bash
  • curl -X POST https://api.svajpa.net/v1/audio/speech \
  • -H "Authorization: Bearer YOUR_API_KEY" \
  • -H "Content-Type: application/json" \
  • -d '{"model": "tts-1", "input": "Welcome to our dining hall.", "voice": "nova"}' \
  • --output audio.mp3

Language Specification

Explicitly set the language to ensure correct pronunciation, especially for Latin-script texts that are not English. For example, to generate Dutch audio, add the language field to your JSON payload.

  • ```bash
  • curl -X POST https://api.svajpa.net/v1/audio/speech \
  • -H "Authorization: Bearer YOUR_API_KEY" \
  • -d '{"model": "tts-1", "input": "Welkom bij ons restaurant.", "voice": "aria", "language": "nl"}' \
  • --output audio.mp3

Speed Adjustment

Adjust the speed parameter between 0.25 and 4.0 to match the desired pacing of your audio menu. Faster speeds suit quick notifications, while slower rates improve clarity for complex dish descriptions.

  • ```bash
  • curl -X POST https://api.svajpa.net/v1/audio/speech \
  • -H "Authorization: Bearer YOUR_API_KEY" \
  • -d '{"model": "tts-1", "input": "The special today is grilled salmon.", "voice": "sage", "speed": 0.8}' \
  • --output audio.mp3

Error Handling

Sound wave illustration for: Error Handling

Errors are handled gracefully to ensure your restaurant app remains stable. Failed synthesis requests are free, with the charge returned in full if the API cannot process the audio.

Common Error Codes

We return standard HTTP status codes. A 400 Bad Request indicates invalid JSON or missing fields like input or voice. A 401 Unauthorized means your Bearer token is missing or invalid. Check your dashboard at /get-api-key/ to verify your active key.

  • 400: Invalid request body
  • 401: Unauthorized (bad key)
  • 500: Internal server error

Retry Logic

Implement exponential backoff for 500 errors. Since requests are processed sequentially, short delays help avoid contention. Remember, failed requests incur no cost, so retrying is safe even if the input text is long.

Rate Limit Errors

You are limited to 60 requests per minute per key. If you exceed this, the API returns a 429 Too Many Requests error. New accounts start with 10 requests per minute until the first top-up.

  • Standard limit: 60 req/min
  • Initial limit: 10 req/min
  • Exceeded status: 429

Rate Limits and Queues

Sound wave illustration for: Rate Limits and Queues

Synthetic voice generation is processed sequentially, meaning requests are handled one after another. While typical processing speed matches real-time audio generation, complex or long texts may experience slight delays as they wait in line behind previous submissions.

60 Requests Per Minute

Each API key is limited to 60 requests per minute. New accounts start with a lower threshold of 10 requests per minute until the first top-up is processed. This limit applies per key, so rotating keys does not increase your aggregate throughput.

  • Standard limit: 60 requests/minute
  • Initial limit: 10 requests/minute
  • Limit resets every 60 seconds

Queue Behavior

Requests are processed in the order received. If you exceed the rate limit, additional requests are queued until capacity becomes available. There is no priority queue; all requests are treated equally regardless of voice model or audio format.

Load Management

To ensure consistent performance for restaurant audio features, distribute your requests evenly. Avoid bursty traffic patterns that might trigger queuing delays. For large-scale menu announcements, consider splitting texts into smaller chunks sent at a steady pace.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. The voice is neutral yet deep, avoiding excessive emotion or brightness.

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. Creative Commons Attribution 4.0
  4. ISO 639 language codes
  5. OpenAI API reference: create speech
  6. Tether (USDT)
  7. openai-python on GitHub
  8. W3C WAI: making audio and video accessible
  9. LibriTTS-R paper (arXiv 2305.18802)
  10. IETF RFC 7845: Ogg Opus
  11. LibriTTS-R corpus (OpenSLR 141)
  12. Node.js documentation

More on this site