Audio ยท OpenAI
Voice Creation
Create custom voices from audio samples for use with OpenAI TTS models.
POST
/v1/audio/voices/createCustom voices work with the
gpt-4o-mini-tts model. Pass the returned voice ID as { "id": "voice_abc123" } in the TTS voice parameter.Request
Multipart Form Parameters
audio_samplefileformrequiredAudio file with a sample of the voice to clone
consentstringformrequiredConsent confirmation text
namestringformrequiredName for the custom voice
descriptionstringformOptional description of the voice
cURL
curl https://api.metriqual.com/v1/audio/voices/create \
-H "Authorization: Bearer mql_your_key" \
-F audio_sample=@my_voice.mp3 \
-F consent="I confirm I have the right to use this voice" \
-F name="My Custom Voice"TypeScript SDK
const voice = await mql.audio.createVoice({
audio_sample: audioFile,
consent: 'I confirm I have the right to use this voice',
name: 'My Custom Voice',
});
console.log('Voice ID:', voice.id);
// Use in TTS
const audio = await mql.audio.speech({
model: 'gpt-4o-mini-tts',
input: 'Hello from my custom voice!',
voice: { id: voice.id },
instructions: 'Speak in a friendly, natural tone.'
});Python SDK
with open("my_voice.mp3", "rb") as f:
voice = mql.audio.create_voice(file=f, name="My Custom Voice")
print("Voice ID:", voice["id"])
# Use in TTS
audio = mql.audio.speech(
input="Hello from my custom voice!",
voice=voice["id"],
model="gpt-4o-mini-tts",
)Response
200
{
"id": "voice_abc123def456",
"created_at": 1719000000,
"name": "My Custom Voice",
"object": "audio.voice"
}