The way of deleting files in the api is hard if you uploaded a lot of files in an assistant or something else, and want to delete a lot of them. The series of commands down bellow was the way I found to delete all files from the API, of course you can select which files will stay, by deleting them from the api_files.json before running Command 2, this is the (selected) part in the title. (The commands where run in powershell)
Command 1 - creates the api_files.json file(replace DOT for . and DSLASH for //):
curl https:DSLASHapiDOTopenaiDOTcom/v1/files \ -H âAuthorization: Bearer $OPENAI_API_KEYâ>api_files.json
Command 2 - delete all files listed in api_files.json(replace DOT for . and DSLASH for //):
$jsonContent = Get-Content -Raw -Path âpath\to\your\api_files.jsonâ | ConvertFrom-Json
foreach ($entry in $jsonContent.data) {
$idValue = $entry.id
$curlCommand = âcurl https:DSLASHapiDOTopenaiDOTcom/v1/files/$idValue -X DELETE -H âAuthorization: Bearer $OPENAI_API_KEYââ
Invoke-Expression $curlCommand
}