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 Param

From Leeroopedia
Revision as of 13:40, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Response_Input_File_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 a file input to the model provided by the openai-python SDK.

Description

ResponseInputFileParam is a TypedDict used to construct file input items for the Responses API. The type field must always be "input_file". Unlike ResponseInputFileContentParam, in this variant file_data, file_url, and filename are non-optional strings (though not required by total=False), while file_id is Optional[str]. This type is used when specifying file inputs as standalone content parts rather than within a content list.

Usage

Import this type when constructing file input parameters for the Responses API, particularly when providing files by URL, inline data, or uploaded file ID.

Code Reference

Source Location

Signature

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

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

Import

from openai.types.responses import ResponseInputFileParam

I/O Contract

Fields

Name Type Required Description
type Literal["input_file"] Yes The type of the input item. Always input_file.
file_data str No The content 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 str No The URL of the file to be sent to the model.
filename str No The name of the file to be sent to the model.

Usage Examples

import openai

client = openai.OpenAI()

# Provide a file by URL
response = client.responses.create(
    model="gpt-4o",
    input=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_file",
                    "file_url": "https://example.com/document.pdf",
                    "filename": "document.pdf",
                },
                {"type": "input_text", "text": "What does this document say?"},
            ],
        }
    ],
)
print(response.output_text)

Related Pages

Page Connections

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