Last Updated: Dec 30, 2025
Introduction
Crusoe Managed Inference provides high-performance access to specialized AI models like Decart MirageLSD. This article demonstrates how to transform video content using a text prompt via a managed batch queue. By leveraging our high-throughput infrastructure, users can achieve near-real-time results using standard curl commands as well as Python libraries.
Prerequisites
Access to Crusoe Intelligence Foundry
Terminal access with
curlinstalled OR Python 3.x installed withrequestslibrary & basic familiarity with Python scriptsInput video file
Step-by-Step Instructions
Generate Inference Key
The v2v video transformation process follows a logical lifecycle as explained below. Before that, generate an API Key in the Crusoe Foundry UI.
-
Click on "Get API Key" on the right top corner
-
Enter name, select Crusoe project name and/or set expiration date for the key. Click on Create and Copy the key as its used in the following steps.
⚠️ Important: Expiration date must be set after the current time. By default, keys are valid until 12:00 AM UTC on the chosen date.
-
If expiration is invalid, you will see an error as follows
Error Could not create Inference API Key: undefined
Interacting with Video to Video Decart MirageLSD Model using Curl
-
Upload the Input Video
Use the Files API to upload your source video to Crusoe Cloud storage. You must specify the purpose as "video" to ensure correct processing.Tip: To try the feature out, you could download any one sample videos from here.
$ curl -X POST https://ai-api-eu-iceland1-a.crusoecloud.com/v1/files \ -H 'Authorization: Bearer <API Key>' \ -H 'Crusoe-Project-Id: <Project ID>' \ -F "purpose=video" \ -F "file=@/path/to/your/video.mp4"Note: The name of the video must be "video.mp4"
Example Output
{"id":"3326b244-c5ea-4b3d-b298-0022f107913f","type":"video_input","bytes":3084764,"created_at":1766044079,"filename":"video.mp4","purpose":"video","status":"uploaded"} -
Submit the Request to the Queue
Send a POST request to the Decart MirageLSD endpoint, referencing yourfile_idfrom Step 1 and providing a text prompt for the desired modification.$ curl -X POST https://api-video.crusoe.ai/v1/queue/decart/miragelsd-1-batch/enhanced \ -H 'Authorization: Bearer <API Key>' \ -H 'Content-Type: application/json' \ -d '{ "file_id": "<file_id>", "prompt": "Modify the video to show a black horse" <---- update this prompt according to your desire }'Example Output
{"request_id":"ca01c37a5b8884e0ac8626c1a1a0368b","status_url":"https://api-video.crusoe.ai/v1/queue/decart/miragelsd-1-batch/requests/ca01c37a5b8884e0ac8626c1a1a0368b","cancel_url":"https://api-video.crusoe.ai/v1/queue/decart/miragelsd-1-batch/requests/ca01c37a5b8884e0ac8626c1a1a0368b/cancel"}% -
Monitor Job Status
The previous step returns arequest_id. Use this to poll the status URL until the job is complete (status 200).$ curl -X GET https://api-video.crusoe.ai/v1/queue/decart/miragelsd-1-batch/requests/<Request ID> \ -H 'Authorization: Bearer <API Key'Example Output
When successful, the response will include a
result_file_idas shown:{"request_id":"ca01c37a5b8884e0ac8626c1a1a0368b","result_file_id":"b9eedc81-e955-4bc0-be2a-86aea7717447","status":200,"last_updated":1766044329142} -
Download the Output Video
Once the status indicates completion, use the Files API to download the resulting video to your local machine.$ curl -X GET https://api-video.crusoe.ai/v1/files/<result_file_id> \ -H 'Authorization: Bearer <API Key>' \ -o /path/to/download/output.mp4Example Output
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2610k 100 2610k 0 0 1042k 0 0:00:02 0:00:02 --:--:-- 1042k
Interacting with Video to Video Decart MirageLSD Model using Crusoe’s MirageLSD Inference API
- Upload the Input Video
Save your video locally.
Use the following Python script to upload the video. Replace
<INPUT_VIDEO_PATH>, <YOUR_API_KEY>and<YOUR_PROJECT_ID>with the correct values
import requests
INPUT_VIDEO_PATH = "<INPUT_VIDEO_PATH>"
AUTH_TOKEN = "<YOUR_API_KEY>"
PROJECT_ID = "<YOUR_PROJECT_ID>"
with open(INPUT_VIDEO_PATH, "rb") as f:
upload_response = requests.post(
"https://ai-api-eu-iceland1-a.crusoecloud.com/v1/files",
headers={
"Authorization": f"Bearer {AUTH_TOKEN}",
"Crusoe-Project-Id": PROJECT_ID,
},
files={"file": f},
data={"purpose": "video"},
)
upload_response.raise_for_status()
upload_data = upload_response.json()
file_id = upload_data["id"]
print(f"File uploaded successfully. id: {file_id}")
Example Output:
File uploaded successfully. id: dd573be1-1ed1-4c9f-b9c1-de352901df30
Notes / Tips:
The returned
file_idis required for the batch inference request.Successful upload confirmation:
http_status 200.
Common errors:
401 Unauthorized→ invalid API key. Check if your key is valid and has not expired.Invalid file path → Python
FileNotFoundError. Confirm theINPUT_VIDEO_PATHis correct and exists.
2: Submit the MirageLSD Batch Inference Request
Enqueue a job using the uploaded
file_id. Replace<YOUR_API_KEY>, <YOUR_PROJECT_ID>and<UPLOADED_FILE_ID>with the correct values.<UPLOADED_FILE_ID>is thefile_idwe received in Step 2. Replace<YOUR_PROMPT_DESCRIBING_THE_DESIRED_VIDEO>with the prompt describing how you want the output video to look
import requests
AUTH_TOKEN = "<YOUR_API_KEY>"
PROJECT_ID = "<YOUR_PROJECT_ID>"
file_id = "<UPLOADED_FILE_ID>"
inference_response = requests.post(
"https://ai-api-eu-iceland1-a.crusoecloud.com/v1/queue/decart/miragelsd-1-batch/enhanced",
headers={
"Authorization": f"Bearer {AUTH_TOKEN}",
"Crusoe-Project-Id": PROJECT_ID,
"Content-Type": "application/json",
},
json={
"file_id": file_id,
"prompt": "<YOUR_PROMPT_DESCRIBING_THE_DESIRED_VIDEO>",
},
)
inference_response.raise_for_status()
inference_data = inference_response.json()
request_id = inference_data["request_id"]
status_url = inference_data["status_url"]
if not request_id or not status_url:
raise ValueError("Could not find 'request_id' or 'status_url' in enqueue response.")
print(f"Request enqueued. request_id: {request_id}")
print(f"Status Url: {status_url}")
Example Output:
Request enqueued. request_id: c4b7ff33ab1f5b7ed767a434285f2c25
Status Url: https://ai-api-eu-iceland1-a.crusoecloud.com/v1/queue/decart/miragelsd-1-batch/requests/c4b7ff33ab1f5b7ed767a434285f2c25Notes / Tips:
request_ididentifies your job.status_urlis used to poll for job completion.
Common errors:
400 Bad Request→ invalidfile_id. Confirm thatfile_idis correct401 Unauthorized→ invalid API key. Check if your key is valid and has not expired.
3: Poll for Job Completion
- Use the following Python script to poll for output status. Replace
<YOUR_API_KEY>, <YOUR_PROJECT_ID>with the correct values. Replace<STATUS_URL>with the value we received in Step 3.
import time
import requests
is_complete = False
result_file_id = None
AUTH_TOKEN = "<YOUR_API_KEY>"
PROJECT_ID = "<YOUR_PROJECT_ID>"
status_url = "<STATUS_URL>"
while not is_complete:
status_response = requests.get(
status_url,
headers={
"Authorization": f"Bearer {AUTH_TOKEN}",
"Crusoe-Project-Id": PROJECT_ID,
},
)
status_response.raise_for_status()
status_data = status_response.json()
status = status_data["status"]
if status == 200:
is_complete = True
result_file_id = status_data["result_file_id"]
else:
time.sleep(2)
print(f"Request complete. result_file_id: {result_file_id}")
- When complete, you’ll receive a
result_file_idthat points to the transformed output video.
Example Output:
Request complete. result_file_id: 5426b02e-9897-42c0-a4ef-09c2c4cc07f1Notes / Tips:
Polling every 2 seconds is sufficient for near-real-time batch jobs.
Use the
result_file_idto download the processed video.
Common errors:
400 Bad Request→ incorrectstatus_url. Verify that it is correct.
4: Download the Output Video
- Use the following Python script to download the output video file. Replace
<YOUR_API_KEY>, <YOUR_PROJECT_ID>with the correct values. Replace<OUTPUT_VIDEO_PATH>with the path where you want to save the file - exampleoutput/video_output.mp4. Replace<RESULT_FILE_ID>with the value we received in Step 4.
import requests
AUTH_TOKEN = "<YOUR_API_KEY>"
PROJECT_ID = "<YOUR_PROJECT_ID>"
OUTPUT_VIDEO_PATH = "<OUTPUT_VIDEO_PATH>"
result_file_id = "<RESULT_FILE_ID>"
download_response = requests.get(
f"https://ai-api-eu-iceland1-a.crusoecloud.com/v1/files/{result_file_id}",
headers={
"Authorization": f"Bearer {AUTH_TOKEN}",
"Crusoe-Project-Id": PROJECT_ID,
},
)
download_response.raise_for_status()
# Ensure output directory exists
import os
os.makedirs(os.path.dirname(OUTPUT_VIDEO_PATH), exist_ok=True)
with open(OUTPUT_VIDEO_PATH, "wb") as f:
f.write(download_response.content)
print(f"Output video saved at {OUTPUT_VIDEO_PATH}")
Example Output:
File downloaded successfully to: output/video_output.mp4Notes / Tips:
Make sure the directory in
OUTPUT_VIDEO_PATHexists.
Common errors:
404 Not Found→ invalidresult_file_id. Confirm if the result file id is correct401 Unauthorized→ invalid API key. Check if your key is valid and has not expired.Invalid output path -> Python
NotADirectoryError. Make sure the directory where you want to save the output video exists.
5: Combine the entire script
- You can combine Steps 2-5 in a single script. Example is given on the docs here.