TsgcHTTP_API_OpenAI › Methods › CreateResponse
Creates a new model response using the OpenAI Responses API
function CreateResponse(const aRequest: TsgcOpenAIClass_Request_Response) : TsgcOpenAIClass_Response_Response;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Response | Request payload containing the model, input, optional tools, reasoning options and other Responses API parameters. |
Parsed response object exposing the generated output items, final status, usage and the unique id used to retrieve or cancel it later. (TsgcOpenAIClass_Response_Response)
Issues a POST to /v1/responses, the unified endpoint introduced by OpenAI for agentic and reasoning workloads. Responses accept text, images, audio and file inputs, run built-in tools (web search, file search, code interpreter, computer use) and can be chained by supplying a PreviousResponseId. Enable aRequest.Stream to receive incremental deltas through OnHTTPAPISSE; the returned object still reflects the final aggregated state once the stream completes.
oRequest := TsgcOpenAIClass_Request_Response.Create;
try
oRequest.Model := 'gpt-5';
oRequest.Input := 'Summarize the plot of Hamlet in two sentences.';
oResponse := oAPI.CreateResponse(oRequest);
ShowMessage(oResponse.OutputText);
finally
oRequest.Free;
end;