I tried to delete one of the file from the list, but it throws an error “No such File object”.
l = client.files.list().data
client.files.delete(l[0].id)
Traceback (most recent call last):
File “”, line 1, in
File “D:\code\python\gpt.venv\lib\site-packages\openai\resources\files.py”, line 190, in delete
timeout: Override the client-level default timeout for this request, in seconds
File “D:\code\python\gpt.venv\lib\site-packages\openai_base_client.py”, line 1091, in delete
return self.request(cast_to, opts)
File “D:\code\python\gpt.venv\lib\site-packages\openai_base_client.py”, line 834, in request
return self._request(
File “D:\code\python\gpt.venv\lib\site-packages\openai_base_client.py”, line 877, in _request
raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {‘error’: {‘message’: ‘No such File object: file-xxxx’, ‘type’: ‘invalid_request_error’, ‘param’: ‘id’, ‘code’: None}}
4 Likes
I’m getting the same error here, it seems to be because I uploaded the file in the create assistant phase but didn’t reference it, and then couldn’t delete it afterwards
Ah, probably that’s my case too because I was following the tutorial. I deleted the assistance before I deleted the file.
Do the files just live there forever then?
I have the same problem, I don’t think so because there is a “delete” option in the files.
Hi! I’m having the same problem in here. I run the following script and it doesn’t work as expected:
# The headers for the authorization
headers = {
'Authorization': f'Bearer {api_key}'
}
# The DELETE request to remove the specified file
response = requests.delete(f'https://api.openai.com/v1/files/{file_id}', headers=headers)
# Check the response
if response.status_code == 204:
print('File deleted successfully.')
else:
print(f'Failed to delete file. Status code: {response.status_code}')
print(f'Response: {response.text}')
As well I tried to do it by the UI and it’s the same error.
They must have fixed now. I was able to delete all my files.
for file in client.files.list().data:
client.files.delete(file.id)
1 Like