TsgcHTTP_API_OpenAI › Methods › SubmitToolOutputsToRun
Returns tool function outputs to a Run that is waiting in requires_action state
function SubmitToolOutputsToRun(const aThreadId, aRunId: string; const aToolOutputs: TsgcOpenAIClass_Request_FunctionResponses; aStream: Boolean = False): 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 currently awaiting tool outputs. |
aToolOutputs | const TsgcOpenAIClass_Request_FunctionResponses | Collection of tool call ids and their corresponding output strings to be returned to the Run. |
aStream | Boolean | If True, stream incremental events via OnResponseChunk while the Run resumes; otherwise wait for the updated Run object. |
The Run object with its status advanced after the tool outputs were accepted (TsgcOpenAIClass_Run)
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.
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;