Stop a prediction before it finishes
Jul 31, 2026
·2 minute read
You can now cancel a prediction while it's running.
Video generation models like stability-ai/stable-video-diffusion-img2vid-xt can take minutes to produce a single clip. A long passage fed to hexgrad/kokoro-82M runs for a while too. Sometimes a model just gets stuck. Until now, once a prediction started, it ran to completion. You could wait it out, or ignore the output when it eventually showed up, but there was no way to actually stop it.
How to cancel a prediction
All it takes is the prediction's ID. Every client, and the raw API, accept the same thing.
Python
1wriftai.predictions.cancel("your-prediction-id")
Javascript / Typescript
1await wriftai.predictions.cancel('your-prediction-id');
Go
1err := client.Predictions.Cancel(context.TODO(), "your-prediction-id")
CLI
1wriftai predictions cancel your-prediction-id
Direct API call
1curl -X POST https://api.wrift.ai/v1/predictions/your-prediction-id/cancel \2 -H "Authorization: Bearer $WRIFTAI_ACCESS_TOKEN"
What to expect
Cancellation is asynchronous, but in practice it's fast. If a runtime has already picked up the prediction (status started), cancelling it takes effect almost immediately.
If you cancel a prediction that's still pending, before a runtime has picked it up, the request is simply recorded. You don't need to retry it or track it yourself. The moment a runtime picks the prediction up, it cancels right away. Time spent in the queue isn't billed either way.
A few things worth knowing
- Cancelling twice is safe. The second call is a no-op.
- Cancelling a prediction that's already finished returns an error. There's nothing left to stop in a prediction that's already been terminated.
- A prediction can still finish right as you cancel it. You'll see
succeededinstead ofcancelled. That's not a bug. The prediction won the race. - Cancellation isn't a timeout. Predictions already have an execution time limit regardless of whether you call cancel.
Right now cancellation is only available through the API and SDKs. Dashboard support is coming.
Full details on the status lifecycle, execution limits, and output retention are in the prediction docs.