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 File Content Param

From Leeroopedia
Knowledge Sources
Domains API_Types, Responses_API
Last Updated 2026-02-15 00:00 GMT

Overview

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

Description

ResponseInputFileContentParam is a TypedDict used to construct file input content items for the Responses API request payload. The type field must always be "input_file". Files can be referenced by file_id (an uploaded file identifier), by file_data (base64-encoded inline data), by file_url (a remote URL), or with a filename for display purposes. All file reference fields are optional, allowing flexible file specification.

Usage

Import this type when constructing request payloads that include file content items as part of a message's content array in the Responses API.

Code Reference

Source Location

Signature

class ResponseInputFileContentParam(TypedDict, total=False):
    """A file input to the model."""

    type: Required[Literal["input_file"]]
    file_data: Optional[str]
    file_id: Optional[str]
    file_url: Optional[str]
    filename: Optional[str]

Import

from openai.types.responses import ResponseInputFileContentParam

I/O Contract

Fields

Name Type Required Description
type Literal["input_file"] Yes The type of the input item. Always input_file.
file_data Optional[str] No The base64-encoded data of the file to be sent to the model.
file_id Optional[str] No The ID of the file to be sent to the model.
file_url Optional[str] No The URL of the file to be sent to the model.
filename Optional[str] No The name of the file to be sent to the model.

Usage Examples

import base64
import openai

client = openai.OpenAI()

# Using file_id
file_content_param = {
    "type": "input_file",
    "file_id": "file-abc123",
}

# Using inline base64 data
with open("document.pdf", "rb") as f:
    b64_data = base64.b64encode(f.read()).decode("utf-8")

file_content_param_inline = {
    "type": "input_file",
    "file_data": b64_data,
    "filename": "document.pdf",
}

response = client.responses.create(
    model="gpt-4o",
    input=[
        {
            "role": "user",
            "content": [
                file_content_param,
                {"type": "input_text", "text": "Summarize this file."},
            ],
        }
    ],
)
print(response.output_text)

Related Pages

Page Connections

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