TsgcHTTP_API_OpenAI › Methods › CancelRun
Cancels an in-progress Run before it completes
function CancelRun(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 cancel. |
The Run object with its updated Status, typically cancelling transitioning to cancelled (TsgcOpenAIClass_Run)
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.
var oRun: TsgcOpenAIClass_Run;
begin
oRun := oAPI.CancelRun('thread_abc123', 'run_abc123');
ShowMessage('Status: ' + oRun.Status);
end;