Skip to main content

/audio/speech

Overview

FeatureSupportedNotes
Cost TrackingWorks with all supported models
LoggingWorks across all integrations
FallbacksWorks between supported models
LoadbalancingWorks between supported models
Supported ProvidersOpenAI, Azure OpenAI, Vertex AI, AWS Polly, ElevenLabs, MiniMax

Quick Start

Python

from pathlib import Path
from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

speech_file_path = Path(__file__).parent / "speech.mp3"

response = client.audio.speech.create(
model="openai/tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dogs"
)

response.stream_to_file(speech_file_path)

cURL

curl https://api.haimaker.ai/v1/audio/speech \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}' \
--output speech.mp3

Using Different Models

OpenAI TTS

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.audio.speech.create(
model="openai/tts-1",
voice="alloy", # Options: alloy, echo, fable, onyx, nova, shimmer
input="Hello, this is a test of text to speech."
)

response.stream_to_file("speech.mp3")

OpenAI TTS HD

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.audio.speech.create(
model="openai/tts-1-hd",
voice="nova",
input="This is high-definition text to speech."
)

response.stream_to_file("speech_hd.mp3")

Gemini TTS

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.audio.speech.create(
model="gemini/gemini-2.5-flash-preview-tts",
voice="alloy",
input="The quick brown fox jumped over the lazy dogs"
)

response.stream_to_file("gemini_speech.mp3")

Available Voices

For OpenAI TTS models, the available voices are:

VoiceDescription
alloyNeutral, balanced voice
echoWarm, conversational voice
fableExpressive, storytelling voice
onyxDeep, authoritative voice
novaFriendly, upbeat voice
shimmerClear, professional voice

Supported Providers

ProviderDocumentation Link
OpenAIUsage
Azure OpenAIAzure TTS
Vertex AIVertex AI TTS
ElevenLabsElevenLabs TTS
MiniMaxMiniMax TTS