Anthropic | Message Batches

メッセージバッチAPIを使用すると、大量のメッセージを非同期で処理できます。これは、即時のレスポンスを必要としないタスク(バルクコンテンツ生成、データ分析、バッチ処理ワークフローなど)に最適です。

バッチの一覧表示

組織のすべてのメッセージバッチを一覧表示します。


Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'API_KEY';
WriteLn(Anthropic._ListBatches);

バッチの取得

特定のバッチに関する情報を取得します。


Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'API_KEY';
WriteLn(Anthropic._GetBatch('batch_id_here'));

バッチのキャンセル

まだ処理中のバッチをキャンセルします。


Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'API_KEY';
WriteLn(Anthropic._CancelBatch('batch_id_here'));

バッチ結果を取得する

完了したバッチの結果を取得します。


Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'API_KEY';
WriteLn(Anthropic._GetBatchResults('batch_id_here'));

型付きレスポンス

バッチデータへの構造化されたアクセスには、型付きレスポンスクラスを使用してください。


Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'API_KEY';

oBatches := Anthropic.ListBatches;
Try
  for i := 0 to Length(oBatches.Batches) - 1 do
    WriteLn(oBatches.Batches[i].Id + ' - ' + oBatches.Batches[i].ProcessingStatus);
Finally
  oBatches.Free;
End;