列出消息批处理
get /v1/messages/batches
列出工作区中的所有消息批处理。最近创建的批处理排在前面。
在我们的用户指南中了解更多关于消息批处理 API 的信息
查询参数
-
after_id: optional string用作分页游标的对象 ID。提供时,返回此对象之后的结果页。
-
before_id: optional string用作分页游标的对象 ID。提供时,返回此对象之前的结果页。
-
limit: optional number每页返回的项目数。
默认为
20。范围从1到1000。
请求头参数
-
"anthropic-beta": optional array of AnthropicBeta可选的请求头,用于指定您要使用的 beta 版本。
-
string -
"message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 22 more-
"message-batches-2024-09-24" -
"prompt-caching-2024-07-31" -
"computer-use-2024-10-22" -
"computer-use-2025-01-24" -
"pdfs-2024-09-25" -
"token-counting-2024-11-01" -
"token-efficient-tools-2025-02-19" -
"output-128k-2025-02-19" -
"files-api-2025-04-14" -
"mcp-client-2025-04-04" -
"mcp-client-2025-11-20" -
"dev-full-thinking-2025-05-14" -
"interleaved-thinking-2025-05-14" -
"code-execution-2025-05-22" -
"extended-cache-ttl-2025-04-11" -
"context-1m-2025-08-07" -
"context-management-2025-06-27" -
"model-context-window-exceeded-2025-08-26" -
"skills-2025-10-02" -
"fast-mode-2026-02-01" -
"output-300k-2026-03-24" -
"user-profiles-2026-03-24" -
"advisor-tool-2026-03-01" -
"managed-agents-2026-04-01" -
"cache-diagnosis-2026-04-07"
-
-
返回
-
data: array of BetaMessageBatch-
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: BetaMessageBatchRequestCounts按状态分类统计消息批处理中的请求。
请求从
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 'anthropic-beta: message-batches-2024-09-24' \
-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"
}