TsgcHTTP_API_OpenAIMethods › CancelResponse

CancelResponse Method

Cancels a background response that is still in progress on the OpenAI Responses API

Syntax

function CancelResponse(const aResponseId: string) : TsgcOpenAIClass_Response_Response;

Parameters

NameTypeDescription
aResponseIdconst stringUnique identifier of the background response to cancel.

Return Value

Updated response object reflecting the cancelled status and any partial output accumulated so far. (TsgcOpenAIClass_Response_Response)

Remarks

Issues a POST to /v1/responses/{response_id}/cancel. This only succeeds on responses that were created with background=true and are still in the queued or in_progress state; already-completed or failed responses cannot be cancelled. Use it to stop long-running reasoning jobs or tool-driven agents that are no longer needed, freeing the model capacity and avoiding further token usage.

Example

oResponse := oAPI.CancelResponse('resp_abc123');
ShowMessage('Response is now: ' + oResponse.Status);

Back to Methods