TsgcHTTP_API_OpenAIMethods › RetrieveBatch

RetrieveBatch Method

Retrieves the current state of a Batch job by its identifier

Syntax

function RetrieveBatch(const aBatchId: string) : TsgcOpenAIClass_Response_Batch;

Parameters

NameTypeDescription
aBatchIdconst stringThe identifier of the Batch job to retrieve (e.g. batch_abc123).

Return Value

The Batch object with current status, request counts, output/error file ids and timestamps (TsgcOpenAIClass_Response_Batch)

Remarks

Calls GET /v1/batches/{batch_id}. Poll until Status reaches a terminal value such as completed, failed, expired or cancelled. On completion download the resulting JSONL via RetrieveFileContent(Batch.OutputFileId).

Example

var oBatch: TsgcOpenAIClass_Response_Batch;
begin
  oBatch := oAPI.RetrieveBatch('batch_abc123');
  ShowMessage(oBatch.Status + ' - output: ' + oBatch.OutputFileId);
end;

Back to Methods