POST /api/v1/storage/lora/import
API version: v1.2.4
Import LoRA model files from remote URLs instead of uploading directly.
Endpoint
Plain text
POST /api/v1/storage/lora/importAuthentication
Required. Include your API key in the request header:
Plain text
X-API-Key: your-api-key-hereRequest Body
Content Type
Plain text
application/jsonParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
high_noise_url | string | Yes | HTTPS URL to high noise .safetensors file |
low_noise_url | string | Yes | HTTPS URL to low noise .safetensors file |
name | string | No | Display name for the LoRA model |
description | string | No | Description of the LoRA model |
tags | string | No | JSON array string of tags |
default_scale | float | No | Default LoRA strength (0.0-1.0, default: 1.0) |
URL Requirements
- Protocol: HTTPS required (HTTP allowed but not recommended)
- Ports: Standard ports only (80 for HTTP, 443 for HTTPS)
- No credentials: URLs must not contain authentication credentials
- Public access: URLs must be publicly accessible
- File format: Must point to
.safetensorsfiles
Security Validation
The API performs SSRF protection:
- DNS resolution validated against private/reserved IP ranges
- Loopback addresses blocked (127.0.0.0/8, ::1)
- Private networks blocked (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
- AWS metadata endpoint blocked (169.254.169.254)
- Link-local addresses blocked
Response
Success (200 OK)
JSON
{
"lora_id": "550e8400-e29b-41d4-a716-446655440000",
"file_id": "lora-550e8400-e29b-41d4-a716-446655440000",
"name": "Imported LoRA Model",
"status": "pending",
"message": "LoRA import started. Use GET /api/v1/loras/{lora_id}/status to check progress."
}Response Fields
| Field | Type | Description |
|---|---|---|
lora_id | string | Unique UUID identifier for the LoRA model |
file_id | string | File identifier (format: lora-{uuid}) |
name | string | Display name of the LoRA model |
status | string | Import status: pending, downloading, ready, failed |
message | string | Instructions for checking import progress |
Examples
Import (cURL)
cURL
curl -X POST https://phosor.ai/api/v1/storage/lora/import \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"high_noise_url": "https://example.com/models/high_noise.safetensors",
"low_noise_url": "https://example.com/models/low_noise.safetensors",
"name": "My Imported LoRA"
}'Import from Hugging Face (Python)
Python
import requests
response = requests.post(
"https://phosor.ai/api/v1/storage/lora/import",
headers={
"X-API-Key": "your-api-key",
"Content-Type": "application/json"
},
json={
"high_noise_url": "https://huggingface.co/user/model/resolve/main/high_noise.safetensors",
"low_noise_url": "https://huggingface.co/user/model/resolve/main/low_noise.safetensors",
"name": "HuggingFace LoRA",
"description": "Imported from Hugging Face repository",
"tags": '["imported", "huggingface"]'
}
)
result = response.json()
print(f"Import started: {result['lora_id']}")Complete Import Flow
Python
import requests
import time
def import_lora_and_wait(high_url, low_url, name, api_key):
"""Import LoRA from URLs and wait for processing to complete"""
# Step 1: Start import
print("Starting LoRA import...")
response = requests.post(
"https://phosor.ai/api/v1/storage/lora/import",
headers={
"X-API-Key": api_key,
"Content-Type": "application/json"
},
json={
"high_noise_url": high_url,
"low_noise_url": low_url,
"name": name
}
)
if response.status_code != 200:
print(f"Import failed: {response.text}")
return None
lora_id = response.json()["lora_id"]
print(f"Import started. LoRA ID: {lora_id}")
# Step 2: Poll for completion
while True:
status_response = requests.get(
f"https://phosor.ai/api/v1/loras/{lora_id}/status",
headers={"X-API-Key": api_key}
)
status_data = status_response.json()
status = status_data["status"]
print(f"Status: {status}")
if status == "ready":
print("LoRA model is ready to use!")
return lora_id
elif status == "failed":
print(f"Import failed: {status_data.get('error_message')}")
return None
time.sleep(5)
# Usage
lora_id = import_lora_and_wait(
"https://example.com/high_noise.safetensors",
"https://example.com/low_noise.safetensors",
"My Imported LoRA",
"your-api-key"
)JavaScript Example
JavaScript
async function importLora(highNoiseUrl, lowNoiseUrl, name, apiKey) {
const response = await fetch('https://phosor.ai/api/v1/storage/lora/import', {
method: 'POST',
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
high_noise_url: highNoiseUrl,
low_noise_url: lowNoiseUrl,
name: name
})
});
if (response.ok) {
const result = await response.json();
console.log('Import started:', result.lora_id);
return result;
} else {
console.error('Import failed:', await response.text());
return null;
}
}
// Usage
importLora(
'https://example.com/high_noise.safetensors',
'https://example.com/low_noise.safetensors',
'My Imported LoRA',
'your-api-key'
);Status Transitions
The import process is non-blocking. Status transitions are:
Plain text
pending → downloading → ready
↘ failed- pending: Import request received, download queued
- downloading: Files being downloaded from remote URLs
- ready: LoRA model ready for use in video generation
- failed: Import failed (check
error_messagefor details)
Error Responses
Invalid URL Format (400 Bad Request)
JSON
{
"error": "Invalid URL",
"message": "URL must be a valid HTTPS URL"
}SSRF Protection (400 Bad Request)
JSON
{
"error": "URL validation failed",
"message": "URL resolves to a private or reserved IP address"
}Invalid Port (400 Bad Request)
JSON
{
"error": "Invalid URL",
"message": "Only standard ports (80, 443) are allowed"
}Unauthorized (401 Unauthorized)
JSON
{
"error": "API key required",
"message": "X-API-Key header is required"
}Use Cases
-
Hugging Face Models: Import LoRA models directly from Hugging Face repositories
-
Cloud Storage: Import from cloud storage (Phosor Storage, GCS, or other) public URLs
-
CDN Distribution: Import from CDN-hosted model files
-
Model Sharing: Share LoRA models between users via public URLs