TsgcHTTP_API_OpenAIMethods › CreateAssistant

CreateAssistant Method

Creates a new Assistant with model, instructions, tools and metadata

Syntax

function CreateAssistant(const aRequest: TsgcOpenAIClass_Request_Assistant) : TsgcOpenAIClass_Assistant;

Parameters

NameTypeDescription
aRequestconst TsgcOpenAIClass_Request_AssistantAssistant configuration including model, name, instructions, tools, tool resources and metadata.

Return Value

The newly created Assistant object with its assigned id and configuration (TsgcOpenAIClass_Assistant)

Remarks

Calls POST /v1/assistants to build a reusable Assistant that can be invoked from Threads and Runs. Supply the target model plus any tools (code interpreter, file search, functions) and tool resources required by your workflow. Returns the full Assistant definition, including its generated id which must be used in subsequent Thread and Run calls.

Example

var oRequest: TsgcOpenAIClass_Request_Assistant;
begin
  oRequest := TsgcOpenAIClass_Request_Assistant.Create;
  try
    oRequest.Model := 'gpt-4o';
    oRequest.Name := 'Math Tutor';
    oRequest.Instructions := 'You are a helpful math tutor.';
    ShowMessage(oAPI.CreateAssistant(oRequest).Id);
  finally
    oRequest.Free;
  end;
end;

Back to Methods