TsgcHTTP_API_OpenAI › Methods › RetrieveRun
Retrieves the current state of a Run, including status and usage
function RetrieveRun(const aThreadId, aRunId: string): TsgcOpenAIClass_Run;
| Name | Type | Description |
|---|---|---|
aThreadId | const string | The identifier of the Thread that owns the Run. |
aRunId | const string | The identifier of the Run to retrieve (e.g. run_abc123). |
The Run object with its current status, required actions, usage statistics and timestamps (TsgcOpenAIClass_Run)
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.
var oRun: TsgcOpenAIClass_Run;
begin
repeat
oRun := oAPI.RetrieveRun('thread_abc123', 'run_abc123');
Sleep(500);
until (oRun.Status = 'completed') or (oRun.Status = 'failed');
end;