Claude Platform Docs

バッチ

メッセージバッチを作成
client.Messages.Batches.New(ctx, params) (*MessageBatch, error)
POST/v1/messages/batches

メッセージ作成リクエストのバッチを送信します。

メッセージバッチを取得
client.Messages.Batches.Get(ctx, messageBatchID, query) (*MessageBatch, error)
GET/v1/messages/batches/{message_batch_id}

このエンドポイントはべき等であり、メッセージバッチの完了をポーリングするために使用できます。メッセージバッチの結果にアクセスするには、レスポンス内のresults_urlフィールドに対してリクエストを行ってください。

メッセージバッチの一覧
client.Messages.Batches.List(ctx, params) (*Page[MessageBatch], error)
GET/v1/messages/batches

ワークスペース内のすべてのメッセージバッチを一覧表示します。最も新しく作成されたバッチが最初に返されます。

メッセージバッチをキャンセル
client.Messages.Batches.Cancel(ctx, messageBatchID, body) (*MessageBatch, error)
POST/v1/messages/batches/{message_batch_id}/cancel

バッチは処理が終了する前であればいつでもキャンセルできます。キャンセルが開始されると、バッチはcanceling状態になり、この間にシステムはキャンセルを確定する前に、進行中の中断不可能なリクエストを完了させる場合があります。

メッセージバッチを削除
client.Messages.Batches.Delete(ctx, messageBatchID, body) (*DeletedMessageBatch, error)
DELETE/v1/messages/batches/{message_batch_id}

メッセージバッチを削除します。

メッセージバッチの結果を取得
client.Messages.Batches.ResultsStreaming(ctx, messageBatchID, query) *jsonl.Stream[MessageBatchIndividualResponse]
GET/v1/messages/batches/{message_batch_id}/results

メッセージバッチの結果を.jsonlファイルとしてストリーミングします。

Models
type DeletedMessageBatch struct { Type: "message_batch_deleted"; ID }
Type MessageBatchDeleted

Deleted object type.

For Message Batches, this is always "message_batch_deleted".

defaultmessage_batch_deleted
ID string

ID of the Message Batch.

type MessageBatch struct { Type: "message_batch"; ID; ArchivedAt; /* 7 more */ }
type MessageBatchCanceledResult struct { Type: "canceled" }
Type Canceled
defaultcanceled
type MessageBatchErroredResult struct { Type: "errored"; Error }
Type Errored
defaulterrored
Error ErrorResponse
Type Error
defaulterror
One of the following:
RequestID string
type MessageBatchExpiredResult struct { Type: "expired" }
Type Expired
defaultexpired
type MessageBatchIndividualResponse struct { CustomID; Result }

This is a single line in the response .jsonl file and does not represent the response as a whole.

CustomID string

Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.

Must be unique for each request within the Message Batch.

Processing result for this request.

Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

One of the following:
type MessageBatchRequestCounts struct { Canceled; Errored; Expired; /* 2 more */ }
Canceled int64

Number of requests in the Message Batch that have been canceled.

This is zero until processing of the entire Message Batch has ended.

default0
Errored int64

Number of requests in the Message Batch that encountered an error.

This is zero until processing of the entire Message Batch has ended.

default0
Expired int64

Number of requests in the Message Batch that have expired.

This is zero until processing of the entire Message Batch has ended.

default0
Processing int64

Number of requests in the Message Batch that are processing.

default0
Succeeded int64

Number of requests in the Message Batch that have completed successfully.

This is zero until processing of the entire Message Batch has ended.

default0
type MessageBatchResultUnion interface{…}

Processing result for this request.

Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

One of the following:
type MessageBatchSucceededResult struct { Type: "succeeded"; Message }
Type Succeeded
defaultsucceeded
Message Message