curl --request PUT \
--url https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.put(url, headers=headers)
print(response.text)const options = {method: 'PUT', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel"
req, _ := http.NewRequest("PUT", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"request_id": "6f1a1a6e-6a53-4a5f-9d3a-2b3b0a1f9c21",
"status": "CANCELLATION_REQUESTED"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"request_id": "6f1a1a6e-6a53-4a5f-9d3a-2b3b0a1f9c21",
"status": "CANCELLATION_REQUESTED"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}Ask for one submitted request to be cancelled.
Asks Comfy to stop a request that has not finished. It is a request, not a guarantee, and the 202 says exactly that: CANCELLATION_REQUESTED means the ask was accepted, not that the run has stopped. A run already on the wire at a partner may complete anyway - and a partner generation that completes is charged, whether or not anyone collected it - so a caller who needs to know what actually happened reads the status endpoint afterwards, where a cancellation that took effect is COMPLETED carrying an error_type like every other terminal outcome.
curl --request PUT \
--url https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.put(url, headers=headers)
print(response.text)const options = {method: 'PUT', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel"
req, _ := http.NewRequest("PUT", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.comfy.org/v2/models/{provider}/{model}/requests/{request_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"request_id": "6f1a1a6e-6a53-4a5f-9d3a-2b3b0a1f9c21",
"status": "CANCELLATION_REQUESTED"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"request_id": "6f1a1a6e-6a53-4a5f-9d3a-2b3b0a1f9c21",
"status": "CANCELLATION_REQUESTED"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}{
"detail": "<string>",
"error_type": "invalid_input",
"upstream_detail": "<string>",
"refusal_subject": "<string>"
}Authorizations
Bearer token authentication. Normally a Firebase or Cloud JWT. A 'comfyui-' prefixed API key is also accepted in this header: the prefix classifies the value as an API key and it is validated exactly as if it had been sent in X-API-Key.
Path Parameters
Lowercase provider segment of the canonical {provider}/{model} model ID - the partner whose model is being run.
Lowercase provider segment of the canonical {provider}/{model} model ID - the partner whose model is being addressed. The invocation route's provider path parameter and a catalog entry's provider field both reference this one schema, which is what keeps the listed IDs and the accepted IDs from drifting apart.
64^[a-z0-9]+([._-][a-z0-9]+)*$"bfl"
Lowercase model segment of the canonical {provider}/{model} model ID - the model to run within that provider.
Lowercase model segment of the canonical {provider}/{model} model ID - the model to run within that provider. Shared by the invocation route's model path parameter and a catalog entry's model field, for the same no-drift reason as RouterProviderSegment.
128^[a-z0-9]+([._-][a-z0-9]+)*$"flux-2-pro"
The queued request to address - the request_id the submission returned in its body. It is not the submission's X-Comfy-Request-Id: that header carries the id of one HTTP call and addresses nothing, as the RouterQueueRequestId schema spells out.
Identifier of one queued Router request - the handle a caller polls, cancels and collects a result by.
36^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"6f1a1a6e-6a53-4a5f-9d3a-2b3b0a1f9c21"
Response
Accepted - CANCELLATION_REQUESTED. The ask was accepted for a request that had not yet reached a terminal state. It is not a statement that the run has stopped; read the status endpoint to learn what it did.
The answer to a cancellation ask on the two statuses that describe a request this route resolved - the 202 and the 400. One body shape across both rather than a success envelope plus an error envelope, because both are the same statement - what cancelling found - and a client that has to parse a different type per status code gains nothing from the split.
Identifier of one queued Router request - the handle a caller polls, cancels and collects a result by.
36^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"6f1a1a6e-6a53-4a5f-9d3a-2b3b0a1f9c21"
What a cancellation ask found, for the two outcomes that describe a request this route actually resolved. Both are mirrored by the HTTP status, so a client may branch on either.
CANCELLATION_REQUESTED, ALREADY_COMPLETED "CANCELLATION_REQUESTED"
Was this page helpful?