File inputs using Base64-encoded files not working

Ali Beyram 35 Reputation points
2025-04-23T03:48:46.8666667+00:00

I am trying to use the the file inputs to upload a PDF but I am getting the following error message

The server had an error processing your request. Sorry about that! You can retry your request, or contact us through our help center at oai-assistants@microsoft.com if you keep seeing this error. ....

I tried the email but it is only available for internal Microsoft employees.

here is simple code to reproduce it


import base64
import os

from openai import AzureOpenAI


client = AzureOpenAI(
    api_version="2025-03-01-preview",
    azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
)

with open("example.pdf", "rb") as f:
    data = f.read()

base64_string = base64.b64encode(data).decode("utf-8")

response = client.responses.create(
    model="gpt-4.1-mini",
    input=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_file",
                    "filename": "example.pdf",
                    "file_data": f"data:application/pdf;base64,{base64_string}",
                },
                {
                    "type": "input_text",
                    "text": "what is document about?",
                },
            ],
        },
    ],
)
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,080 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Stefano Accardo 0 Reputation points
    2025-05-06T13:39:56.73+00:00

    Having the same exact problem. These AI bots answer are not helping.

    0 comments No comments

  2. JAYA SHANKAR G S 4,035 Reputation points Microsoft External Staff Moderator
    2025-05-30T08:05:17.5966667+00:00

    Hello @Ali Beyram ,

    Thank you for your patience. We’ve received an update from our product team this issue has been identified as a fundamental feature gap. The team is actively working on implementing the functionality.

    Currently, there is no ETA for the fix. However, we are closely tracking the progress and will keep you informed as soon as any updates or releases become available.

    In the meantime, the product team has provided a workaround using a vector store and the file_search tool to retrieve content. Below is a sample code snippet for the responses API:

    response = client.responses.create(  
        model="gpt-4.1-mini",  
        input=[{"role": "user", "content": "Describe the files in the vector store."}],
        tools=[{
            "type": "file_search",
            "vector_store_ids": ["vs_uUYi8hxFmT7fYncND6nKhqUS"],
        }]
    )  
    
    for i in response.output:
        if i.type == "message":
            print(i.content[0].text)
    

    You’ll need to specify the vector store ID, which can be created via SDK, REST API, or the Azure portal.

    Location to create the vector store

    User's image

    File upload to the vector store

    User's image

    Sample output

    User's image

    Please evaluate whether this workaround suits your use case. If it does, you may proceed with it until the permanent fix is available. Otherwise, we appreciate your continued patience as our team works on a solution.

    Feel free to reach out in the comments if you need help implementing the workaround or have further questions.

    Thank you


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.