API Documentation for AI Voice Generation

By PetVoice editorial team · Updated 2026-11-19

This documentation guides indie developers building AI voice features for elderly care and assistive devices. You will learn how to get your API key, make your first request, and integrate PetVoice API into your application using standard tools.

We provide clear, calm synthetic speech with licensed human recordings and no complex setup required. The API delivers audio files directly, supporting common formats and languages, so you can focus on user experience rather than infrastructure.

API Documentation for AI Voice Generation

Frequently asked questions

How do I get my API key?

Sign up on the /get-api-key/ page using Google or an email and password. Your account is specific to 789pet.info. The dashboard displays your active API key, current balance, and usage statistics immediately after registration.

Can I use the Python SDK?

Yes, the official OpenAI Python SDK works perfectly. Simply change the base_url to https://api.789pet.info/v1 and provide your PetVoice API key. This allows you to use familiar code structures without needing a custom library.

What is the character limit?

Each request supports up to 4,096 characters. For longer texts, split the input into parts within this limit and join the resulting audio files. This ensures consistent synthesis quality and manageable processing times for your application.

How do I handle errors?

Failed requests are free; the charge is returned in full if synthesis fails. Check the HTTP status code and response body for details. Ensure your text is under 4,096 characters and your API key is valid.

Is the API RESTful?

Yes, it is a standard RESTful API. You send a POST request to /v1/audio/speech with a JSON body and receive an audio file. Other endpoints like /v1/voices are also available for listing available voices and languages.

Do I need JSON or form data?

You must use JSON for the request body. Include fields like model, input, voice, and response_format as JSON objects. The API expects this specific structure to process your text-to-speech request correctly and efficiently.

Can I stream the audio?

No, streaming or WebSocket support is not available. The API returns the complete audio file in the response. You must wait for the full generation to complete before receiving the data, which may take a few seconds for short phrases.

How do I test with curl?

Use the example provided on your dashboard. Typically, it looks like: `curl -X POST https://api.789pet.info/v1/audio/speech -H "Authorization: Bearer YOUR_KEY" -d '{"model": "tts-1", "input": "Hello", "voice": "aria"}'`. Replace YOUR_KEY with your actual key.

What models are available?

Two models are available: tts-1 and tts-1-hd. Both use the same engine and pricing. Choose tts-1-hd or tts-1; they use the same engine and price. They support all eight voice presets and 23 languages.

Can I change the base URL?

Yes, when using SDKs like OpenAI’s, set the base_url to https://api.789pet.info/v1. This directs requests to our infrastructure while keeping the standard endpoint paths like /audio/speech and /voices intact for your integration.

Is authentication required?

Yes, every request requires an Authorization: Bearer tts-... header with your active API key. You can generate a new key at any time via the dashboard; the old key stops working immediately upon issuing the new one.

How do I rotate my API key?

Go to the /get-api-key/ page and issue a new key. The old key stops working immediately when the new one is active. This ensures secure access without downtime, as you simply update the key in your application.

What happens on rate limit?

You are limited to 60 requests per minute per key (10 before the first top-up). If you exceed this, requests may queue. Monitor your usage on the dashboard to avoid interruptions in your voice features.

Do I need a backend?

A backend is not strictly required, but recommended for hiding your API key. You can call the API directly from a client if you manage key exposure. The API handles JSON requests and returns audio files directly.

First request

curl

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

Get your API key

Sound wave illustration for: Get your API key

Start by visiting the /get-api-key/ page to create your account. You can sign up using Google for immediate access to $0.50 in trial credit, valid for 7 days, or use an email and password for a standard account without initial credit.

Once registered, navigate to the dashboard to locate your unique API key. This key authenticates your requests to the PetVoice API and is required for all subsequent interactions with the endpoint.

Sign up with Google for trial credit

Sign up with Google for trial credit

Click the Google sign-in button on the registration page. Upon verification, you receive $0.50 in credit (approx. 50,000 characters) valid for 7 days, allowing you to test the API immediately without payment details.

Use email and password for standard account

Use email and password for standard account

Select the email registration option if you prefer not to use Google. Accounts created this way start with zero balance and no trial credit. You will need to top up via USDT (TRC-20) before making your first request.

Find your key on the dashboard

After logging in, the dashboard displays your active API key. You can copy this key for use in your applications. Note that issuing a new key immediately invalidates the previous one, so update your configuration promptly if you rotate keys.

  • Key format: tts-...
  • One active key per account
  • New keys invalidate old ones instantly

Make your first request

Sound wave illustration for: Make your first request

Your first call is straightforward. Send a POST request to the speech endpoint with your text, chosen voice, and format preferences. The API returns the audio file directly in the response body, ready for immediate playback in your assistive device or elderly care application.

You can test this quickly using the provided curl command. Ensure your API key is included in the Authorization header. The system validates your input and generates the audio, returning it as a binary stream matching your requested format.

Use the provided curl example

Copy the example command from your dashboard. Replace YOUR_API_KEY with your actual key. Adjust the text and voice parameters to match your use case. This command works for any supported language and voice preset.

  • Replace placeholder values with your actual credentials
  • Test with a short phrase like "Hello, how are you?"
  • Verify the response contains audio data

Send text and voice selection

Include your text in the input field. Select one of the eight preset voices, such as Luna for storytelling or Atlas for news. You can also specify the response format, speed, and optional language code. The API handles the rest.

  • Input: Text up to 4096 characters
  • Voice: Choose from 8 presets
  • Format: mp3, wav, opus, flac, or pcm

Receive audio file in response

The API returns the audio file directly in the response body. You can save this file or stream it directly to your application. The audio is generated quickly, typically within seconds for short phrases. No additional processing is needed.

  • Response format: Binary audio data
  • Supported formats: mp3, wav, opus, flac, pcm
  • Immediate playback capability

Use with OpenAI SDK

Sound wave illustration for: Use with OpenAI SDK

Integrating PetVoice with the official OpenAI SDK is straightforward. By pointing the client to our API domain, you leverage familiar libraries for synthetic speech generation without learning a new interface.

This approach keeps your codebase clean, using standard HTTP clients to handle requests and receive audio data efficiently in your elderly care or assistive device applications.

Set base_url to our API domain

Configure your OpenAI client's base_url to https://api.789pet.info/v1. This redirects all API calls to our infrastructure while maintaining compatibility with the standard request shape.

Ensure your API key is passed via the Authorization: Bearer header. The SDK handles the rest, sending your text payload directly to our speech endpoint.

  • Base URL: https://api.789pet.info/v1
  • Auth Header: Authorization: Bearer tts-...

Use official OpenAI client library

Install the standard openai Python or JavaScript library. No custom SDK is required; the official package works seamlessly by simply changing the base URL.

This allows you to use existing examples and patterns, reducing integration time for indie developers building assistive voice features.

Same request structure as OpenAI

Your request body mirrors the OpenAI speech endpoint: model, input, voice, response_format, and speed. Use tts-1 or tts-1-hd as the model value.

The API accepts these fields exactly as documented, ensuring consistent behavior with standard TTS implementations. Audio is returned directly in the response body.

Supported audio formats

Sound wave illustration for: Supported audio formats

PetVoice API returns audio in the format you specify via the response_format parameter. Choose the output type that best fits your elderly care app’s technical constraints and playback environment.

MP3 for web and mobile apps

MP3 is the standard choice for web browsers and mobile applications. It offers a good balance between file size and audio quality, ensuring smooth playback without excessive data usage.

WAV for high-quality local playback

WAV provides uncompressed audio, ideal for local playback or applications requiring raw data. It preserves the full fidelity of the synthesized voice, suitable for assistive devices with high-quality speakers.

OPUS and FLAC for efficient storage

Use OPUS for efficient, low-bitrate audio or FLAC for lossless compression. These formats reduce storage costs for your generated audio files while maintaining high audio integrity for archival or offline use.

Rate limits and performance

Sound wave illustration for: Rate limits and performance

PetVoice API enforces strict rate limits to ensure stable voice generation for your assistive devices. Your API key allows up to 60 requests per minute once you have topped up, providing sufficient throughput for most indie applications.

60 requests per minute per key

After your initial period, you can send 60 requests per minute. This limit applies per API key, so ensure you manage your keys efficiently across your development and production environments.

10 requests per minute initially

New accounts start with a lower limit of 10 requests per minute. This allows you to test integration without overwhelming the system. Once you add funds, the limit increases to 60 requests per minute.

  • Start with 10 requests per minute
  • Top up to reach 60 requests per minute
  • Limit applies per API key

Queue handling under load

Requests are processed sequentially. If you exceed the rate limit or if the system is under heavy load, your request may wait in a queue. This ensures that each voice generation is completed accurately without data loss.

Rate limits and performance

Handling long texts

Sound wave illustration for: Handling long texts

Long-form content is common in assistive reading applications. Since each API request accepts a maximum of 4,096 characters, you must divide your text into smaller segments before sending them to the endpoint.

Split text into 4096-character chunks

Break your input string at natural boundaries, such as spaces or punctuation, ensuring no single chunk exceeds the 4,096-character limit. This ensures every request stays within the defined payload constraints.

Generate each part separately

Submit each chunk as an individual POST request. Because requests are processed sequentially, longer texts may queue behind other traffic, so be prepared for slight delays between generations.

Join audio files client-side

The API returns one audio file per request. Your client application must concatenate the returned audio streams in the correct order to create a continuous playback experience for the user.

Error codes and handling

Sound wave illustration for: Error codes and handling

Handling errors gracefully ensures your assistive devices or elderly care apps remain responsive. PetVoice API returns standard HTTP status codes to help you debug issues quickly, from authentication problems to temporary server hiccups. Understanding these responses helps you maintain a smooth user experience without unnecessary delays.

Most errors are transient. By checking the status code and response body, you can decide whether to retry the request, prompt the user, or adjust parameters like text length or voice selection. Failed synthesis requests are free, so retrying is cost-effective.

401 for invalid API keys

A 401 Unauthorized response indicates your API key is missing, incorrect, or has been revoked. Ensure you are passing the correct Authorization: Bearer tts-... header with every request. If you issued a new key, the old one stops immediately.

  • Check for typos in your key string.
  • Verify the header format is exactly Authorization: Bearer <key>.
  • Regenerate a key from the dashboard if needed.

429 for rate limit exceeded

You receive a 429 Too Many Requests error when exceeding your quota. New accounts start with 10 requests per minute, increasing to 60 per minute after a top-up. Requests are processed sequentially, so under load, you may queue briefly before hitting the limit.

  • Implement exponential backoff for retries.
  • Monitor your usage via the dashboard.
  • Top up USDT on TRON to increase your limit to 60 req/min.

500 for synthesis failures

If the server cannot process the text due to internal issues, you receive a 500 error. The charge is returned in full, so you can retry or adjust the input text. This ensures you only pay for successfully generated audio.

Voice and language parameters

Sound wave illustration for: Voice and language parameters

PetVoice API supports 23 languages including Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, and Turkish. If the language field is omitted, the system guesses the language from the script, defaulting to English for Latin text. You should explicitly set the language for non-English Latin-script text to ensure accurate synthesis.

We provide eight preset voices designed for clarity and calmness, suitable for elderly care and assistive devices. Female voices include Aria, Nova, Luna, and Sage, while male options are Felix, Milo, Atlas, and Orion. These voices are based on licensed recordings from LibriTTS-R and LibriVox.

Select from 8 preset voices

Choose from eight distinct presets to match your application's tone. Female options include Aria (warm narrator), Nova (upbeat), Luna (soft storytelling), and Sage (calm instruction). Male voices offer Felix (energetic), Milo (friendly), Atlas (neutral news), and Orion (deep documentary).

All voices support all 23 listed languages. Each generated audio file contains an inaudible watermark identifying it as synthetic speech.

  • Aria: Warm, clear narrator
  • Nova: Bright, upbeat
  • Luna: Soft, storytelling
  • Sage: Calm, instructional
  • Felix: Energetic, promo
  • Milo: Friendly, conversational

Set optional language code

You can pass an optional ISO language code to guide the synthesis engine. If omitted, the system infers the language from the script, assuming English for Latin characters. For accurate results with non-English Latin-script text, always specify the language parameter.

Adjust speed from 0.25x to 4.0x

The speed parameter accepts values between 0.25 and 4.0, allowing you to slow down speech for clarity or accelerate it for brevity. Standard generation speed is roughly real-time, processing about 25 characters per second for long texts.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Use upbeat voices for alerts and calm voices for instructions.

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. LibriTTS-R corpus (OpenSLR 141)
  4. curl documentation
  5. Creative Commons Attribution 4.0
  6. openai-node on GitHub
  7. IETF RFC 7845: Ogg Opus
  8. W3C WAI: making audio and video accessible
  9. ISO 639 language codes
  10. LibriVox public-domain audiobooks
  11. Python documentation
  12. Tether (USDT)

More on this site