Error retrieving file content

Hi,
I coded an assistant that receives a file, uploads it, and retrieves content from the file.
It worked fairly well, but it stopped working since this morning. I don’t think I made major modifications to my code, so I wonder if you have any clue ?

Here is my code (file was already loaded):

from openai import OpenAI

client = OpenAI()

file = "file-ImSNSQ3NmYkvWu9zcVxFuFPt"
print(client.files.retrieve(file))

content = client.files.content(file)
print(content)

Here is my error:


(base) ➜  ai-assistant-poc git:(main) ✗ python3 main.py
FileObject(id='file-ImSNSQ3NmYkvWu9zcVxFuFPt', bytes=1658085, created_at=1704452471, filename='1_InnoBrain.pdf', object='file', purpose='assistants', status='processed', status_details=None)
Traceback (most recent call last):
  File "/Users/myUser/Work/ai-assistant-poc/main.py", line 45, in <module>
    content = client.files.content(file)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myUser/miniconda3/lib/python3.11/site-packages/openai/resources/files.py", line 229, in content
    return self._get(
           ^^^^^^^^^^
  File "/Users/myUser/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1031, in get
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myUser/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 853, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/Users/myUser/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 930, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Not allowed to download files of purpose: assistants', 'type': 'invalid_request_error', 'param': None, 'code': None}}
1 Like

I had a similar problem but at higer level, i didn’t try to retrieve content by code.
The assistant response today is alwasy something like this:

The manual you requested a summary of is not accessible through my system. When I attempted to open the file using the provided ID, I encountered an error message indicating that the opened page had no contents. This may occur if the file is empty, corrupted, or if there is a technical issue with the file viewing system. I do not have the capability to view or analyze the file content further. Therefore, I am unable to provide you with a summary of the manual

I confirm that, same problem:

ERROR 2024-01-05 12:51:10,260 Error code: 400 - {'error': {'message': 'Not allowed to download files of purpose: assistants', 'type': 'invalid_request_error', 'param': None, 'code': None}}

The code you’re using is using the files API to retrieve file content of a file marked with purpose assistants.

It might be that OpenAI doesn’t allow downloading files marked with this purpose.

You can try the OpenAI files UI and it should give you delete and download (if download is allowed) options.
Screenshot 2024-01-06 at 9.24.33 AM

1 Like

Yes, according to the post below, it is not possible to recover content from files that have the purpose of assistant.

Not allowed to download files of purpose: assistants