OpenAI GPT-4, DALL-E, Whisper
Integrate OpenAI GPT-4, DALL-E, and Whisper APIs into Delphi applications. Chat completions, image generation, and speech-to-text.
Integrate OpenAI GPT-4, DALL-E, and Whisper APIs into Delphi applications. Chat completions, image generation, and speech-to-text.
OpenAI REST client — Chat Completions, Responses, Images, Audio (TTS / Whisper), Embeddings, Files, Fine-tuning, Moderation, Assistants and Threads.
TsgcHTTP_API_OpenAI
OpenAI REST API over HTTPS
Windows, macOS, Linux, iOS, Android
Enterprise (AI add-on)
Set the ApiKey in OpenAIOptions, then call typed Create*() methods or one-liner helpers like _CreateChatCompletion.
uses
sgcHTTP_API_OpenAI;
var
OpenAI: TsgcHTTP_API_OpenAI;
begin
OpenAI := TsgcHTTP_API_OpenAI.Create(nil);
OpenAI.OpenAIOptions.ApiKey := 'sk-...';
// One-shot chat completion (returns the raw JSON body)
Memo1.Lines.Text := OpenAI._CreateChatCompletion(
'gpt-4o-mini', 'Hello, world.');
// Other one-liners ship out of the box:
OpenAI._CreateEmbeddings('text-embedding-3-small', 'sgcWebSockets rocks');
OpenAI._CreateImage('a delphi-blue rubber duck');
OpenAI._CreateModeration('be nice');
// Streaming: build a typed Request, set Stream := True, hook OnHTTPAPISSE
OpenAI.OnHTTPAPISSE := HandleSSE;
end;
procedure TForm1.HandleSSE(Sender: TObject;
const aEvent, aData: string;
var Cancel: Boolean);
begin
Memo1.Lines.Add(aData);
end;
using esegece.sgcWebSockets;
var openai = new TsgcHTTPAPI_OpenAI();
openai.OpenAIOptions.ApiKey = "sk-...";
// One-shot chat completion (raw JSON body)
Console.WriteLine(openai._CreateChatCompletion("gpt-4o-mini", "Hello, world."));
// Streamed responses surface through OnHTTPAPISSE
openai.OnHTTPAPISSE += (s, ev, data, c) => Console.Write(data);
5 published properties, 78 methods, 2 events — pulled from the component reference.
Published properties: CircuitBreaker.
Published properties: ReadTimeout, TLSOptions.
Published properties: OpenAIOptions.
Published properties: Version.
Methods: CreateChatCompletion, CreateCompletion, CreateEdit.
Methods: CreateResponse, RetrieveResponse, DeleteResponse.
Authoritative sources for the protocols this component implements.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — OpenAI Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\AI\OpenAI Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi, C++ Builder and .NET and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |