from ai21 import AI21Client# Initialize the clientclient = AI21Client( api_key="your_api_key_here" # or use environment variable AI21_API_KEY)# Delete a file by its IDtry: client.library.files.delete("your-file-id-here") print("File deleted successfully")except Exception as e: print(f"Error deleting file: {e}")
File Library Management
Delete File
Delete the specified file from the library.
DELETE
/
studio
/
v1
/
library
/
files
/
{file_id}
Copy
Ask AI
from ai21 import AI21Client# Initialize the clientclient = AI21Client( api_key="your_api_key_here" # or use environment variable AI21_API_KEY)# Delete a file by its IDtry: client.library.files.delete("your-file-id-here") print("File deleted successfully")except Exception as e: print(f"Error deleting file: {e}")
Restrictions:
Files in PROCESSING status cannot be deleted. Attempts to delete such files will result in a 422 error.
from ai21 import AI21Client# Initialize the clientclient = AI21Client( api_key="your_api_key_here" # or use environment variable AI21_API_KEY)# Delete a file by its IDtry: client.library.files.delete("your-file-id-here") print("File deleted successfully")except Exception as e: print(f"Error deleting file: {e}")
Assistant
Responses are generated using AI and may contain mistakes.