TsgcHTTP_API_AnthropicMethods › CancelBatch

CancelBatch Method

Cancels an in-progress Message Batch on the Anthropic API

Syntax

function CancelBatch(const aBatchId: string) : TsgcAnthropicClass_Response_Batch;

Parameters

NameTypeDescription
aBatchIdconst stringIdentifier of the batch to cancel, typically starting with msgbatch_.

Return Value

Updated batch descriptor with its new ProcessingStatus set to canceling or ended (TsgcAnthropicClass_Response_Batch)

Remarks

Sends a POST /v1/messages/batches/{id}/cancel request to the Anthropic API. Requests that have already begun processing inside the batch will still be billed; unprocessed requests will be aborted. The anthropic-version header from AnthropicOptions is included automatically. The returned object must be freed by the caller.

Example

oResponse := oAPI.CancelBatch('msgbatch_01AbCdEf');
try
  ShowMessage('new status: ' + oResponse.ProcessingStatus);
finally
  oResponse.Free;
end;

Back to Methods