AUDIO OUTPUT

Text to speech API

Send JSON to /v1/audio/speech and save the binary response as an audio file. Choose the model by voice controls, compatibility and billing unit.

Live requests verified6 output formatsBinary response

Choose a TTS model

ModelBest forInput limitVerified price
gpt-4o-mini-ttsControllable delivery with instructions4,096 characters; 2,000 model tokens$0.60 / 1M text tokens + $12 / 1M audio tokens
tts-1-hdLegacy HD TTS compatibility4,096 characters$30 / 1M characters

Audio created by these models is AI-generated. Tell end users that the voice is synthetic when you publish or play it.

gpt-4o-mini-tts

Use instructions to describe tone, pace, accent or emotion. The request below returns MP3 bytes; --output prevents curl from printing binary data to your terminal.

cURL · controlled MP3
curl https://api-models.com/v1/audio/speech \
  -H "Authorization: Bearer $API_MODELS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "input": "Your order is ready for pickup.",
    "voice": "marin",
    "instructions": "Speak warmly, clearly, and at a relaxed pace.",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  --output speech.mp3
Python · requests
import os
import requests

response = requests.post(
    "https://api-models.com/v1/audio/speech",
    headers={"Authorization": f"Bearer {os.environ['API_MODELS_KEY']}"},
    json={
        "model": "gpt-4o-mini-tts",
        "input": "Your order is ready for pickup.",
        "voice": "marin",
        "instructions": "Speak warmly, clearly, and at a relaxed pace.",
        "response_format": "mp3",
    },
    timeout=120,
)
response.raise_for_status()
with open("speech.mp3", "wb") as output:
    output.write(response.content)
Node.js · fetch
import { writeFile } from "node:fs/promises";

const response = await fetch("https://api-models.com/v1/audio/speech", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.API_MODELS_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "gpt-4o-mini-tts",
    input: "Your order is ready for pickup.",
    voice: "marin",
    instructions: "Speak warmly, clearly, and at a relaxed pace.",
    response_format: "mp3",
  }),
});
if (!response.ok) throw new Error(await response.text());
await writeFile("speech.mp3", Buffer.from(await response.arrayBuffer()));

tts-1-hd

Use the same endpoint without instructions. Compatibility voices alloy, echo, fable, onyx, nova and shimmer are the safe choice for this upstream; nova and alloy were exercised in live requests.

cURL · WAV output
curl https://api-models.com/v1/audio/speech \
  -H "Authorization: Bearer $API_MODELS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1-hd",
    "input": "A high-quality compatibility voice sample.",
    "voice": "nova",
    "response_format": "wav",
    "speed": 0.9
  }' \
  --output speech.wav

Parameters and output formats

FieldRequirementNotes
modelRequiredgpt-4o-mini-tts or tts-1-hd
inputRequiredMaximum 4,096 characters
voiceRequiredUse a voice compatible with the selected model
instructionsgpt-4o-mini-tts onlyControls delivery; not supported by tts-1-hd
response_formatOptionalmp3, opus, aac, flac, wav, pcm; default mp3
speedOptional0.25 to 4.0; default 1.0

The gateway currently documents normal binary responses only. Do not add stream_format=sse; it is not part of the verified compatibility surface.

Common errors

SymptomFix
Chat completion errorUse /v1/audio/speech, not /v1/chat/completions
Empty or corrupt fileSave the binary response and check response.ok before writing
Unsupported voice behaviorUse the compatibility voices listed for tts-1-hd
instructions rejectedRemove it from tts-1-hd requests