Use the dedicated guides
This page is a compact overview. For verified pricing, limits, model-specific parameters and cURL, Python and Node.js examples, open the text-to-speech guide, Whisper speech-to-text guide, or embeddings guide.
Text to speech (TTS)
Supported models: gpt-4o-mini-tts and tts-1-hd. The response is binary audio, so save it to a file instead of parsing JSON.
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": "Hello from API Models.",
"voice": "alloy",
"response_format": "mp3"
}' \
--output speech.mp3import 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": "Hello from API Models.",
"voice": "alloy",
"response_format": "mp3",
},
timeout=120,
)
response.raise_for_status()
open("speech.mp3", "wb").write(response.content)model, input and voice are required. Common formats are mp3, opus, aac, flac, wav and pcm. instructions works with gpt-4o-mini-tts, not tts-1-hd.
Speech to text with Whisper
whisper-1 accepts a file upload as multipart/form-data and returns text. Do not send a JSON chat body.
curl https://api-models.com/v1/audio/transcriptions \
-H "Authorization: Bearer $API_MODELS_KEY" \
-F "file=@./audio.mp3" \
-F "model=whisper-1" \
-F "response_format=json"import os
import requests
with open("audio.mp3", "rb") as audio:
response = requests.post(
"https://api-models.com/v1/audio/transcriptions",
headers={"Authorization": f"Bearer {os.environ['API_MODELS_KEY']}"},
files={"file": ("audio.mp3", audio, "audio/mpeg")},
data={"model": "whisper-1", "response_format": "json"},
timeout=180,
)
response.raise_for_status()
print(response.json()["text"])Optional fields include language, prompt, response_format and temperature. Whisper also supports text, srt, verbose_json and vtt output formats.
Text embeddings
Supported models: text-embedding-3-large, text-embedding-3-small and text-embedding-ada-002. The response contains vectors in data[].embedding.
curl https://api-models.com/v1/embeddings \
-H "Authorization: Bearer $API_MODELS_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "Embed this sentence.",
"encoding_format": "float"
}'const response = await fetch("https://api-models.com/v1/embeddings", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_MODELS_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "text-embedding-3-small",
input: "Embed this sentence.",
encoding_format: "float",
}),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data.data[0].embedding.slice(0, 8));dimensions is supported by the text-embedding-3 models, but not by text-embedding-ada-002.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Chat-style error | Wrong endpoint | Use the capability route listed above |
| 415 / invalid body | Wrong content type | TTS and embeddings use JSON; transcription uses multipart |
| Empty or corrupt audio | Binary response parsed as JSON | Write the response body to a file |
| 404 model | Model ID mismatch | Copy the exact ID from the live catalog |