创建批处理任务
curl --request POST \
--url https://api.ppio.com/openai/v1/batches \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"input_file_id": "<string>",
"endpoint": "<string>",
"completion_window": "<string>"
}
'import requests
url = "https://api.ppio.com/openai/v1/batches"
payload = {
"input_file_id": "<string>",
"endpoint": "<string>",
"completion_window": "<string>"
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({input_file_id: '<string>', endpoint: '<string>', completion_window: '<string>'})
};
fetch('https://api.ppio.com/openai/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.ppio.com/openai/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>',
'endpoint' => '<string>',
'completion_window' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$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.ppio.com/openai/v1/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"completion_window\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
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.ppio.com/openai/v1/batches")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"completion_window\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ppio.com/openai/v1/batches")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"completion_window\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"input_file_id": "<string>",
"output_file_id": "<string>",
"error_file_id": "<string>",
"completion_window": "<string>",
"in_progress_at": {},
"expires_at": {},
"finalizing_at": {},
"completed_at": {},
"failed_at": {},
"expired_at": {},
"cancelling_at": {},
"cancelled_at": {},
"status": "<string>",
"errors": "<string>",
"version": 123,
"created_at": "<string>",
"updated_at": {},
"created_by": "<string>",
"created_by_key_id": "<string>",
"remark": "<string>",
"total": 123,
"completed": 123,
"failed": 123,
"metadata": {},
"request_counts": {
"total": 123,
"completed": 123,
"failed": 123
}
}批量推理
创建批处理任务
POST
/
openai
/
v1
/
batches
创建批处理任务
curl --request POST \
--url https://api.ppio.com/openai/v1/batches \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"input_file_id": "<string>",
"endpoint": "<string>",
"completion_window": "<string>"
}
'import requests
url = "https://api.ppio.com/openai/v1/batches"
payload = {
"input_file_id": "<string>",
"endpoint": "<string>",
"completion_window": "<string>"
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({input_file_id: '<string>', endpoint: '<string>', completion_window: '<string>'})
};
fetch('https://api.ppio.com/openai/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.ppio.com/openai/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>',
'endpoint' => '<string>',
'completion_window' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$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.ppio.com/openai/v1/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"completion_window\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
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.ppio.com/openai/v1/batches")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"completion_window\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ppio.com/openai/v1/batches")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"completion_window\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"input_file_id": "<string>",
"output_file_id": "<string>",
"error_file_id": "<string>",
"completion_window": "<string>",
"in_progress_at": {},
"expires_at": {},
"finalizing_at": {},
"completed_at": {},
"failed_at": {},
"expired_at": {},
"cancelling_at": {},
"cancelled_at": {},
"status": "<string>",
"errors": "<string>",
"version": 123,
"created_at": "<string>",
"updated_at": {},
"created_by": "<string>",
"created_by_key_id": "<string>",
"remark": "<string>",
"total": 123,
"completed": 123,
"failed": 123,
"metadata": {},
"request_counts": {
"total": 123,
"completed": 123,
"failed": 123
}
}成功 上传文件 后,使用该文件的 ID 来发起一个批处理任务。请注意,完成窗口固定为 48 小时,当前不可修改。
请求头
string
必填
枚举值:
application/jsonstring
必填
Bearer 身份验证格式,例如:Bearer {{API 密钥}}。
请求体
string
必填
已上传的、包含批处理请求的输入文件 ID。
string
必填
批处理所使用的端点。可用端点为
/v1/chat/completions 和 /v1/completions。为了兼容 OpenAI API,请将
endpoint 参数设置为 /v1/chat/completions 或 /v1/completions。string
批处理完成的时间窗口。当前固定为
48h,不可调整。响应
string
必填
批处理任务的唯一标识符。
string
必填
对象类型,恒为
batch。string
必填
批处理任务用于处理请求的 API 端点。
string
必填
包含批处理请求的输入文件 ID。
string
必填
包含批处理结果的输出文件 ID。在批处理完成之前为空。
string
必填
包含批处理过程中发生的错误的错误文件 ID。在出现错误之前为空。
string
必填
批处理完成的时间窗口。当前固定为
48h。string | null
批处理开始处理的时间戳。若尚未开始则为 null。
string | null
批处理到期的时间戳。若未设置则为 null。
string | null
批处理开始进入最终化阶段的时间戳。若尚未进入则为 null。
string | null
批处理完成的时间戳。若尚未完成则为 null。
string | null
批处理失败的时间戳。若未失败则为 null。
string | null
批处理过期的时间戳。若未过期则为 null。
string | null
批处理开始取消的时间戳。若未在取消中则为 null。
string | null
批处理被取消的时间戳。若未被取消则为 null。
string
必填
批处理任务的当前状态。可用状态:
VALIDATING- 在批处理开始前正在验证输入文件PROGRESS- 批处理进行中COMPLETED- 批处理成功完成FAILED- 批处理失败EXPIRED- 批处理超过截止时间CANCELLING- 正在取消批处理CANCELLED- 批处理已取消
string
批处理过程中发生错误时的错误信息。
integer
必填
批处理任务的版本号。
string
必填
批处理任务的创建时间戳。
string | null
批处理任务最近一次更新的时间戳。若从未更新则为 null。
string
必填
创建该批处理任务的用户唯一标识符。
string
必填
用于创建该批处理任务的 API Key ID。
string
批处理任务的可选备注信息。
integer
必填
批处理中的请求总数。
integer
必填
批处理中已完成的请求数量。
integer
必填
批处理中失败的请求数量。
object | null
与批处理任务关联的附加元数据。若无则为 null。
最后修改于 2026年1月12日