Create Openai Batch
curl --request POST \
--url https://api.deepinfra.com/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "<string>",
"completion_window": "24h",
"metadata": {},
"output_expires_after": {
"anchor": "created_at",
"seconds": 2592000
}
}
'import requests
url = "https://api.deepinfra.com/v1/batches"
payload = {
"input_file_id": "<string>",
"completion_window": "24h",
"metadata": {},
"output_expires_after": {
"anchor": "created_at",
"seconds": 2592000
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input_file_id: '<string>',
completion_window: '24h',
metadata: {},
output_expires_after: {anchor: 'created_at', seconds: 2592000}
})
};
fetch('https://api.deepinfra.com/v1/batches', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'input_file_id' => '<string>',
'completion_window' => '24h',
'metadata' => [
],
'output_expires_after' => [
'anchor' => 'created_at',
'seconds' => 2592000
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.deepinfra.com/v1/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"<string>\",\n \"completion_window\": \"24h\",\n \"metadata\": {},\n \"output_expires_after\": {\n \"anchor\": \"created_at\",\n \"seconds\": 2592000\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input_file_id\": \"<string>\",\n \"completion_window\": \"24h\",\n \"metadata\": {},\n \"output_expires_after\": {\n \"anchor\": \"created_at\",\n \"seconds\": 2592000\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/batches")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input_file_id\": \"<string>\",\n \"completion_window\": \"24h\",\n \"metadata\": {},\n \"output_expires_after\": {\n \"anchor\": \"created_at\",\n \"seconds\": 2592000\n }\n}"
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,
"image_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Files & Batches
Create Openai Batch
POST
/
v1
/
batches
Create Openai Batch
curl --request POST \
--url https://api.deepinfra.com/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "<string>",
"completion_window": "24h",
"metadata": {},
"output_expires_after": {
"anchor": "created_at",
"seconds": 2592000
}
}
'import requests
url = "https://api.deepinfra.com/v1/batches"
payload = {
"input_file_id": "<string>",
"completion_window": "24h",
"metadata": {},
"output_expires_after": {
"anchor": "created_at",
"seconds": 2592000
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input_file_id: '<string>',
completion_window: '24h',
metadata: {},
output_expires_after: {anchor: 'created_at', seconds: 2592000}
})
};
fetch('https://api.deepinfra.com/v1/batches', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'input_file_id' => '<string>',
'completion_window' => '24h',
'metadata' => [
],
'output_expires_after' => [
'anchor' => 'created_at',
'seconds' => 2592000
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.deepinfra.com/v1/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"<string>\",\n \"completion_window\": \"24h\",\n \"metadata\": {},\n \"output_expires_after\": {\n \"anchor\": \"created_at\",\n \"seconds\": 2592000\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input_file_id\": \"<string>\",\n \"completion_window\": \"24h\",\n \"metadata\": {},\n \"output_expires_after\": {\n \"anchor\": \"created_at\",\n \"seconds\": 2592000\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/batches")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input_file_id\": \"<string>\",\n \"completion_window\": \"24h\",\n \"metadata\": {},\n \"output_expires_after\": {\n \"anchor\": \"created_at\",\n \"seconds\": 2592000\n }\n}"
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,
"image_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}When called with an API key, the key needs the
batch scope (about scopes).Authorizations
Body
application/json
Response
Successful Response