Skip to main content
DELETE
/
studio
/
v1
/
library
/
files
/
{file_id}
from ai21 import AI21Client  # Initialize the client client = AI21Client(  api_key="your_api_key_here" # or use environment variable AI21_API_KEY )  # Delete a file by its ID try:  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.

Responses

Response 200

Successful deletion. No body content.

Response 422

File by this ID does not exist.
from ai21 import AI21Client  # Initialize the client client = AI21Client(  api_key="your_api_key_here" # or use environment variable AI21_API_KEY )  # Delete a file by its ID try:  client.library.files.delete("your-file-id-here")  print("File deleted successfully") except Exception as e:  print(f"Error deleting file: {e}") 
⌘I