K KokorovDeveloper documentation
Kokorov · Text-to-speech API

Give your application
a voice.

Integrate Kokorov text-to-speech into your product using a simple HTTP API. Submit text, choose a voice and audio format, and receive generated speech as an audio file.

REST API JSON requests Audio responses HTTPS

API base URL

BASE URL
https://Kokorov.duckdns.org
Before you begin

Create an account and wait for activation. Your API key is issued during registration, but speech generation remains unavailable until your account has an active subscription.

Quick start

Follow these steps to make your first speech-generation request.

  1. Register. Submit your name and email address to receive an account ID and API key.
  2. Wait for activation. Your account starts with pending status. The service provider must activate it and assign a subscription.
  3. Choose a voice. Call GET /voices to retrieve the voices currently available.
  4. Generate speech. Send an authenticated request to POST /v1/tts and save the returned audio.
cURL · GENERATE WAV AUDIO
curl -X POST https://Kokorov.duckdns.org/v1/tts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello! Welcome to Kokorov text to speech.",
    "voice": "af_heart",
    "speed": 1.0,
    "format": "wav"
  }' \
  --output speech.wav

Create an account

POST /v1/register

Creates a new customer account. Registration does not require an API key.

Request body

JSON
{
  "name": "John Banda",
  "email": "john@example.com"
}
FieldTypeRules
nameStringRequired. 1–120 bytes after trimming.
emailStringRequired. Maximum 254 bytes; must contain @.

Successful response

Registration returns HTTP 200 with your account ID and newly generated API key.

JSON · RESPONSE EXAMPLE
{
  "account_id": "KKR-XXXXXXXXXXXXXXX",
  "api_key": "kk_live_YOUR_SECRET_KEY"
}
Save your API key immediately.

Treat it like a password. Store it securely on your backend. Do not expose it in browser JavaScript, mobile app source code, public repositories, or logs.

An email address can only be registered once. A duplicate registration returns HTTP 409 Conflict.

Account activation

New accounts are created with pending status. Your API key is valid for account and usage lookups, but cannot generate speech until the account is activated.

StatusMeaning
pendingRegistration received; awaiting activation.
activeAccount is activated. A valid subscription and remaining quota are still required for synthesis.
suspendedAccount access is suspended.

Contact your Kokorov service provider for activation or subscription questions. Activation, subscription changes, and account administration are handled by the provider.

Authentication

Protected endpoints use Bearer token authentication. Include your API key in the HTTP Authorization header.

HTTP HEADER
Authorization: Bearer YOUR_API_KEY

API keys have the prefix kk_live_. Requests with missing, invalid, or revoked keys are rejected with HTTP 401 Unauthorized.

List voices

GET /voices

Returns the voices currently available on the service. This endpoint does not require authentication.

Example response

JSON
{
  "voices": ["af_heart"]
}

Currently available: af_heart. Always query this endpoint for the latest list before presenting voice choices in your application.

cURL
curl https://Kokorov.duckdns.org/voices

Text to speech

POST /v1/tts

Converts text into an audio file. Requires an active account, a valid API key, and sufficient subscription quota. The /tts route is also available as an authenticated alias.

Request body

FieldTypeRules
text REQUIREDStringMust not be empty. Maximum 2,000 characters.
voice OPTIONALStringDefaults to af_heart. Must match a voice returned by /voices.
speed OPTIONALNumberDefaults to 1.0. Allowed range: 0.5 to 2.0.
format OPTIONALStringDefaults to wav. Supported: wav, mp3, ogg, flac, aac.

Example request

JSON
{
  "text": "Hello! This audio was generated using Kokorov.",
  "voice": "af_heart",
  "speed": 1.0,
  "format": "wav"
}

JavaScript example (Node.js)

This example uses the built-in fetch API available in modern Node.js versions.

JAVASCRIPT
const fs = require("node:fs/promises");

const API_URL = "https://Kokorov.duckdns.org";
const API_KEY = process.env.Kokorov_API_KEY;

async function synthesize(text) {
  const response = await fetch(`${API_URL}/v1/tts`, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      text,
      voice: "af_heart",
      speed: 1.0,
      format: "mp3"
    })
  });

  if (!response.ok) {
    const error = await response.text();
    throw new Error(`Kokorov ${response.status}: ${error}`);
  }

  const audio = Buffer.from(await response.arrayBuffer());
  await fs.writeFile("speech.mp3", audio);
  return audio.length;
}

synthesize("Hello from my application!")
  .then(size => console.log(`Saved ${size} bytes`))
  .catch(console.error);

Successful response

A successful synthesis returns the audio file directly, not JSON. The response includes these headers:

HeaderDescription
Content-TypeMIME type for the selected audio format.
Content-DispositionAttachment filename, such as Kokorov-speech.wav.
Content-LengthAudio response size in bytes.
x-synthesis-msTime spent synthesizing, in milliseconds.
x-audio-formatSelected output format.
Concurrency note

The service currently processes one synthesis request at a time. If another synthesis is running, the API returns HTTP 429 Too Many Requests. Your application should retry after a short delay, using a bounded retry policy.

Account details

GET /v1/account

Returns account information, subscription details when available, and the number of active API keys. Requires authentication.

cURL
curl https://Kokorov.duckdns.org/v1/account \
  -H "Authorization: Bearer YOUR_API_KEY"

The response contains an account object, a subscription object (which may be null), and active_api_keys. Account information includes the account ID, name, email, status, and creation timestamp.

Usage and quota

GET /v1/usage

Returns the account's current status and subscription usage information. Requires authentication.

cURL
curl https://Kokorov.duckdns.org/v1/usage \
  -H "Authorization: Bearer YOUR_API_KEY"

When a subscription exists, usage data includes its character limit, characters used, characters remaining, status, start time, and expiry time. Successful speech-generation requests consume quota based on the number of characters submitted.

Audio formats

Choose the output format using the format request field. If omitted, the API returns WAV.

FormatContent typeFile extension
wavaudio/wav.wav
mp3audio/mpeg.mp3
oggaudio/ogg.ogg
flacaudio/flac.flac
aacaudio/aac.aac

Format names are case-insensitive. Unsupported formats return HTTP 400 Bad Request.

Errors

Errors are returned with an appropriate HTTP status and a message describing the problem.

StatusMeaningWhat to do
400Invalid input, voice, speed, or format.Check your request fields and allowed values.
401Missing, invalid, or revoked API key.Check your Bearer token.
403Account inactive or subscription/quota restriction.Check account status and contact your provider if needed.
409Email already registered.Use the existing account.
413Text exceeds 2,000 characters.Split the text into smaller requests.
422Speech synthesis failed.Retry carefully; contact support if it persists.
429Another synthesis is currently running.Wait briefly and retry.
500Internal server or audio conversion error.Retry later and contact support if persistent.

Security best practices

  • Keep API keys on your server. Never embed them in public frontend code.
  • Use environment variables or a secrets manager to store credentials.
  • Use HTTPS for every API request.
  • Do not commit API keys to Git repositories.
  • Do not log authorization headers or full API keys.
  • Validate user input and enforce sensible request limits in your application.