TsgcHTTP_API_OpenAIMethods › SubmitToolOutputsToRun

SubmitToolOutputsToRun Method

Returns tool function outputs to a Run that is waiting in requires_action state

Syntax

function SubmitToolOutputsToRun(const aThreadId, aRunId: string; const aToolOutputs: TsgcOpenAIClass_Request_FunctionResponses; aStream: Boolean = False): TsgcOpenAIClass_Run;

Parameters

NameTypeDescription
aThreadIdconst stringThe identifier of the Thread that owns the Run.
aRunIdconst stringThe identifier of the Run currently awaiting tool outputs.
aToolOutputsconst TsgcOpenAIClass_Request_FunctionResponsesCollection of tool call ids and their corresponding output strings to be returned to the Run.
aStreamBooleanIf True, stream incremental events via OnResponseChunk while the Run resumes; otherwise wait for the updated Run object.

Return Value

The Run object with its status advanced after the tool outputs were accepted (TsgcOpenAIClass_Run)

Remarks

Calls POST /v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs. When the Run enters requires_action, each pending function call listed in RequiredAction.SubmitToolOutputs must be answered with a matching ToolCallId and output. Once submitted the Run resumes execution; enable aStream to process deltas as they arrive.

Example

var oOutputs: TsgcOpenAIClass_Request_FunctionResponses;
begin
  oOutputs := TsgcOpenAIClass_Request_FunctionResponses.Create;
  try
    with oOutputs.Add do begin
      ToolCallId := 'call_abc123';
      Output := '{"temperature":21,"unit":"C"}';
    end;
    oAPI.SubmitToolOutputsToRun('thread_abc123', 'run_abc123', oOutputs);
  finally
    oOutputs.Free;
  end;
end;

Back to Methods