TsgcHTTP_API_OpenAI › Methods › CreateRun
Starts a new Run of an Assistant against an existing Thread
function CreateRun(const aThreadId: string; const aRun: TsgcOpenAIClass_Request_Run): TsgcOpenAIClass_Run;
| Name | Type | Description |
|---|---|---|
aThreadId | const string | The identifier of the Thread to execute. |
aRun | const TsgcOpenAIClass_Request_Run | Run configuration: target Assistant id, optional model/instructions overrides, tools, tool choice, streaming and truncation options. |
The newly created Run object including its id and initial status (usually queued) (TsgcOpenAIClass_Run)
Calls POST /v1/threads/{thread_id}/runs to execute the target Assistant against the Thread. The Run progresses through states such as queued, in_progress, requires_action and completed; poll RetrieveRun or use streaming to observe progress. When status is requires_action, call SubmitToolOutputsToRun with the function results.
var oRequest: TsgcOpenAIClass_Request_Run;
oRun: TsgcOpenAIClass_Run;
begin
oRequest := TsgcOpenAIClass_Request_Run.Create;
try
oRequest.AssistantId := 'asst_abc123';
oRun := oAPI.CreateRun('thread_abc123', oRequest);
ShowMessage('Run ' + oRun.Id + ' - ' + oRun.Status);
finally
oRequest.Free;
end;
end;