Skip to main content
POST
/
v1
/
batches
/
{batch_id}
/
cancel
Cancel Openai Batch
curl --request POST \
  --url https://api.deepinfra.com/v1/batches/{batch_id}/cancel \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://api.deepinfra.com/v1/batches/{batch_id}/cancel"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.deepinfra.com/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.deepinfra.com/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 => [
"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.deepinfra.com/v1/batches/{batch_id}/cancel"

req, _ := http.NewRequest("POST", 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.post("https://api.deepinfra.com/v1/batches/{batch_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.deepinfra.com/v1/batches/{batch_id}/cancel")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "endpoint": "<string>",
  "input_file_id": "<string>",
  "completion_window": "<string>",
  "status": "<string>",
  "created_at": 123,
  "expires_at": 123,
  "object": "batch",
  "errors": {
    "object": "list",
    "data": [
      {
        "code": "<string>",
        "line": 123,
        "message": "<string>",
        "param": "<string>"
      }
    ]
  },
  "output_file_id": "<string>",
  "error_file_id": "<string>",
  "in_progress_at": 123,
  "finalizing_at": 123,
  "completed_at": 123,
  "failed_at": 123,
  "expired_at": 123,
  "cancelling_at": 123,
  "cancelled_at": 123,
  "request_counts": {
    "total": 0,
    "completed": 0,
    "failed": 0
  },
  "metadata": {},
  "model": "<string>",
  "usage": {
    "input_tokens": 0,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 0,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 0
  }
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

xi-api-key
string | null
x-api-key
string | null

Path Parameters

batch_id
string
required

Response

Successful Response

id
string
required

The batch ID.

endpoint
string
required

The API endpoint used for the batch.

input_file_id
string
required

The ID of the input file for the batch.

completion_window
string
required

The time frame within which the batch should be processed.

status
string
required

The current status of the batch.

created_at
integer
required

The Unix timestamp of when the batch was created.

expires_at
integer
required

The Unix timestamp of when the batch will expire.

object
string
default:batch

The object type, which is always batch.

Allowed value: "batch"
errors
BatchErrors · object | null

Errors that occurred during the batch.

output_file_id
string | null

The ID of the output file.

error_file_id
string | null

The ID of the error file.

in_progress_at
integer | null

The Unix timestamp of when the batch started processing.

finalizing_at
integer | null

The Unix timestamp of when the batch started finalizing.

completed_at
integer | null

The Unix timestamp of when the batch completed.

failed_at
integer | null

The Unix timestamp of when the batch failed.

expired_at
integer | null

The Unix timestamp of when the batch expired.

cancelling_at
integer | null

The Unix timestamp of when the batch started cancelling.

cancelled_at
integer | null

The Unix timestamp of when the batch was cancelled.

request_counts
BatchRequestCounts · object | null

Request counts for the batch.

metadata
Metadata · object | null

Metadata associated with the batch.

model
string | null

The model used for the batch.

usage
BatchUsage · object | null

Token usage accumulated for the batch.