Claude Platform Docs

メッセージバッチの結果を取得

$client->beta->messages->batches->results(string messageBatchID, ?list<AnthropicBeta> betas, ?string workspaceID): MessageBatchIndividualResponse
GET/v1/messages/batches/{message_batch_id}/results

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

ファイルの各行は、メッセージバッチ内の単一リクエストの結果を含むJSONオブジェクトです。結果がリクエストと同じ順序であることは保証されません。結果とリクエストを照合するにはcustom_idフィールドを使用してください。

Message Batches APIの詳細については、ユーザーガイドをご覧ください。

Parameters
messageBatchID: string

ID of the Message Batch.

betas?:optional list<AnthropicBeta>

Optional header to specify the beta version(s) you want to use.

workspaceID?:optional string
Returns
class MessageBatchIndividualResponse { $customID; $result; }
string customID

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.

メッセージバッチの結果を取得
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(apiKey: 'my-anthropic-api-key');

$betaMessageBatchIndividualResponse = $client
  ->beta
  ->messages
  ->batches
  ->resultsStream(
  'message_batch_id',
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
  workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);

var_dump($betaMessageBatchIndividualResponse);