TsgcHTTP_API_OpenAI › Methods › RetrieveBatch
Retrieves the current state of a Batch job by its identifier
function RetrieveBatch(const aBatchId: string) : TsgcOpenAIClass_Response_Batch;
| Name | Type | Description |
|---|---|---|
aBatchId | const string | The identifier of the Batch job to retrieve (e.g. batch_abc123). |
The Batch object with current status, request counts, output/error file ids and timestamps (TsgcOpenAIClass_Response_Batch)
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).
var oBatch: TsgcOpenAIClass_Response_Batch;
begin
oBatch := oAPI.RetrieveBatch('batch_abc123');
ShowMessage(oBatch.Status + ' - output: ' + oBatch.OutputFileId);
end;