Anthropic | Message Batches

The Message Batches API allows you to process large volumes of messages asynchronously. This is ideal for tasks that don't require immediate responses, such as bulk content generation, data analysis, or batch processing workflows.

List Batches

Lists all message batches for your organization.


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

Get Batch

Retrieves information about a specific batch.


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

Cancel Batch

Cancels a batch that is still processing.


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

Get Batch Results

Retrieves the results of a completed batch.


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

Typed Response

Use the typed response class for structured access to batch data.


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;