Cancel a video job
Stop a video job that is waiting or running. A cancelled job is not charged.
MarkdownPOST
/v1/videos/{id}/cancelCancels a job and returns the job object with status: "cancelled". A job still waiting in Lykia's queue is always cancelled. A job already with the provider is cancelled only when the provider allows it at that stage. A cancelled job costs nothing.
Example
Request
curl -X POST https://api.getlykia.com/v1/videos/gen-1795463449-mbcwAk5o21bdfuKi/cancel \
-H "Authorization: Bearer $LYKIA_API_KEY"import os
import requests
VIDEO_ID = "gen-1795463449-mbcwAk5o21bdfuKi"
response = requests.post(
f"https://api.getlykia.com/v1/videos/{VIDEO_ID}/cancel",
headers={"Authorization": f"Bearer {os.environ['LYKIA_API_KEY']}"},
timeout=30,
)
if response.status_code == 409:
# Already finished, or the provider cannot stop it at this stage
print(response.json()["error"]["code"])
else:
response.raise_for_status()
print(response.json()["status"]) # "cancelled"; a cancelled job is freeResponse200
{
"id": "gen-1795463449-mbcwAk5o21bdfuKi",
"object": "video",
"status": "cancelled",
"progress": 0,
"model": "bytedance/seedance-1.0-pro",
"provider": "bytedance",
"created_at": 1795463449,
"completed_at": 1795463449,
"expires_at": null,
"duration_seconds": null,
"params": {
"duration": 5,
"image": false,
"last_frame": false,
"reference_images": 0
},
"error": {
"message": "The job was cancelled",
"code": "cancelled",
"reason": "invalid_request"
},
"usage": {
"cost": 0,
"is_byok": false,
"cost_details": {
"upstream_cost": 0,
"platform_fee": 0,
"is_byok": false
}
}
}Errors
| Status | Code | When |
|---|---|---|
404 | not_found | No such job in this project. |
409 | job_not_cancellable | The job has already finished, or the provider cannot cancel it now. |