Claude Platform Docs

Récupérer les résultats d'un lot de messages

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

Diffuse en streaming les résultats d'un lot de messages sous forme de fichier .jsonl.

Chaque ligne du fichier est un objet JSON contenant le résultat d'une requête unique du lot de messages. L'ordre des résultats n'est pas garanti identique à celui des requêtes. Utilisez le champ custom_id pour faire correspondre les résultats aux requêtes.

Pour en savoir plus sur l'API Message Batches, consultez notre guide de l'utilisateur.

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.

Récupérer les résultats d'un lot de messages
<?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);