TsgcHTTP_API_OpenAIMethods › RetrieveRun

RetrieveRun Method

Retrieves the current state of a Run, including status and usage

Syntax

function RetrieveRun(const aThreadId, aRunId: string): TsgcOpenAIClass_Run;

Parameters

NameTypeDescription
aThreadIdconst stringThe identifier of the Thread that owns the Run.
aRunIdconst stringThe identifier of the Run to retrieve (e.g. run_abc123).

Return Value

The Run object with its current status, required actions, usage statistics and timestamps (TsgcOpenAIClass_Run)

Remarks

Calls GET /v1/threads/{thread_id}/runs/{run_id}. Poll this endpoint to track Run progress until Status reaches a terminal value such as completed, failed, cancelled or expired. When Status = requires_action, inspect RequiredAction and reply via SubmitToolOutputsToRun.

Example

var oRun: TsgcOpenAIClass_Run;
begin
  repeat
    oRun := oAPI.RetrieveRun('thread_abc123', 'run_abc123');
    Sleep(500);
  until (oRun.Status = 'completed') or (oRun.Status = 'failed');
end;

Back to Methods