Deleting multiple files in the dashboard

Hey guys, I was running an experiment with vector databases and decided to upload an parsed car mechanic manual of more than 400 JSON files, only to later realize that you got to delete the files individually in the OpenAI API dashboard.

This is extremely frustrating and makes me wonder how does OpenAI run a multi billion dollar business lacking essential UX features like these? It seems like something obvious, even an alert before uploading the files would’ve been nice…

The API Playground site is just as you describe: a place to experiment

  • Application
  • Programming
  • Interface

allows you to write programs that will delete 100 files a minute while you have a cuppa tea.

Still, a batch delete method that accepts a list of file IDs seems like an obvious addition to the API that is not present.


Alright, I made a simple python script to easily delete all the files in the storage in just a minute, I’ll leave it here in case someone finds it useful:

import openai

# Initialize the client
client = openai.OpenAI(api_key='[YOUR_API_KEY_HERE]')

# List files in your OpenAI storage
response = client.files.list()

# Initialize a counter for the total number of files
file_count = 0

# List to store file IDs for deletion
file_ids = []

# Iterate over the files and count them
for file in response:
    file_count += 1
    print(f"ID: {}, Filename: {file.filename}, Purpose: {file.purpose}")

# Print the total number of files
print(f"Total number of files: {file_count}")

# Ask user if they want to delete all files
delete_all = input("Would you like to delete all files? (Y/N): ").strip().upper()

if delete_all == 'Y':
    # Iterate over file IDs and delete each file
    for file_id in file_ids:
        print(f"Deleted file with ID: {file_id}")
    print("All files have been deleted.")
    print("No files were deleted.")

To run it:

  • Create file and paste the code.
  • Replace the [YOUR_API_KEY_HERE] text with your API key generated in the OpenAI dashboard.
  • Run in a terminal: python