TsgcHTTP_API_OpenAI › Methods › ListRuns
Lists Runs executed on a given Thread with pagination support
function ListRuns(const aThreadId: string; const aLimit: Integer = 20; aOrder: string = ''; aAfter: string = ''; aBefore: string = '') : TsgcOpenAIClass_Response_List_Runs;
| Name | Type | Description |
|---|---|---|
aThreadId | const string | The identifier of the Thread whose Runs should be listed. |
aLimit | const Integer | Maximum number of Runs to return (1-100, defaults to 20). |
aOrder | string | Sort order by created_at: asc or desc. |
aAfter | string | Cursor for forward pagination; pass the last Run id from the previous page. |
aBefore | string | Cursor for backward pagination; pass the first Run id from the previous page. |
Paginated list of Run objects together with pagination cursors (TsgcOpenAIClass_Response_List_Runs)
Calls GET /v1/threads/{thread_id}/runs to return all Runs executed on the specified Thread, newest first by default. Each entry exposes the Assistant id, status, usage and timing information needed to monitor or audit execution.
var oList: TsgcOpenAIClass_Response_List_Runs;
i: Integer;
begin
oList := oAPI.ListRuns('thread_abc123', 20, 'desc');
for i := 0 to oList.Data.Count - 1 do
Memo1.Lines.Add(oList.Data[i].Id + ' - ' + oList.Data[i].Status);
end;