Base64 file not going through api

Here is a request body successfully fulfilled by the API Prompts Playground, including base64 of a PDF as file content part.

Chat Completions

POST https://api.openai.com/v1/chat/completions

{
  "messages":[
    {
      "role":"user",
      "content":[
        {
          "type":"text",
          "text":"Summarize PDF"
        },
        {
          "type":"file",
          "file":{
            "file_data":"data:application/pdf;base64,JVBERi0xLjUNJeLjz9MN...",
            "filename":"competion-sidebar.pdf"
          }
        }
      ]
    }
  ],
  "temperature":1,
  "max_completion_tokens":2048,
  "top_p":0.05,
  "model":"gpt-4o",
  "response_format":{
    "type":"text"
  },
  "stream":true,
  "stream_options":{
    "include_usage":true
  }
}

Responses

POST https://api.openai.com/v1/responses

{
  "model": "gpt-4o",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Summarize PDF"
        },
        {
          "type": "input_file",
          "filename": "competion-sidebar.pdf",
          "file_data": "data:application/pdf;base64,JVBERi0xLjUNJeLjz9MNCjEgMCB..."
        }
      ]
    }
  ],
  "tools": [],
  "text": {
    "format": {
      "type": "text"
    }
  },
  "temperature": 1,
  "top_p": 0.05,
  "reasoning": {},
  "stream": true,
  "max_output_tokens": 2048,
  "store": true
}

Headers filtered down to developer-provided, including a
OpenAI-Beta: responses=v1 header likely used before release.

Content-Type: application/json
Authorization: Bearer (sessiontoken)
OpenAI-Organization: org-1234
OpenAI-Project: proj_1234
OpenAI-Beta: responses=v1

Analysis

Your payload keys are incorrect when compared:

  • Change file_namefilename.
  • Prefix your file_data with data:application/pdf;base64,.

The API reference seems to be in error if the Playground is recommended or the only working key, using a data URL.

Make these two corrections and your inline base64 upload should succeed.

(nothing is a “link” when you use the forum’s preformatted text formatting)