DELETE /api/v1/loras/{lora_id}
API version: v1.2.4
Delete a LoRA model and its associated files.
Endpoint
Plain text
DELETE /api/v1/loras/{lora_id}Authentication
Required. Include your API key in the request header:
Plain text
X-API-Key: your-api-key-herePath Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
lora_id | string | Yes | UUID of the LoRA model to delete |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | string | No | UUID for permission validation (required if LoRA has user ownership) |
Response
Success (200 OK)
JSON
{
"message": "LoRA model deleted successfully",
"lora_id": "550e8400-e29b-41d4-a716-446655440000"
}Response Fields
| Field | Type | Description |
|---|---|---|
message | string | Success confirmation message |
lora_id | string | UUID of the deleted LoRA model |
Examples
Delete LoRA (cURL)
cURL
curl -X DELETE "https://phosor.ai/api/v1/loras/550e8400-e29b-41d4-a716-446655440000" \
-H "X-API-Key: your-api-key"Delete with User Validation (cURL)
cURL
curl -X DELETE "https://phosor.ai/api/v1/loras/550e8400-e29b-41d4-a716-446655440000?user_id=123e4567-e89b-12d3-a456-426614174000" \
-H "X-API-Key: your-api-key"Delete LoRA (Python)
Python
import requests
def delete_lora(lora_id, api_key, user_id=None):
"""Delete a LoRA model"""
params = {}
if user_id:
params["user_id"] = user_id
response = requests.delete(
f"https://phosor.ai/api/v1/loras/{lora_id}",
headers={"X-API-Key": api_key},
params=params
)
if response.status_code == 200:
print(f"LoRA {lora_id} deleted successfully")
return True
elif response.status_code == 404:
print(f"LoRA {lora_id} not found")
return False
elif response.status_code == 403:
print(f"No permission to delete LoRA {lora_id}")
return False
else:
print(f"Error: {response.text}")
return False
# Usage
delete_lora("550e8400-e29b-41d4-a716-446655440000", "your-api-key")Delete with Confirmation (Python)
Python
import requests
def delete_lora_with_confirmation(lora_id, api_key):
"""Delete a LoRA model with user confirmation"""
# First, get LoRA details
details_response = requests.get(
f"https://phosor.ai/api/v1/loras/{lora_id}",
headers={"X-API-Key": api_key}
)
if details_response.status_code != 200:
print(f"LoRA {lora_id} not found")
return False
lora = details_response.json()
print(f"About to delete LoRA:")
print(f" Name: {lora['name']}")
print(f" Usage Count: {lora['usage_count']}")
print(f" Created: {lora['created_at']}")
# Confirm deletion
confirm = input("Are you sure you want to delete this LoRA? (yes/no): ")
if confirm.lower() != "yes":
print("Deletion cancelled")
return False
# Delete
delete_response = requests.delete(
f"https://phosor.ai/api/v1/loras/{lora_id}",
headers={"X-API-Key": api_key}
)
if delete_response.status_code == 200:
print("LoRA deleted successfully")
return True
else:
print(f"Failed to delete: {delete_response.text}")
return False
# Usage
delete_lora_with_confirmation("550e8400-e29b-41d4-a716-446655440000", "your-api-key")JavaScript Example
JavaScript
async function deleteLora(loraId, apiKey, userId = null) {
const url = new URL(`https://phosor.ai/api/v1/loras/${loraId}`);
if (userId) {
url.searchParams.append('user_id', userId);
}
const response = await fetch(url, {
method: 'DELETE',
headers: {
'X-API-Key': apiKey
}
});
if (response.ok) {
const result = await response.json();
console.log('Deleted:', result.lora_id);
return true;
} else if (response.status === 404) {
console.log('LoRA not found');
return false;
} else if (response.status === 403) {
console.log('No permission to delete');
return false;
} else {
console.error('Delete failed:', await response.text());
return false;
}
}
// Usage
deleteLora('550e8400-e29b-41d4-a716-446655440000', 'your-api-key');Batch Delete
Python
import requests
def delete_multiple_loras(lora_ids, api_key):
"""Delete multiple LoRA models"""
results = []
for lora_id in lora_ids:
response = requests.delete(
f"https://phosor.ai/api/v1/loras/{lora_id}",
headers={"X-API-Key": api_key}
)
results.append({
"lora_id": lora_id,
"success": response.status_code == 200,
"status_code": response.status_code
})
if response.status_code == 200:
print(f"Deleted: {lora_id}")
else:
print(f"Failed to delete {lora_id}: {response.status_code}")
return results
# Usage
lora_ids = [
"550e8400-e29b-41d4-a716-446655440000",
"661f9511-f30c-52e5-b827-557766551111",
"772g0622-g41d-63f6-c938-668877662222"
]
results = delete_multiple_loras(lora_ids, "your-api-key")
successful = sum(1 for r in results if r["success"])
print(f"Deleted {successful} of {len(lora_ids)} LoRAs")What Gets Deleted
When a LoRA model is deleted:
- High noise file - The high_noise.safetensors file is removed from Phosor Storage
- Low noise file - The low_noise.safetensors file is removed from Phosor Storage
- Database record - The LoRA status is set to
deleted(soft delete) - Cache entries - Any cached data for the LoRA is invalidated
Requirements
- LoRA must be in
readystatus to be deleted - If LoRA has a
user_id, the requesting user must match (or be an admin) - Cannot delete LoRAs in
pendingordownloadingstatus
Error Responses
LoRA Not Found (404 Not Found)
JSON
{
"error": "LoRA not found",
"message": "No LoRA model found with the specified ID or LoRA is not in 'ready' status"
}No Permission (403 Forbidden)
JSON
{
"error": "Permission denied",
"message": "You do not have permission to delete this LoRA model"
}Unauthorized (401 Unauthorized)
JSON
{
"error": "API key required",
"message": "X-API-Key header is required"
}