TsgcHTTP_API_OpenAIMethods › ListRuns

ListRuns Method

Lists Runs executed on a given Thread with pagination support

Syntax

function ListRuns(const aThreadId: string; const aLimit: Integer = 20; aOrder: string = ''; aAfter: string = ''; aBefore: string = '') : TsgcOpenAIClass_Response_List_Runs;

Parameters

NameTypeDescription
aThreadIdconst stringThe identifier of the Thread whose Runs should be listed.
aLimitconst IntegerMaximum number of Runs to return (1-100, defaults to 20).
aOrderstringSort order by created_at: asc or desc.
aAfterstringCursor for forward pagination; pass the last Run id from the previous page.
aBeforestringCursor for backward pagination; pass the first Run id from the previous page.

Return Value

Paginated list of Run objects together with pagination cursors (TsgcOpenAIClass_Response_List_Runs)

Remarks

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.

Example

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;

Back to Methods