列出消息批处理
get /v1/messages/batches
列出工作区中的所有消息批处理。最近创建的批处理优先返回。
在我们的用户指南中了解更多关于 Message Batches API 的信息
查询参数
-
after_id: optional string用作分页游标的对象 ID。提供时,返回此对象之后的结果页。
-
before_id: optional string用作分页游标的对象 ID。提供时,返回此对象之前的结果页。
-
limit: optional number每页返回的项目数。
默认为
20。范围从1到1000。
返回值
-
data: array of MessageBatch-
id: string唯一对象标识符。
ID 的格式和长度可能会随时间变化。
-
archived_at: stringRFC 3339 日期时间字符串,表示消息批处理被归档且其结果变为不可用的时间。
-
cancel_initiated_at: stringRFC 3339 日期时间字符串,表示为消息批处理启动取消的时间。仅在启动取消时指定。
-
created_at: stringRFC 3339 日期时间字符串,表示消息批处理创建的时间。
-
ended_at: stringRFC 3339 日期时间字符串,表示消息批处理处理结束的时间。仅在处理结束后指定。
当消息批处理中的每个请求已成功、出错、取消或过期时,处理结束。
-
expires_at: stringRFC 3339 日期时间字符串,表示消息批处理将过期并结束处理的时间,即创建后 24 小时。
-
processing_status: "in_progress" or "canceling" or "ended"消息批处理的处理状态。
-
"in_progress" -
"canceling" -
"ended"
-
-
request_counts: MessageBatchRequestCounts按状态分类统计消息批处理中的请求。
请求从
processing开始,只有在整个批处理处理结束后才会转移到其他状态。所有值的总和始终与批处理中的请求总数匹配。-
canceled: number消息批处理中已取消的请求数。
在整个消息批处理处理结束之前,此值为零。
-
errored: number消息批处理中遇到错误的请求数。
在整个消息批处理处理结束之前,此值为零。
-
expired: number消息批处理中已过期的请求数。
在整个消息批处理处理结束之前,此值为零。
-
processing: number消息批处理中正在处理的请求数。
-
succeeded: number消息批处理中已成功完成的请求数。
在整个消息批处理处理结束之前,此值为零。
-
-
results_url: string包含消息批处理请求结果的
.jsonl文件的 URL。仅在处理结束后指定。文件中的结果不保证与请求的顺序相同。使用
custom_id字段将结果与请求进行匹配。 -
type: "message_batch"对象类型。
对于消息批处理,始终为
"message_batch"。"message_batch"
-
-
first_id: stringdata列表中的第一个 ID。可用作上一页的before_id。 -
has_more: boolean指示在请求的页面方向上是否有更多结果。
-
last_id: stringdata列表中的最后一个 ID。可用作下一页的after_id。
示例
curl https://api.anthropic.com/v1/messages/batches \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY"
响应
{
"data": [
{
"id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
"archived_at": "2024-08-20T18:37:24.100435Z",
"cancel_initiated_at": "2024-08-20T18:37:24.100435Z",
"created_at": "2024-08-20T18:37:24.100435Z",
"ended_at": "2024-08-20T18:37:24.100435Z",
"expires_at": "2024-08-20T18:37:24.100435Z",
"processing_status": "in_progress",
"request_counts": {
"canceled": 10,
"errored": 30,
"expired": 10,
"processing": 100,
"succeeded": 50
},
"results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",
"type": "message_batch"
}
],
"first_id": "first_id",
"has_more": true,
"last_id": "last_id"
}