创建批处理

帖子 https://api.openai.com/v1/batches

从上传的请求文件创建并执行批处理source

请求正文

包含新批处理请求的已上传文件的 ID。source

有关如何上传文件的信息,请参阅上传文件source

您的输入文件必须格式化为 JSONL 文件,并且必须具有batch.该文件最多可包含 50000 个请求,最大大小可达 200 MB。source

用于批处理中所有请求的终端节点。现在/v1/chat/completions,/v1/embeddings/v1/completions受支持。请注意,/v1/embeddings批处理还限制为批处理中所有请求的最多 50,000 个嵌入输入。source

应处理批处理的时间范围。目前仅24h受支持。source

批处理的可选自定义元数据。source

返回

创建的 Batch 对象。source

示例请求
1
2
3
4
5
6
7
8
curl https://api.openai.com/v1/batches \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input_file_id": "file-abc123",
    "endpoint": "/v1/chat/completions",
    "completion_window": "24h"
  }'
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "id": "batch_abc123",
  "object": "batch",
  "endpoint": "/v1/chat/completions",
  "errors": null,
  "input_file_id": "file-abc123",
  "completion_window": "24h",
  "status": "validating",
  "output_file_id": null,
  "error_file_id": null,
  "created_at": 1711471533,
  "in_progress_at": null,
  "expires_at": null,
  "finalizing_at": null,
  "completed_at": null,
  "failed_at": null,
  "expired_at": null,
  "cancelling_at": null,
  "cancelled_at": null,
  "request_counts": {
    "total": 0,
    "completed": 0,
    "failed": 0
  },
  "metadata": {
    "customer_id": "user_123456789",
    "batch_description": "Nightly eval job",
  }
}