Cancel Batch
POST
/
v1
/
batches
/
:batch_id
/
cancel
Cancel Batch
curl --request POST \
--url https://api.neosantara.xyz/v1/batches/:batch_id/cancel \
--header 'x-api-key: <api-key>'import requests
url = "https://api.neosantara.xyz/v1/batches/:batch_id/cancel"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.neosantara.xyz/v1/batches/:batch_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.neosantara.xyz/v1/batches/:batch_id/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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.neosantara.xyz/v1/batches/:batch_id/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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.neosantara.xyz/v1/batches/:batch_id/cancel")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.neosantara.xyz/v1/batches/:batch_id/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"status": "<string>",
"cancelled_at": 123,
"request_counts": {
"total": 123,
"completed": 123,
"failed": 123
}
}Cancel a batch job that is currently in progress. Once cancelled, the batch cannot be resumed.
string
required
The ID of the batch to cancel (e.g.,
batch-abc123).Returns
string
The ID of the cancelled batch.
string
The object type, which is always
batch.string
The API endpoint that was used for the batch.
string
The batch status, which will be
canceled.integer
The Unix timestamp when the batch was cancelled.
object
{
"id": "batch-abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"status": "canceled",
"cancelled_at": 1699566000,
"request_counts": {
"total": 100,
"completed": 45,
"failed": 2
}
}
{
"error": {
"message": "Batch not found",
"type": "invalid_request_error",
"code": "batch_not_found"
}
}
{
"error": {
"message": "Cannot cancel batch with status: completed",
"type": "invalid_request_error",
"code": "cannot_cancel"
}
}
⌘I
Cancel Batch
curl --request POST \
--url https://api.neosantara.xyz/v1/batches/:batch_id/cancel \
--header 'x-api-key: <api-key>'import requests
url = "https://api.neosantara.xyz/v1/batches/:batch_id/cancel"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.neosantara.xyz/v1/batches/:batch_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.neosantara.xyz/v1/batches/:batch_id/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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.neosantara.xyz/v1/batches/:batch_id/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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.neosantara.xyz/v1/batches/:batch_id/cancel")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.neosantara.xyz/v1/batches/:batch_id/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"status": "<string>",
"cancelled_at": 123,
"request_counts": {
"total": 123,
"completed": 123,
"failed": 123
}
}