Skip to content

'file' message type with data URL should be supported by chat completions #733

@danielmklein

Description

@danielmklein

Describe the bug

If you run an agent and pass it content that includes an input_file where file is base64-encoded data, like this...

content: [
  {
    type: 'input_file',
    file: "data:application/pdf;base64,JVBER...snip...",
    providerData: {
      filename: "cool-doc.pdf"
    }
  }
],

you hit this error:

throw new Error(
`File uploads are not supported for chat completions: ${JSON.stringify(
c,
)}`,
);

even though the docs and API do support passing such an input file.

It looks like this issue also existed in the python SDK but was fixed: openai/openai-agents-python#893.

Debug information

  • Agents SDK version: (e.g. `v0.3.4)
  • Node 22.21.1

Repro steps

import { Agent, run } from '@openai/agents';

const agent = new Agent({
  name: 'Assistant',
  instructions: 'You are a helpful assistant.',
});

const result = await run(
  agent,
  [
    {
      role: 'user',
      content: [
        {
          type: 'input_text',
          text: "what does this file say?",
        }
        {
          type: 'input_file',
          file: "data:application/pdf;base64,JVBER...snip...", // replace with a valid base64-encoded pdf
          providerData: {
            filename: "cool-doc.pdf"
          }
        }
      ],
    }
  ],
);`

Expected behavior

I would expect this to successfully pass the file input data to the API without error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions