Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Response Input Audio Param

From Leeroopedia
Revision as of 13:40, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Response_Input_Audio_Param.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains API_Types, Responses_API
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete TypedDict parameter type for supplying audio input to the model provided by the openai-python SDK.

Description

ResponseInputAudioParam is a TypedDict used to construct audio input items for the Responses API. It requires an input_audio sub-dict of type InputAudio containing a data field with base64-encoded audio and a format field specifying the audio format (either "mp3" or "wav"). The type field must always be "input_audio". The module also exports the helper InputAudio TypedDict.

Usage

Import this type when you need to send audio data as input to the Responses API, for example when building voice-enabled applications or transcription pipelines.

Code Reference

Source Location

Signature

class InputAudio(TypedDict, total=False):
    data: Required[str]
    format: Required[Literal["mp3", "wav"]]

class ResponseInputAudioParam(TypedDict, total=False):
    """An audio input to the model."""

    input_audio: Required[InputAudio]
    type: Required[Literal["input_audio"]]

Import

from openai.types.responses import ResponseInputAudioParam

I/O Contract

Fields

Name Type Required Description
input_audio InputAudio Yes The audio input containing base64-encoded data and format.
type Literal["input_audio"] Yes The type of the input item. Always input_audio.

InputAudio fields:

Name Type Required Description
data str Yes Base64-encoded audio data.
format Literal["mp3", "wav"] Yes The format of the audio data. Currently supported formats are mp3 and wav.

Usage Examples

import base64
import openai

client = openai.OpenAI()

# Read and encode audio file
with open("question.mp3", "rb") as f:
    audio_b64 = base64.b64encode(f.read()).decode("utf-8")

response = client.responses.create(
    model="gpt-4o-audio-preview",
    input=[
        {
            "type": "input_audio",
            "input_audio": {
                "data": audio_b64,
                "format": "mp3",
            },
        }
    ],
)
print(response.output_text)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment