Retrieve file content API is not allowing to retrive content

Is there any limitation to downloading (retrieving content) files? I got this error and couldn’t find any information on documentation.

{
  "error": {
    "code": null,
    "message": "Not allowed to download files of purpose: fine-tune",
    "param": null,
    "type": "invalid_request_error"
  }
}

I tried search file purpose too and got a similar error.

Also, as feedback, I couldn’t find any documentation about error responses. It would be nice to have one.

Hello!

Currently, we only allow downloads on the results of fine-tuning runs and not the input files to the fine tuning run. We also don’t allow downloads for search related files.

Out of curiosity, why do you want to download fine-tuning files? We can also update our documentation to indicate which purposes can be downloaded and which can’t.

2 Likes

Thanks for the reply.
I was just updating the C# SDK. I don’t have any use case other than testing.

1 Like

I had the same experience today.

Downloading the original fine-tuning files again would have been a nice feature to make the whole /files endpoint more “feature complete”.

My current use-case is a “company assistant” based on a company knowledge base. Currently i am working on a web-based file manager and content editor to give selected team-members the ability to update the existing knowledge base.

Reading the API doc gave me the impression that a first rudimentary editor concept could have been so easy as: upload a file once and then have other members: download → update/extend the content in a nice (web-based) editor → upload the file again.

Of course now i have to keep the content in a database which is also ok and maybe even better in the long-run but also includes unplanned effort in the prototyping phase which would have been better to estimate if the docs would have been more clear.

So please update the docs about restrictions or enable the download of fine-tuning files :slight_smile:

thanks,
Andreas

At least for me, with the update with Assistants API, I cannot seem to see what I uploaded. So to andreas’s point, I might upload a company knowledge base, then I make changes and upload again. Or I might upload a photo, yet in the files tab I can’t see the photos uploaded. It’s just really frustrating because I have to keep a mental running tab of what files are what, and when other people in my organization work, they wouldn’t know what files are what as well.

I uploaded a file using the following code snippet -

    async def upload_file(self, filepath: str, delete_file_after_upload=True) -> FileObject:
        if os.path.exists(filepath) is False:
            raise ValueError(f"{filepath} doesn't exists or is invalid")

        with open(filepath, "rb") as infile:
            file_obj = await self.__openai_client.files.create(file=infile, purpose="assistants")

        if delete_file_after_upload and file_obj.status == "uploaded":
            os.remove(filepath)

        return file_obj

now when I try to download the same file using this code snippet -

    async def get_file_contents(self, file_id: str) -> str:
        client = self.__openai_client
        print("file_id: ", file_id)
        content = await client.files.retrieve_content(file_id=file_id, timeout=60)
        return content

I get the following error -

openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: ‘Not allowed to download files of purpose: assistants’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}