Cancel Run Endpoint
curl --request POST \
--url https://api.example.com/threads/{thread_id}/runs/{run_id}/cancelimport requests
url = "https://api.example.com/threads/{thread_id}/runs/{run_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/threads/{thread_id}/runs/{run_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.example.com/threads/{thread_id}/runs/{run_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$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.example.com/threads/{thread_id}/runs/{run_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/threads/{thread_id}/runs/{run_id}/cancel")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/threads/{thread_id}/runs/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"run_id": "<string>",
"thread_id": "<string>",
"assistant_id": "<string>",
"user_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"status": "pending",
"input": {},
"output": {},
"error_message": "<string>",
"config": {},
"context": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Thread Runs
Cancel Run Endpoint
Cancel a running execution.
action=cancel and action=interrupt are currently aliases: both stop
the run immediately and finalize it as interrupted. Neither action
provides cooperative graph-level handling or guarantees saved partial
state. Set wait=1 to wait up to 10 seconds
for the background task to settle before returning the updated run. The
response may still report pending or running if the timeout expires.
Without wait=1, a live-owned run is cancelled asynchronously, so the
response may still report pending or running.
POST
/
threads
/
{thread_id}
/
runs
/
{run_id}
/
cancel
Cancel Run Endpoint
curl --request POST \
--url https://api.example.com/threads/{thread_id}/runs/{run_id}/cancelimport requests
url = "https://api.example.com/threads/{thread_id}/runs/{run_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/threads/{thread_id}/runs/{run_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.example.com/threads/{thread_id}/runs/{run_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$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.example.com/threads/{thread_id}/runs/{run_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/threads/{thread_id}/runs/{run_id}/cancel")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/threads/{thread_id}/runs/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"run_id": "<string>",
"thread_id": "<string>",
"assistant_id": "<string>",
"user_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"status": "pending",
"input": {},
"output": {},
"error_message": "<string>",
"config": {},
"context": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Query Parameters
Response
Successful Response
Run entity model
Status values: pending, running, error, success, timeout, interrupted