NAME

OpenAPI::Client::OpenAI::Path::audio-speech - Documentation for the /audio/speech path.

OPERATIONS

POST /audio/speech

createSpeech

$client->create_speech({
    body => { ... },
});

Generates audio from the input text.

Returns the audio file content, or a stream of audio events.

Request body

Content-Type: application/json

Example:

{
   "input" : "string",
   "instructions" : "string",
   "model" : "tts-1",
   "response_format" : "mp3",
   "speed" : 1,
   "stream_format" : "audio",
   "voice" : {
      "id" : "voice_1234"
   }
}

Responses

200 - OK

Content-Type: application/octet-stream

Example:

"string"

Content-Type: text/event-stream

Example:

{
   "audio" : "base64-encoded-audio-data",
   "type" : "speech.audio.delta"
}

SCHEMAS

CreateSpeechRequest

Properties:

  • input (string, required) - The text to generate audio for. The maximum length is 4096 characters.

  • instructions (string) - Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd .

  • model (anyOf, required) - One of the available TTS models : tts-1 , tts-1-hd , gpt-4o-mini-tts , or gpt-4o-mini-tts-2025-12-15 .

  • response_format (string) - The format to audio in. Supported formats are mp3 , opus , aac , flac , wav , and pcm .

    Allowed values: mp3, opus, aac, flac, wav, pcm

    Default: mp3

  • speed (number) - The speed of the generated audio. Select a value from 0.25 to 4.0 . 1.0 is the default.

    Default: 1

  • stream_format (string) - The format to stream the audio in. Supported formats are sse and audio . sse is not supported for tts-1 or tts-1-hd .

    Allowed values: sse, audio

    Default: audio

  • voice (VoiceIdsOrCustomVoice, required) - The voice to use when generating the audio. Supported built-in voices are alloy , ash , ballad , coral , echo , fable , onyx , nova , sage , shimmer , verse , marin , and cedar . You may also provide a custom voice object with an id , for example { "id": "voice_1234" } . Previews of the voices are available in the Text to speech guide .

    See "VoiceIdsOrCustomVoice" below for shape.

CreateSpeechResponseStreamEvent

See https://platform.openai.com/docs/api-reference for details.

VoiceIdsOrCustomVoice

A built-in voice name or a custom voice reference.

SEE ALSO

OpenAPI::Client::OpenAI::Path

COPYRIGHT AND LICENSE

Copyright (C) 2023-2026 by Nelson Ferraz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.0 or, at your option, any later version of Perl 5 you may have available.