TsgcHTTP_API_OpenAI › Methods › CancelResponse
Cancels a background response that is still in progress on the OpenAI Responses API
function CancelResponse(const aResponseId: string) : TsgcOpenAIClass_Response_Response;
| Name | Type | Description |
|---|---|---|
aResponseId | const string | Unique identifier of the background response to cancel. |
Updated response object reflecting the cancelled status and any partial output accumulated so far. (TsgcOpenAIClass_Response_Response)
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.
oResponse := oAPI.CancelResponse('resp_abc123');
ShowMessage('Response is now: ' + oResponse.Status);