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()));
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.
| ID | Note |
|---|---|
hexgrad/Kokoro-82M | Canonical |
kokoro | Alias |
kokoro-82m | Alias |
tts-1 | Alias |
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.2 / 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.
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. See the error reference and provider error guides.
