TsgcHTTP_API_OpenAI › Methods › CreateAssistant
Creates a new Assistant with model, instructions, tools and metadata
function CreateAssistant(const aRequest: TsgcOpenAIClass_Request_Assistant) : TsgcOpenAIClass_Assistant;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Assistant | Assistant configuration including model, name, instructions, tools, tool resources and metadata. |
The newly created Assistant object with its assigned id and configuration (TsgcOpenAIClass_Assistant)
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.
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;