API Documentation for Text-to-Speech Integration

By Ak24hr editorial team · Updated 2026-11-19

This documentation provides the technical specifications for integrating SpeakBlog’s text-to-speech API into your WordPress environment or custom applications. You will find precise details on authentication, endpoint structures, and supported audio formats required to generate consistent audio for blog posts and video content.

The guide targets developers and no-code users who require reliable, scalable audio generation without manual recording. It includes concrete examples for Python, JavaScript, and cURL, along with explanations of rate limits and error handling to ensure smooth integration with your existing workflows.

API Documentation for Text-to-Speech Integration

Frequently asked questions

What is the API endpoint URL?

The primary endpoint for generating audio is POST https://api.ak24hr.cc/v1/audio/speech. You send a JSON body containing the text, voice selection, and format preferences. This endpoint processes your request and returns the generated audio file directly in the response, allowing you to integrate TTS into your applications or workflows efficiently.

How do I authenticate my requests?

Include your API key in the request header using the format: Authorization: Bearer tts-... You receive one active key per account. If you need a new key, you can issue it at any time via your dashboard; the previous key stops working immediately upon generation of the new one.

Which model should I use for high quality?

Select the tts-1-hd model for high-quality audio. Both tts-1 and tts-1-hd use the same engine and pricing structure. Both models use the same engine and price ($0.01 per 1,000 characters).

Can I use the OpenAI SDK with this API?

Yes, the API uses the same request shape as the OpenAI speech endpoint. You can use official OpenAI SDKs by changing the base_url to https://api.ak24hr.cc/v1 and providing your SpeakBlog API key. This allows seamless integration without requiring a custom SDK or learning a new request structure.

What happens if I exceed the rate limit?

The standard limit is 60 requests per minute per key. Before your first top-up, the limit is 10 requests per minute. Requests are processed sequentially, so under load, your request may wait in a queue. Failed requests are free: if synthesis fails, the charge is returned in full.

How do I specify a different language?

Include the optional language parameter with an ISO code in your request body. If omitted, the system guesses the language from the script, defaulting to English for Latin text. For non-English Latin-script text, explicitly setting the language parameter ensures accurate synthesis and prevents misinterpretation by the engine.

What audio formats are supported?

You can choose from mp3, wav, opus, flac, and pcm formats. Specify your preferred format using the response_format field in the JSON body. This flexibility allows you to select the optimal file type for your specific use case, whether it is web delivery, archival, or further audio processing.

How do I handle API errors?

If synthesis fails, the charge is returned in full. Monitor your response status codes to identify issues. Failed requests do not deduct from your character balance. Ensure your text is within the 4096 character limit and your API key is valid to minimize common errors during generation.

Is the API compatible with WordPress plugins?

The API is compatible with any tool that can send HTTP requests. There is no official WordPress plugin, but you can use existing no-code tools that support custom API endpoints. Simply configure the plugin to point to https://api.ak24hr.cc/v1/audio/speech with your API key and required JSON body.

Can I generate audio in real-time?

No, the API does not support streaming or WebSocket connections for real-time partial audio. Audio is generated and returned as a complete file after processing. Typical speed is roughly real-time for long texts, but short phrases may take a few seconds due to sequential processing and potential queuing.

How do I rotate my API key?

You can issue a new API key at any time via your account dashboard. When a new key is generated, the old one stops working immediately. This ensures that your previous key cannot be used for further requests, providing a secure method for rotating credentials without downtime in your integration.

What is the maximum text length per request?

The maximum input text length is 4096 characters per request. For longer texts, you must split the content into parts of up to 4096 characters, generate audio for each part, and join the resulting audio files. Spaces and punctuation count toward the character limit for billing purposes.

Does the API support streaming audio?

How do I check available voices?

Send a GET request to https://api.ak24hr.cc/v1/voices. This endpoint returns a list of available voices, supported languages, formats, and pricing details. You can use this information to select the appropriate voice preset, such as aria, nova, or atlas, for your specific content requirements.

First request

curl

curl https://api.ak24hr.cc/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.ak24hr.cc/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.ak24hr.cc/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 and API Keys

Sound wave illustration for: Authentication and API Keys

Accessing the SpeakBlog API requires a valid API key for authentication. Generate your key via the /get-api-key/ page using Google or email credentials. Each account maintains one active key at a time, ensuring secure and traceable usage across your WordPress or no-code workflows.

The key is transmitted via the HTTP Authorization header. This standard method ensures compatibility with existing no-code integrations and simplifies token management for blog audio pipelines without requiring custom middleware.

Generating Your API Key

Generating Your API Key

Navigate to the /get-api-key/ page on ak24hr.cc. Sign in using Google or create an email/password account. The dashboard displays your current API key, balance, and usage statistics immediately upon access.

Accounts created via email do not receive the $0.50 trial credit; Google sign-ins do. Ensure your payment method is configured for top-ups if you exceed the free tier.

  • Sign in via Google or email/password
  • View key in the dashboard
  • Trial credit applies to Google sign-ins only

Bearer Token Authorization

Bearer Token Authorization

Include your key in every request header: Authorization: Bearer tts-.... The API validates this token against the account associated with the key. All requests to https://api.ak24hr.cc/v1 require this header.

Incorrect or missing tokens result in a 401 Unauthorized error. Ensure the key is passed exactly as generated, without extra spaces or line breaks.

  • Header: Authorization: Bearer tts-...
  • One active key per account
  • Returns 401 if invalid

Key Rotation Policy

You can issue a new API key at any time from the dashboard. Upon generation, the previous key becomes invalid immediately. This allows zero-downtime rotation if a key is compromised.

No deprecation period applies. Update your WordPress plugins or no-code automation tools to use the new key immediately after generation to prevent request failures.

  • Issue new key anytime
  • Old key invalid immediately
  • Update integrations instantly

Endpoint: POST /v1/audio/speech

Sound wave illustration for: Endpoint: POST /v1/audio/speech

The POST /v1/audio/speech endpoint accepts JSON requests and returns synthesized audio files. The request body defines the synthesis parameters, including the text input, voice selection, and output format. This endpoint is the primary method for generating audio content from text data.

Request Body Structure

Send a JSON object to the endpoint. The structure mirrors the OpenAI speech API, ensuring compatibility with existing tools. The request must include the text to be spoken and the desired audio format.

  • Content-Type: application/json
  • Authorization: Bearer tts-<key>
  • Body: JSON object with model, input, voice, response_format, and speed fields

Required Fields: Model and Input

The model field accepts either tts-1 or tts-1-hd, both using the same engine and pricing. The input field contains the text to be converted, limited to 4096 characters per request. Longer texts must be split into parts and joined manually.

Optional Parameters: Voice and Speed

The voice parameter selects one of eight presets, such as aria for narration or felix for promos. The speed parameter adjusts playback rate from 0.25 to 4.0. The language field is optional but recommended for non-English Latin script text to ensure accurate pronunciation.

Supported Models and Voices

Sound wave illustration for: Supported Models and Voices

The API provides two model options, tts-1 and tts-1-hd, which utilize the same engine and pricing structure. This simplifies integration by allowing consistent billing regardless of the selected quality tier. Both models process input text up to 4096 characters per request, ensuring uniform behavior across different audio generation settings.

tts-1 and tts-1-hd Options

Both models share identical performance characteristics and pricing, charging $10 per million characters. The distinction lies only in the output quality; both use the same engine and price. This allows developers to switch models without adjusting billing logic or request parameters.

Voice Selection Presets

Eight voice presets are available, including female options like aria and nova, and male options like atlas and milo. Each voice is based on licensed recordings from LibriTTS-R and LibriVox public-domain audiobook readings. Generated audio files contain an inaudible watermark indicating synthetic speech.

  • aria: warm, clear narrator
  • nova: bright, upbeat
  • luna: soft, storytelling
  • sage: calm, instructional
  • felix: energetic, promo
  • milo: friendly, conversational
  • atlas: neutral, news
  • orion: deep, documentary

Language Code Specification

The API supports 23 languages, including English, Spanish, German, French, Japanese, and Korean. If the language parameter is omitted, the system guesses the language from the text script, defaulting to English for Latin script. For non-English text using Latin characters, explicitly setting the language code is recommended.

Response Formats and Audio Output

Sound wave illustration for: Response Formats and Audio Output

The API returns audio files in five supported formats: MP3, WAV, OPUS, FLAC, and PCM. Select the response_format parameter to define the output type. This choice affects file size and compatibility with your WordPress media library or video editing pipeline.

Audio is delivered as a binary stream within the HTTP response body. The system does not store the generated file; you receive it directly for immediate use or download. No persistent storage link is provided after the response completes.

MP3, WAV, OPUS, FLAC, PCM

Choose from MP3 for compressed web delivery, WAV for uncompressed quality, OPUS for efficient streaming, FLAC for lossless archives, or PCM for raw data. Each format suits different blog audio workflows and video editing requirements.

The selected format determines the file structure but not the audio content. All voices generate audio at the same quality level regardless of the container format chosen.

  • MP3: Standard compressed format
  • WAV: Uncompressed audio
  • OPUS: Efficient format for web delivery
  • FLAC: Lossless quality
  • PCM: Raw binary data

Audio File Delivery Method

Audio is returned directly in the response body as binary data. There is no intermediate storage or download link generated by the API. You must handle the binary stream immediately upon receipt.

For long texts split into multiple parts, you receive separate audio files. Your application must join these files sequentially to create the final continuous audio track for your blog post.

Content-Type Headers

The response includes a Content-Type header matching the requested format (e.g., audio/mpeg for MP3). Use this header to correctly save the file or embed it in your HTML5 audio player.

Ensure your client code respects the content type to avoid playback issues in WordPress media players or video editing software.

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

Your API key allows up to 60 requests per minute under normal conditions. Each request processes text sequentially, meaning generation time depends on input length. Typical synthesis runs at roughly real-time speed, approximately 25 characters of text per second of audio generated.

60 Requests Per Minute Limit

Requests are processed one after another. If your application sends multiple requests simultaneously, they enter a queue. Under heavy load, a single request may wait behind others before synthesis begins. This sequential processing ensures consistent resource allocation but may introduce latency during peak usage periods.

Queuing Under Load

During high traffic, requests accumulate in a queue. The system processes them in order of arrival. Longer texts take more time to synthesize, so a queue of long-form articles will delay subsequent requests. Short phrases typically require only a few seconds, but concurrent volume affects total wait time.

Pre-Top-Up Rate Limit

Accounts without a top-up are limited to 10 requests per minute. This lower limit applies until you add funds via USDT on the TRON network. Once your balance is updated, the limit automatically increases to the standard 60 requests per minute for your active key.

Rate Limits and Quotas

Error Handling and Status Codes

Sound wave illustration for: Error Handling and Status Codes

The API returns specific HTTP status codes to indicate request outcomes. Understanding these errors ensures your integration handles failures gracefully without unnecessary retries or billing disputes.

400 Bad Request Errors

This error indicates invalid input parameters. Common causes include exceeding the 4096-character limit for the input field or providing an invalid voice preset. Ensure your text payload fits within the specified character count.

401 Unauthorized Errors

Returned when the Authorization header is missing or contains an invalid API key. Verify that your key starts with tts- and matches the active key for your account. Note that generating a new key immediately invalidates the previous one.

429 Too Many Requests

Triggered when you exceed the rate limit of 60 requests per minute. Requests are processed sequentially, so high volume may cause queuing delays before the limit is hit. New accounts without a top-up start with a stricter limit of 10 requests per minute.

Integration with OpenAI SDK

Sound wave illustration for: Integration with OpenAI SDK

SpeakBlog’s API mirrors the OpenAI speech endpoint structure, allowing developers to reuse existing client libraries without rewriting core logic. By adjusting the base URL, you can route requests to our infrastructure while maintaining standard request shapes and response formats.

Setting the Base URL

Configure your SDK client to point to https://api.ak24hr.cc/v1 instead of the default OpenAI endpoint. This ensures that all subsequent API calls, including voice synthesis, are processed by our TTS infrastructure while preserving the standard JSON payload structure.

Using Official SDKs

The official OpenAI SDKs function correctly with this configuration. Simply update the base_url parameter in your client initialization. This approach eliminates the need for custom HTTP clients or complex middleware, enabling immediate integration into existing Python or JavaScript environments.

Configuration Examples

See the code examples in the next section for Python and JavaScript implementations. Ensure your API key is passed via the Authorization: Bearer header. The SDK handles the remaining request formatting automatically.

Code Examples and CURL Requests

Sound wave illustration for: Code Examples and CURL Requests

The API accepts standard JSON payloads to generate audio files. You can send a POST request with your text, selected voice, and output format. The system processes the request and returns the audio file directly in the response body.

For developers using Python or JavaScript, the OpenAI SDKs work seamlessly by pointing to the SpeakBlog base URL. This allows for easy integration into WordPress plugins or custom blog themes without requiring a dedicated SDK.

Basic CURL Command

Use this command to generate speech instantly. Replace YOUR_API_KEY with your actual key.

```bash curl -X POST https://api.ak24hr.cc/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"}' ```

Python SDK Example

Configure the base URL to use the OpenAI client for SpeakBlog. This ensures compatibility with existing codebases.

```python import openai client = openai.OpenAI(api_key="YOUR_API_KEY", base_url="https://api.ak24hr.cc/v1") with client.audio.speech.create( model="tts-1", voice="nova", input="Text to speech for blogs." ) as response: response.stream_to_file("output.mp3") ```

JavaScript Fetch Example

Use the native Fetch API to send requests. This method works in any modern browser or Node.js environment.

```javascript fetch('https://api.ak24hr.cc/v1/audio/speech', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'tts-1', voice: 'nova', input: 'Blog content audio generation.' }) }) .then(res => res.blob().then(blob => blob.arrayBuffer())) .then(audioBuffer => { /* process audio */ }); ```

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. By systematically comparing voice performances, you identify which preset resonates best with your specific audience demographic.

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-node on GitHub
  3. curl documentation
  4. LibriTTS-R corpus (OpenSLR 141)
  5. Tether (USDT)
  6. Python documentation
  7. openai-python on GitHub
  8. Node.js documentation
  9. FFmpeg documentation
  10. TRON developer hub: TRC-20
  11. LibriTTS-R paper (arXiv 2305.18802)
  12. MDN: Web Speech API

More on this site