Assistants API: Uploading a File with Power Automate

Hello World

I am trying to upload a simple PDF file to an Assistants API thread using Microsoft Power Automate.

The file does upload into Storage and is visible from the Storage section of the Open AI Dashboard.
However, when attached to a message asking an Assistant to review the PDF it responds but is unable to interogate the PDF.
Note: the PDF is valid and I have tried several PDF files. If I upload the same file using Assistants Playground it works as expected and the AI can work with the PDF file.

My suspicion is that the encoding at point of upload is wrong. Seeking help to determine the correct approach.

My Power Automate process is:

  1. SharePoint - Get File Content

  2. HTTP Post - to https://api.openai.com/v1/files
    Authorisation and Content-Type: multipart/form-data; boundary=YOUR_BOUNDARY

--YOUR_BOUNDARY Content-Disposition: form-data; name="purpose"

assistants
–YOUR_BOUNDARY
Content-Disposition: form-data; name=“file”; filename=“Document.pdf”
Content-Type: application/pdf

@{body(‘Get_file_content_SP’)}
–YOUR_BOUNDARY–

NOTE: the local MacOS filesize is 15k but when uploaded into OpenAI storage it is listed as 22k.

Below is an sample of the first few lines from the output of @{body(‘Get_file_content_SP’)}
Should I convert it to base64?

%PDF-1.7
%����
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(en) /StructTreeRoot 15 0 R/MarkInfo<</Marked true>>/Metadata 27 0 R/ViewerPreferences 28 0 R>>
endobj
2 0 obj
<</Type/Pages/Count 1/Kids[ 3 0 R] >>
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R/F2 12 0 R>>/ExtGState<</GS10 10 0 R/GS11 11 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 595.25 842] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0>>
endobj
4 0 obj
<</Filter/FlateDecode/Length 224>>
stream
x���;o�0 �w�7&,��eɀ���)�!��E� ��}��t�%ݪ�y’����q��Ry�=�|��6׹8 ۜ��>�"Cˋ1��eo�G�,��Z=?֪�*w �ߴb��o��Q�Ŵ?3a����֒˽V/��q9:��u"�]���I��&���ʅZK䆵��rC��3יIh�e�i���ғV�He��b��Ku˲&�{�ñ��zH[

Even if it’s a PDF, if the content is composed of images, it may not be read correctly.

In that case, it might be better to send it as base64 encoded image data instead of as a PDF, as it would likely be read more accurately.

did you ever figure this out - I am having the same issue now ? keeps corrupting the files and doubling the file size ?