Error Including Files with base64?

I have been including files in my messages for a long time as described in OpenAI docs.

Since Yesterday, I have been receiving uninformative error messages from OpenAI every time I include a document:

openai.APIError: An error occurred while processing your request. You can retry your request, or contact us through our help center at help.openai.com if the error persists. Please include the request ID wfr_019detcetcetc in your message.

I asked the AI support bot on help.openai.com and it said the documentation was wrong.

Thank you for sharing the documentation link. The OpenAI API recently changed its handling of base64-encoded files in message payloads. As of March 2026, direct inclusion of base64 file data in message content is no longer reliably supported—files now generally must be uploaded separately and referenced by their file_id, even if prior docs or guides mention the old method.

I tend to believe documentation over AI bots. Who is right?

base64 still working for my Chatbot plugin with a payload like:

 {
    "role": "user",
    "content": [
      { "type": "text", "text": "what is in this image?" },
      {
        "type": "image_url",
        "image_url": {
          "url": "data:image/png;base64,iVBORw0KGgoAAA..."
        }
      }
    ]
  }
2 Likes

Hi @Joao_Abrantes,

I tested this on my end, and the API call returned a successful response as expected. Could you please confirm whether you’re still experiencing the issue?

If possible, can you also share the code used to make the API call, as that would help with the investigation?

3 Likes

This report is missing:

  • if the API now errors on the exact same call previously successful
  • what the file type is being attached, the length, if it is under the documented number of pages, if it would exceed the model input context window, MIME type being used in the data URL, etc
  • which API model is giving the issue
  • which API endpoint is giving the issue
  • which programming language is being used
  • (we can infer openai.APIError means SDK usage)

I created a script to make extensive calls if desired, a variant of the scripting to keep the vision costs in check across all models and endpoints - now with any type of file input from a local file as BASE64. The only thing it reveals is the greatly-increased expense of gpt-5.4 series with the same file, because of large vision input being used. Where I expect this cost bloat and use the mini model as an avoidance technique.

Testing log of a small PDF:

File : test1.pdf  (application/pdf)

| model              | chat input tokens | responses input tokens |
| ------------------ | ----------------- | ---------------------- |
| gpt-5.4-mini       |              1727 |                   1829 |
| gpt-5.1-2025-11-13 |               310 |                    680 |
| gpt-4.1-2025-04-14 |               311 |                    816 |
| gpt-4o-2024-08-06  |               311 |                    816 |

Where all models can also answer about the file:

--- Testing gpt-4o-2024-08-06 (Responses)
gpt-4o-2024-08-06  Total input tokens: 816
The document is an image of a webpage titled "My Joke Website." It features

Result: success on PDF as input_file or file_input message attachment.

File types and their MIME mappings by extensions you might find useful - to tell us which caused an input error.


# ---------------------------------------------------------------------------
# MIME-type table (extension → MIME) for all OpenAI-accepted file types
# ---------------------------------------------------------------------------

EXTENSION_TO_MIME: dict[str, str] = {
    # PDF
    ".pdf":      "application/pdf",
    # Spreadsheets
    ".xlsx":     "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    ".xls":      "application/vnd.ms-excel",
    ".xla":      "application/vnd.ms-excel",
    ".xlb":      "application/vnd.ms-excel",
    ".xlc":      "application/vnd.ms-excel",
    ".xlm":      "application/vnd.ms-excel",
    ".xlt":      "application/vnd.ms-excel",
    ".xlw":      "application/vnd.ms-excel",
    ".csv":      "text/csv",
    ".tsv":      "text/tsv",
    ".iif":      "text/x-iif",
    # Rich documents
    ".docx":     "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    ".doc":      "application/msword",
    ".dot":      "application/msword",
    ".odt":      "application/vnd.oasis.opendocument.text",
    ".rtf":      "application/rtf",
    # Presentations
    ".pptx":     "application/vnd.openxmlformats-officedocument.presentationml.presentation",
    ".ppt":      "application/vnd.ms-powerpoint",
    ".pot":      "application/vnd.ms-powerpoint",
    ".ppa":      "application/vnd.ms-powerpoint",
    ".pps":      "application/vnd.ms-powerpoint",
    ".pwz":      "application/vnd.ms-powerpoint",
    ".wiz":      "application/vnd.ms-powerpoint",
    # Text / code
    ".txt":      "text/plain",
    ".text":     "text/plain",
    ".log":      "text/plain",
    ".conf":     "text/plain",
    ".md":       "text/markdown",
    ".markdown": "text/markdown",
    ".rst":      "text/x-rst",
    ".html":     "text/html",
    ".htm":      "text/html",
    ".mht":      "text/html",
    ".mhtml":    "text/html",
    ".xml":      "text/xml",
    ".json":     "application/json",
    ".yaml":     "application/x-yaml",
    ".yml":      "application/x-yaml",
    ".toml":     "application/toml",
    ".ini":      "text/x-ini",
    ".css":      "text/css",
    ".js":       "text/javascript",
    ".mjs":      "text/javascript",
    ".ts":       "text/x-typescript",
    ".py":       "text/x-python",
    ".sh":       "text/x-sh",
    ".bash":     "text/x-bash",
    ".ksh":      "text/x-shellscript",
    ".bat":      "text/x-shellscript",
    ".sql":      "application/x-sql",
    ".c":        "text/x-c",
    ".cc":       "text/x-c++",
    ".cpp":      "text/x-c++",
    ".cxx":      "text/x-c++",
    ".h":        "text/x-c",
    ".hh":       "text/x-c",
    ".java":     "text/x-java",
    ".go":       "text/x-go",
    ".rs":       "text/x-rust",
    ".rb":       "text/x-ruby",
    ".php":      "text/x-php",
    ".cs":       "text/x-csharp",
    ".swift":    "text/x-swift",
    ".kt":       "text/x-kotlin",
    ".pl":       "text/x-perl",
    ".r":        "text/x-r",
    ".asm":      "text/x-asm",
    ".s":        "text/x-asm",
    ".eml":      "message/rfc822",
    ".srt":      "text/srt",
    ".vtt":      "text/vtt",
    ".vcf":      "text/x-vcard",
    ".ics":      "text/calendar",
    ".ifb":      "text/calendar",
}

Similar topic - similar timeline of a problem, but when using “background” on Responses:

4 Likes

it started working for me again. Same bug as here: Responses API with file input in the background mode: server error with PDFs

it gave error for 1 full day though.

also OpenAI tells me to use the request ID of the error to get help, but their support bot can’t look into that request ID to understand what happened.

2 Likes