Can not download assistant generated file / download link (assistants-api V2)

I have created an assistant with the new V2 API in a python file.

The original message to the assistant asks for extracting tables from a pdf.

The pdf is directly uploaded in the message by

  1. Uploading the file
file = client.files.create(file = open(file_path,mode="rb"), purpose = "assistants")
  1. Attaching the file when creating the message
attachments = [{"file_id": file.id, "tools": [{"type": "file_search"}]}] 

The message asks to return these tables as a csv file and asks the assistant to provide the “file id” from the csv file that it will generate.
Here are the “attachment” attribute details from the original message:

attachments=[Attachment(file_id='file-8TrHfQH86DIEx4e9D47Lu0q4', tools=[AttachmentToolAssistantToolsFileSearchTypeOnly(type='file_search')])]

At the end of the run, the assistant answers that the job is done and replies:

The file ID for the CSV file is: file-8TrHfQH86DIEx4e9D47Lu0q4. You can download the CSV file using the following link: Download CSV file.

Question:
How are we supposed to access/download this file from code?

Issues:

  1. The file id in the assistant’s message is exactly the same file id from the original file uploaded/forwarded/attached to the original message.

  2. This is confirmed when trying to actually download this file through a get request, which returns:
    image

Error: 400
{'error': {'message': 'Not allowed to download files of purpose: assistants', 'type': 'invalid_request_error', 'param': None, 'code': None}}
  1. Inspecting the assistant’s message reveals that there is nothing in the assistant’s “attachments” attribute:
attachments=[]
  1. I have seen people trying to process this file through file_id retrieval but there is no file_id reference to this mentioned csv file offered by the assistant that is any different from the file_id of the original pdf file uploaded. There is no other file id mentioned in the entire thread.

  2. I have no idea if the link mentioned by the assistant actually exists or how to access it if the file is there:

sandbox:/files/download/file-8TrHfQH86DIEx4e9D47Lu0q4

Due to API’s beta status I am not sure if this download functionality has been developed yet as i can not find any reference in the documentation. Any feedback appreciated.

1 Like