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
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?
Thanks for your input!
The model supports binary input just fine, I already tried it using the API
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:
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, 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.
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
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:
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.
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:
Minimum headers
Requirements / common pitfalls
I share a simple OutSystems Server Action pattern (REST integration) for this exact request/response structure.
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
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.
I have not experience with gpt5.2 yet, but due to this document, you can try to not specify the FileFormat