Batches
Cancel a batch job
Cancel a batch job by ID
POST
Together AI SDK (Python)
Authorizations
Response
OK
Together AI SDK (Python)
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Cancel a batch job by ID
from together import Together
import os
client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)
batch = client.batches.cancel("<BATCH_ID>")
print(batch)import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const batch = await client.batches.cancel("<BATCH_ID>");
console.log(batch);
import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const batch = await client.batches.cancel("<BATCH_ID>");
console.log(batch);
curl -X POST "https://api.together.ai/v1/batches/<BATCH_ID>/cancel" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json"
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/batches/{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.together.ai/v1/batches/{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.together.ai/v1/batches/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/batches/{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": "01234567-8901-2345-6789-012345678901",
"user_id": "user_789xyz012",
"input_file_id": "file-input123abc456def",
"file_size_bytes": 1048576,
"status": "IN_PROGRESS",
"job_deadline": "2024-01-15T15:30:00Z",
"created_at": "2024-01-15T14:30:00Z",
"endpoint": "/v1/chat/completions",
"progress": 75,
"model_id": "Qwen/Qwen3.5-9B",
"output_file_id": "file-output789xyz012ghi",
"error_file_id": "file-errors456def789jkl",
"error": "<string>",
"completed_at": "2024-01-15T15:45:30Z"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}OK
Was this page helpful?
from together import Together
import os
client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)
batch = client.batches.cancel("<BATCH_ID>")
print(batch)import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const batch = await client.batches.cancel("<BATCH_ID>");
console.log(batch);
import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const batch = await client.batches.cancel("<BATCH_ID>");
console.log(batch);
curl -X POST "https://api.together.ai/v1/batches/<BATCH_ID>/cancel" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json"
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/batches/{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.together.ai/v1/batches/{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.together.ai/v1/batches/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/batches/{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": "01234567-8901-2345-6789-012345678901",
"user_id": "user_789xyz012",
"input_file_id": "file-input123abc456def",
"file_size_bytes": 1048576,
"status": "IN_PROGRESS",
"job_deadline": "2024-01-15T15:30:00Z",
"created_at": "2024-01-15T14:30:00Z",
"endpoint": "/v1/chat/completions",
"progress": 75,
"model_id": "Qwen/Qwen3.5-9B",
"output_file_id": "file-output789xyz012ghi",
"error_file_id": "file-errors456def789jkl",
"error": "<string>",
"completed_at": "2024-01-15T15:45:30Z"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}