Retrieving Files from Assistants API

Hi there,
I’ve got Open AI Assistant API configured and running in my webapp, but whenever the assistant generates a file(csv, pdf, xlsx, etc.) It displays at the end with what looks like a hyperlink to download the file but it only displays as text. I can’t figure out how to retrieve those files and store them in my DB in bubble. when checking the API calls, it always seems to just return a file_id for the file. Curious if anyone has figured out how to retrieve files from the Assistants api when it creates them. This is an example output that is returned if that helps at all:

"I have successfully created a CSV file containing all the Chromebooks currently in stock. The total quantity of Chromebooks in stock is 1,078.

You can download the CSV file with Chromebooks in stock from the following link: Download Chromebooks in Stock CSV"
It looks like it’s trying to return a link but like I said it just comes in as text like the above example

Any help would be appreciated!

Ask it to provide the URL just in plain text :joy:

Should’ve mentioned that that was the first workaround I tried, but the assistants API just gives a result for the link like this:

"Certainly! Here is the download URL for the CSV file containing all the Chromebooks currently in stock, in plain text:

sandbox:/mnt/data/chromebooks_in_stock.csv"

Looks like this is relevant: How do download files generated in AI Assistants? - #11 by nikunj - API - OpenAI Developer Forum

If you have the file ID already in your 1st API call looks like you just need to do one more GET request for the file https://platform.openai.com/docs/api-reference/files/retrieve-contents

You would setup the API call datatype as File so Bubble knows to save it to your storage

1 Like

That was the solution! Thanks so much!

1 Like