Skip to main content
Two audio endpoints, both OpenAI-shaped:
  • Text-to-speech (TTS)POST /v1/audio/speech returns audio bytes for a text input. Find models with audio_speech in supports.
  • Transcription (ASR)POST /v1/audio/transcriptions returns text for an audio file upload. Find models with audio_transcription in supports.
See model discovery for the filter snippets.

Text-to-speech

The example below uses Kokoro-82M. The response body is raw audio bytes (WAV by default) — write them straight to disk.
curl https://tokens.flex.ai/v1/audio/speech \
  -H "Authorization: Bearer $FLEXAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Kokoro-82M",
    "input": "Hello from FlexAI.",
    "voice": "neutral_female"
  }' \
  --output out.wav
import os
from openai import OpenAI

client = OpenAI(base_url="https://tokens.flex.ai/v1", api_key=os.environ["FLEXAI_API_KEY"])

resp = client.audio.speech.create(
    model="Kokoro-82M",
    input="Hello from FlexAI.",
    voice="neutral_female",
)
resp.stream_to_file("out.wav")
import fs from "node:fs";
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://tokens.flex.ai/v1",
  apiKey: process.env.FLEXAI_API_KEY,
});

const resp = await client.audio.speech.create({
  model: "Kokoro-82M",
  input: "Hello from FlexAI.",
  voice: "neutral_female",
});
fs.writeFileSync("out.wav", Buffer.from(await resp.arrayBuffer()));

Voices

Voice names are model-specific — there’s no shared “Alloy/Echo/Fable/…” namespace. Check the model’s description on GET /api/models for the supported set, or fall back to the model’s upstream documentation.

Billing

TTS bills per input character — see pricing[] (billing_unit: "character") on GET /api/models, or billing.

Transcription

/v1/audio/transcriptions is Whisper-compatible. Send the audio file as multipart/form-data, get back a JSON { "text": "..." }. The current model is whisper-large-v3-turbo.
curl https://tokens.flex.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $FLEXAI_API_KEY" \
  -F "file=@input.wav" \
  -F "model=whisper-large-v3-turbo" \
  -F "language=en"
import os
from openai import OpenAI

client = OpenAI(base_url="https://tokens.flex.ai/v1", api_key=os.environ["FLEXAI_API_KEY"])

with open("input.wav", "rb") as f:
    resp = client.audio.transcriptions.create(
        model="whisper-large-v3-turbo",
        file=f,
        language="en",
    )
print(resp.text)
import fs from "node:fs";
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://tokens.flex.ai/v1",
  apiKey: process.env.FLEXAI_API_KEY,
});

const resp = await client.audio.transcriptions.create({
  model: "whisper-large-v3-turbo",
  file: fs.createReadStream("input.wav"),
  language: "en",
});
console.log(resp.text);

Request fields

FieldRequiredNotes
fileYesmultipart/form-data upload. WAV, MP3, M4A, FLAC, OGG.
modelYesMust have audio_transcription in supports.
languageNoISO-639-1 code (en, fr, …). Auto-detected when omitted.

Billing

ASR bills per minute of input audio — see pricing[] (billing_unit: "minute") on GET /api/models.

See also