Implementation:Openai Openai python Response Input File Param
| 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
- Repository: openai-python
- File: src/openai/types/responses/response_input_file_param.py
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)