Skip to main content
Use this guide for spoken output from a Response. To synthesize supplied text directly, see Text to speech. The OpenAI examples use its custom-request method for MKA1 extensions that are not part of the OpenAI Responses types.

Generate audio (text-to-speech)

Request audio output by setting modalities to ["text", "audio"]. The response includes the text reply and a base64-encoded recording of it.

Audio configuration

Audio output is always a WAV file: 24 kHz, 16-bit mono. The voice follows the language of the reply, which the API detects from the text (see Supported languages). The request’s audio object (voice and format) is accepted but has no effect, so the examples omit it.
The response contains an output_audio item with the base64-encoded audio and a transcript of what was spoken:
The data field contains the complete WAV file. The transcript field contains the text that was spoken, which is the reply’s output text. If speech synthesis fails, the response still completes, without an output_audio item.

Save audio to a file

Supported languages

Audio responses speak the languages listed in Text to speech. A reply in any other language is spoken with the English voice. To choose the language yourself, or to get MP3 instead of WAV, send the reply text to Text to speech.