Inference APIs
Models/Speech/Kokoro 82M
Text to speech54 voicesMP3 / WAV8 languages
Modality
Text → Audio
Price
$5.20 / 1M characters
300 chars → audio
0.84 s
Model ID
hexgrad/Kokoro-82M

Quickstart

You need an API key to call this model. Create a free account or log in.

Set INFERENCE_API_KEY to your key from the API Keys page, then run:

curl https://api.inferenceapis.com/v1/audio/speech \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hexgrad/Kokoro-82M",
    "input": "Hello! This is Kokoro 82M speaking.",
    "voice": "af_heart",
    "response_format": "mp3"
  }' --output speech.mp3
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.inferenceapis.com/v1",
    api_key=os.environ["INFERENCE_API_KEY"],
)
with client.audio.speech.with_streaming_response.create(
    model="hexgrad/Kokoro-82M",
    voice="af_heart",
    input="Hello! This is Kokoro 82M speaking.",
    response_format="mp3",
) as response:
    response.stream_to_file("speech.mp3")
import fs from "node:fs";
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.inferenceapis.com/v1",
  apiKey: process.env.INFERENCE_API_KEY,
});
const audio = await client.audio.speech.create({
  model: "hexgrad/Kokoro-82M",
  voice: "af_heart",
  input: "Hello! This is Kokoro 82M speaking.",
  response_format: "mp3",
});
fs.writeFileSync("speech.mp3", Buffer.from(await audio.arrayBuffer()));

When to use it

A good fit when
  • Interactive speech: sub-second responses for a paragraph in our measurement
  • You need voices in several languages at a low price per character
Look elsewhere when
  • You need emotional delivery or non-verbal sounds such as laughter

What it costs in practice

WorkloadCost
One 1,000-word article (about 6,000 characters)$0.03
One hour of narration (about 54,000 characters)$0.28
One million characters (about 18 hours of speech)$5.20

Computed from the live rate below. There is no subscription or minimum; new accounts start with free credit.

Endpoint

POST https://api.inferenceapis.com/v1/audio/speech
Headers Authorization: Bearer $INFERENCE_API_KEY
Content-Type: application/json
Compatible OpenAI wire format. /openai/v1/… is accepted too, so Groq-style base URLs work with only the host changed.

Model IDs and aliases

Send any of these as model; they all resolve to this model and bill at its rate.

IDNote
hexgrad/Kokoro-82MCanonical
kokoroAlias
kokoro-82mAlias
tts-1OpenAI's id. OpenAI voice names are mapped too, so OpenAI speech code runs with only the base URL changed

Request body

ParameterTypeDescription
model required string Model ID: hexgrad/Kokoro-82M
input required string The text to speak. Up to 20,000 characters per request.
voice string Voice id. Default af_heart. See the voice list below.
response_format string mp3 (default), wav or raw (PCM).
speed number Playback speed multiplier, e.g. 1.1.
language string Language hint for multilingual voices, e.g. en, ja.

Voices

Click a voice to copy its id. Hear them in the playground.

Response

200 OK · audio
Binary audio (Content-Type: audio/mpeg for mp3, audio/wav for wav).
Headers:
  X-Usage-Characters: 42        # characters billed for this request

Pricing

Price$5.20 / 1M characters
BillingPay as you go from prepaid credits. No subscription, no daily request or token cap. See all pricing.

Notes

  • Voice ids are prefixed by language and gender: af_ American female, am_ American male, bf_/bm_ British, jf_/jm_ Japanese, zf_/zm_ Mandarin, ef_/em_ Spanish, ff_ French, hf_/hm_ Hindi, if_/im_ Italian, pf_/pm_ Portuguese.
  • Billing is per character of input text; the X-Usage-Characters response header reports the metered count.

Compare Kokoro 82M with…

Languages

Per-language voice lists and samples: text-to-speech languages.

Questions about Kokoro 82M

Do OpenAI voice names work?

Yes. alloy, echo, fable, onyx and nova map to the Kokoro voices of the same name (af_alloy, am_echo, bm_fable, am_onyx, af_nova); shimmer, ash, ballad, coral, sage and verse map to the closest character. The response header X-Voice-Mapped says which voice was used. They are Kokoro voices, not OpenAI's, so they sound different.

How long can the input be?

20,000 characters per request. For longer text, split on sentence boundaries, request each part and concatenate the audio; mp3 parts can be joined as they are.

Does it support SSML?

No. Pacing follows punctuation: commas and full stops produce pauses, and a new paragraph produces a longer one. speed changes the overall rate.

Is the audio streamed?

No, the response is the complete file. A paragraph returns in under a second in our measurement, so generating sentence by sentence works for interactive use.

Which languages sound best?

English. Kokoro's authors grade its own voices and the American and British English ones rate highest; the other languages were trained on far less data. Listen before you commit: voices and samples by language.

Can I use the audio commercially?

Kokoro is released under Apache 2.0, which permits commercial use of the model and its output.

Licence

Kokoro 82M is published by Hexgrad under the Apache 2.0. Your use of its output is also subject to that licence.

Errors

Errors use the OpenAI envelope: {"error": {"message", "type", "code"}}. 401 missing or invalid key · 402 insufficient_balance · 404 model_not_found · 503 model_unavailable · 502 backend error, safe to retry. Full table with what to retry: API documentation. Errors from other providers: provider error reference.