Assistant Generated File Extension


I need help in determining the extension of the generated file by Assistant, I am able to download the file, but is there a way to know the extension of the generated file so that I can properly save it?

For example if I tell the Assistant to generate me a chart then it’s most likely a .png image, but if I tell it to generate a chart and save it in a pdf file then the generated file is most likely a .pdf file.

Is there a way to automatically know the extension of the generated file?

Thanks in advance!


The only parts of an assistant that can generate images is functions, that you have total control over and code interpreter, again you can then specify what format you want any images to be in, so you should have total control of that at all times, plus the images that are saved as files should also have the correct file extension added to their file name. I’ve never had a .png that was really a jpg.


Thank you for your reply, let me clarify my case.

I have an assistant that I pass to it an excel file with data.

And I prompt the assistant to provide me with a chart and it replies with the chart, I use Retrieve file to get the chart and pass to it the file_id, the filename I receive does not have any extension like this example:

Retrieve file



“filename”:“3d0fa27c-b5e3-4db3-a10c-eb8d78c4d8bf” this does not have the extension.

Also, I am using API from C# in case this helps.

Am I doing this correctly? Is there another way I can know the extension of the file other than from file_id?

Thanks in advance!


C# is not a direct OpenAI library, so I’m not sure what features it may have.

If you have access to python you could use imghdr.what(path) where path is the path to your image file that you have saved and it will tell you what format the images is in, or you could just try loading the file in paint with the extension of .png or .jpg and see which one works to determine the file time being used.

You can also add instructions to save the image in PNG format in the instructions you give to the model when you ask it to provide you a chart, that way you’ll know ahead of time.

1 Like


Thank you for your help!

I tried instructing the model that the name of the generated charts include the .png extension, sadly it does not always follow that instruction.

I will try opening the file with assuming that it is an image, if it fails to open then I will assume the other option that it is a pdf and see if it works.

Thank you for the suggestions and your time!

I need this too. I think @Foxabilo was missing the point. Case in point, given an assistant with a CSV file and code interpreter. If you ask it an analytical question like how many categories are in this product database, it will generate an image and show it to you (in the playground). But from an API perspective, I do not know how and what the extension is. Only solution I can see now is we use some time of magic mime library to determine it.

UPDATE: The reason this work in the playground is due to how browsers work. They just have an img src set to the full path (no extension) and the browser happily displays it.