Cannot use uploaded file with responses api

Hi, I’m moving from the chat completion api to the respones api. When referencing a file_id in the request I get the error “openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: ‘Invalid input: Expected context stuffing file type to be a supported format: .pdf but got none.’, ‘type’: ‘invalid_request_error’, ‘param’: ‘input’, ‘code’: None}}”

This is my request

 model_name="gpt-5"
 response = client.responses.create(
                temperature=MODEL_TEMPERATURE,
                model=model_name,
                text={
                        "format": {
                            "type": "json_schema",
                            "name": "output_response",
                            "strict": True,
                            "schema": RESPONSE_SCHEMA
                        }
                },
                store=False,
                input=[
                    {
                        "role": "developer",
                        "content": prompt
                    },
                    {
                        "role": "user",
                        "content": [
                            {"type" : "input_file", "file_id": uploaded_file_id}
                        ]
                    }
                ]
            )

Am I doing anything wrong here? According to the docs, this should work..

A successful call, where I don’t try to send temperature to a model without support for it, and the user message provides the task to be done.

messages = [
    {"role": "developer", "content": "You are a meticulous research assistant."},
    {
        "role": "user",
        "content": [
            {
                "type": "input_text",
                "text": "What is being shown in the following content?",
            },
            {
                "type": "input_file",
                "file_id": "file-DDDEEEFFF"
            }
        ]
    }
]

from openai import OpenAI
client = OpenAI()
response = client.responses.create(
    model="gpt-5",
    input=messages,
    max_output_tokens=4500,
    store=False,
)
print(response.output_text)

No variables for you to guess about.

Only PDF files are allowed as file input for the extraction + vision.

The file is uploaded with purpose: user_data, and with the same project as the API usage.

Thanks for your reply. I see my error was in the file upload.

Instead of returning open(“filename”, “rb”) I was returning the content itself with a f.read() call.

1 Like