Kokoro 82M API
Available PopularKokoro 82M is a small, high-quality open text-to-speech model. It is served here on the OpenAI-compatible speech endpoint, so any client that already talks to /v1/audio/speech works by changing the base URL. 54 voices cover American and British English, Japanese, Mandarin, Spanish, French, Hindi, Italian and Portuguese.
Quickstart
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
- Interactive speech: sub-second responses for a paragraph in our measurement
- You need voices in several languages at a low price per character
- You need emotional delivery or non-verbal sounds such as laughter
What it costs in practice
| Workload | Cost |
|---|---|
| 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
Content-Type: application/json
/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.
| ID | Note |
|---|---|
hexgrad/Kokoro-82M | Canonical |
kokoro | Alias |
kokoro-82m | Alias |
tts-1 | OpenAI's id. OpenAI voice names are mapped too, so OpenAI speech code runs with only the base URL changed |
Request body
| Parameter | Type | Description |
|---|---|---|
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
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 |
| Billing | Pay 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-Charactersresponse 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.
