创建批处理任务
curl --request POST \
--url https://open.bigmodel.cn/api/paas/v4/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "<string>",
"endpoint": "/v4/chat/completions",
"auto_delete_input_file": true,
"metadata": {}
}
'import requests
url = "https://open.bigmodel.cn/api/paas/v4/batches"
payload = {
"input_file_id": "<string>",
"endpoint": "/v4/chat/completions",
"auto_delete_input_file": True,
"metadata": {}
}
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>',
endpoint: '/v4/chat/completions',
auto_delete_input_file: true,
metadata: {}
})
};
fetch('https://open.bigmodel.cn/api/paas/v4/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/paas/v4/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"/v4/chat/completions\",\n \"auto_delete_input_file\": true,\n \"metadata\": {}\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/paas/v4/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"/v4/chat/completions\",\n \"auto_delete_input_file\": true,\n \"metadata\": {}\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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/paas/v4/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' => '/v4/chat/completions',
'auto_delete_input_file' => true,
'metadata' => [
]
]),
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;
}{
"id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"input_file_id": "<string>",
"completion_window": "<string>",
"status": "<string>",
"output_file_id": "<string>",
"error_file_id": "<string>",
"created_at": 123,
"in_progress_at": 123,
"expires_at": 123,
"finalizing_at": 123,
"completed_at": 123,
"failed_at": 123,
"expired_at": 123,
"cancelling_at": 123,
"cancelled_at": 123,
"request_counts": 123,
"total": 123,
"completed": 123,
"failed": 123,
"metadata": {}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}批处理 API
创建批处理任务
创建一个新的批量处理任务。见 批量服务。点击 Try it 按钮可快速试用。
POST
/
paas
/
v4
/
batches
创建批处理任务
curl --request POST \
--url https://open.bigmodel.cn/api/paas/v4/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "<string>",
"endpoint": "/v4/chat/completions",
"auto_delete_input_file": true,
"metadata": {}
}
'import requests
url = "https://open.bigmodel.cn/api/paas/v4/batches"
payload = {
"input_file_id": "<string>",
"endpoint": "/v4/chat/completions",
"auto_delete_input_file": True,
"metadata": {}
}
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>',
endpoint: '/v4/chat/completions',
auto_delete_input_file: true,
metadata: {}
})
};
fetch('https://open.bigmodel.cn/api/paas/v4/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/paas/v4/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"/v4/chat/completions\",\n \"auto_delete_input_file\": true,\n \"metadata\": {}\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/paas/v4/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"<string>\",\n \"endpoint\": \"/v4/chat/completions\",\n \"auto_delete_input_file\": true,\n \"metadata\": {}\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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/paas/v4/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' => '/v4/chat/completions',
'auto_delete_input_file' => true,
'metadata' => [
]
]),
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;
}{
"id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"input_file_id": "<string>",
"completion_window": "<string>",
"status": "<string>",
"output_file_id": "<string>",
"error_file_id": "<string>",
"created_at": 123,
"in_progress_at": 123,
"expires_at": 123,
"finalizing_at": 123,
"completed_at": 123,
"failed_at": 123,
"expired_at": 123,
"cancelling_at": 123,
"cancelled_at": 123,
"request_counts": 123,
"total": 123,
"completed": 123,
"failed": 123,
"metadata": {}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Was this page helpful?