メッセージバッチ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;