43
Views
9
Comments
Agent based on OpenAI GPT-5.2 / Error when adding PDF files as binary data
Question

Hi all,

i buit an agent based on the training (https://learn.outsystems.com/training/journeys/build-agentic-powered-app-3411/build-the-intake-agent-exercise/odc/10813).

This agent should analyze the content of a pdf file.


This agent works fine while using the model "CallTrialClaude3_7Sonnet" but when i switch to my production model gpt-5.2 direct from provider OpenAI  I get the error:

OS-BERT-62000 - Failed to call AI model. Status code: BadRequest. The OpenAI AI model provider returned this message: "OpenAIException - Invalid MIME type. Only image types are supported.." (OS-ABRS-FM-40001) 

I already tried everything in https://www.outsystems.com/forums/discussion/105165/agent-based-on-aws-bedrock-openai-error-when-adding-pdf-files-as-binary-data/ but nothing in there helps.

Is there already a solution for the AIContentType.ImageBinary /  Entities.AIContentType.DocumentBinary problem?

Is there another way to use PDF files with OpenAI GPT-5.2?

Best regards, Alex

2025-12-22 13-50-43
Sherif El-Habibi
Champion

Hello,

It looks like the AI model may not support binary input. Have you tried converting the PDF to text first using something like BinaryToBase64 server action and then passing the extracted text to the model to see if that works?

UserImage.jpg
AlexP

Thanks for your input!

The model supports binary input just fine, I already tried it using the API

2021-11-19 11-12-44
Rui Mendes

Hi @AlexP ,

That error is consistent with the request being sent to OpenAI as an image input (or “image binary”) rather than as a document/file input.

When the call is made in an image modality, OpenAI validates the MIME type and only accepts image/*. A PDF (application/pdf) will be rejected, which is exactly what the provider returns:

“Invalid MIME type. Only image types are supported.”

So the issue is not “PDFs are impossible with OpenAI”, it’s that the current OutSystems mapping is sending the PDF using the image-binary pathway.

What you need to do instead

For PDFs you should provide the document as a file input, typically by:

  1. Uploading the PDF to OpenAI Files API (/v1/files, usually with purpose="user_data"), then
  2. Calling the model via the Responses API (/v1/responses) and passing the PDF as input_file using the returned file_id (or alternatively file_url if hosted).

Example flow:

Upload file

curl https://api.openai.com/v1/files \  -H "Authorization: Bearer $OPENAI_API_KEY" \  -F purpose="user_data" \  -F file="@document.pdf"

Use it as input

curl https://api.openai.com/v1/responses \  -H "Content-Type: application/json" \  -H "Authorization: Bearer $OPENAI_API_KEY" \  -d '{    "model": "gpt-5",    "input": [      {        "role": "user",        "content": [          { "type": "input_text", "text": "Please analyze the PDF and summarize it." },          { "type": "input_file", "file_id": "file-XXXX" }        ]      }    ]  }'

In OutSystems terms

  • If you use something like AIContentType.ImageBinary, OpenAI will treat it as an image and reject PDFs.
  • To use PDFs, the connector/agent implementation must support a document/file input approach (file upload + reference by file_id / file_url), or you’ll need an intermediate step that uploads the PDF and then calls the model with the returned ID.

If, after applying the approach above, it works as expected, please don’t forget to mark this reply as the correct answer so others with the same issue can find the solution more easily.

UserImage.jpg
AlexP

Hello Rui

thank you for your quick and detailed reply!

I had already a look at the OpenAI API, the solution you present is perfectly workable but comletely disregards the highy praised and advertised "OutSystems Agent Workbench" i am trying to use here.

Is there any way to use this Agent Workbench with OpenAI models and PDF files?
This works perfectly fine with "Claude3_7Sonnet", why should this be impossible with GPT-5.2?


best regards

   Alex

2021-11-19 11-12-44
Rui Mendes

Hi @AlexP

After validating this in my personal lab, gpt-5.2 can read and extract information from a PDF.

However, to make it work reliably I had to adjust the request format. The key point is that the request must be split into two separate content blocks:

  1. input_text — where you describe what you want the model to do (summary, analysis, critical points, etc.)
  2. input_file — where you provide the PDF via a direct URL (file_url)

If you do not follow this structure precisely, you may not get successful PDF extraction.

Example structure (same pattern I used):

{  "model": "gpt-5.2",  "input": [    {      "role": "user",      "content": [        {          "type": "input_text",          "text": "Analyze this PDF and provide a summary and key critical points."        },        {          "type": "input_file",          "file_url": "https://your-domain/path/document.pdf"        }      ]    }  ]}

With this approach, you should be able to get responses that include information extracted from PDF documents.

If you have any questions, feel free to ask. Otherwise, if this works for you too, please mark this answer as the solution so others with the same issue can find it more easily.

2021-11-19 11-12-44
Rui Mendes


OutSystems note (Service Studio / Service Center / “logic”)

Using Agent Workbench is not enough by itself. You still need to implement the server-side logic that actually calls the OpenAI API.

In OutSystems, that typically means:

  • Creating a Server Action (or a Service Action) that calls POST https://api.openai.com/v1/responses
  • Sending the JSON body exactly like above
  • Passing a valid OpenAI key in the request headers

Minimum headers

  • Authorization: Bearer <YOUR_OPENAI_API_KEY>
  • Content-Type: application/json

Requirements / common pitfalls

  • The file_url must be a direct link to the PDF file (not an HTML page with a download button).
  • If the filename contains spaces, encode them (e.g., replace spaces with %20).
  • You must have a valid OpenAI API key and the key must be allowed to use the selected model.

I share a simple OutSystems Server Action pattern (REST integration) for this exact request/response structure.

GPT_Services.oml
UserImage.jpg
Jayaprakash Ramesh

HI @AlexP ,
the model you selected in do the job very well in image and Binary analysis like image analysis and OCR, check with the MIME type and you API licensed version, if all were correct do a REST API request with the agent in inbuild ODC REST

UserImage.jpg
AlexP

Hi,
I am trying to use the "OutSystems Agent Workbench" here, which sould help to do model independent agent development.
But of course, you are right, this would work.

2023-10-16 05-50-48
Shingo Lam

I have not experience with gpt5.2 yet, but due to this document, you can try to not specify the FileFormat

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.