How to upload file from Salesforce to Assistants API for File Search?

As we are integrating Salesforce to Open AI Assistants - Upload File API, we discovered that the API doesn’t accept blob/base 64 encoding format of files. It accepts only the actual file in the API request body using “form-data” method.

Unfortunately, we are not able to find a way to send the file in form-data method via Apex to the REST API. When we surfed through Salesforce forums as well, we are finding answers from the community that Apex is not supporting this kind of API calls currently.

Has anyone integrated Salesforce to Assistant API for File Search use case before? It would be great if we can get some guidance on this.

I have the exact same issue. I’m trying to implement a solution where we can directly upload files from Salesforce to OpenAI, but as far as I can tell, this method of uploading files is not supported on the Salesforce side. If anyone finds a solution other than a middleware, it would be much appreciated!

It seems it shouldn’t be impossible to create a blob that includes the boundaries, sections, and the file contents. I can’t post the link, but ChatGPT had some ideas about composing a form-data blob.

The problem with it is at some point, all the base64 data has to fit in memory and Apex doesn’t have an excess of memory for larger files.

Perhaps if there was a way to indicate the fie had to be retrieved via a connected app, so the file could be fetched in binary, would be another way to try it.

Another alternative is to upload the file separately and record its vector store id to be used later in the query.

I’m still thinking about it.