TsgcHTTP_API_OpenAIMethods › CancelRun

CancelRun Method

Cancels an in-progress Run before it completes

Syntax

function CancelRun(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 cancel.

Return Value

The Run object with its updated Status, typically cancelling transitioning to cancelled (TsgcOpenAIClass_Run)

Remarks

Calls POST /v1/threads/{thread_id}/runs/{run_id}/cancel to request cancellation of a Run that is in a cancellable state (queued, in_progress or requires_action). The Run transitions to cancelling and eventually to cancelled. Poll RetrieveRun to observe the final status.

Example

var oRun: TsgcOpenAIClass_Run;
begin
  oRun := oAPI.CancelRun('thread_abc123', 'run_abc123');
  ShowMessage('Status: ' + oRun.Status);
end;

Back to Methods