The sgcAI OpenAI component enables Delphi teams to ship smart, revenue-ready experiences that blend natural language understanding, code generation, and conversation flows into existing VCL and FMX products. With a single drop-in component, SaaS vendors can offer AI-driven assistants, automated documentation, or multilingual chat without rebuilding their infrastructure.

Why the OpenAI Component Accelerates Commercial Projects

  • Faster go-to-market: ready-made REST, WebSocket, and streaming support reduces integration time from weeks to hours.
  • Enterprise-grade security: TLS 1.3, HTTP/2, and proxy compatibility protect customer data across regulated deployments.
  • Scalable monetization: multi-tenant token management and rate limiting let ISVs resell AI features as premium add-ons.
  • Cross-platform reach: the same component works across Windows, macOS, Linux, iOS, and Android targets built with Delphi.

Preparing the OpenAI Component in Delphi

  1. Install the latest sgcWebSockets package and ensure the sgcAI_OpenAI unit is available in your project.
  2. Create an OpenAI API key in the OpenAI dashboard and store it securely (environment variable, encrypted INI, or secrets vault).
  3. Add sgcAI.OpenAI to the uses clause of your form or data module.

Configuration Example (VCL Form)

The snippet below configures a TsgcOpenAI component at runtime. Drop a TButton, TMemo, and TListBox on the form to visualize the conversation. 

uses
  System.SysUtils, sgcAI_OpenAI;

procedure TFormMain.FormCreate(Sender: TObject);
begin
  OpenAI := TsgcOpenAI.Create(Self);
  OpenAI.APIKey := GetEnvironmentVariable('OPENAI_API_KEY');
  OpenAI.DefaultModel := 'gpt-4o-mini';
  OpenAI.HTTP.Proxy.Host := 'proxy.company.local';
  OpenAI.HTTP.Proxy.Port := 8080;
  OpenAI.HTTP.Timeout := 15000;
  OpenAI.Streaming := True;
end;

procedure TFormMain.ButtonAskClick(Sender: TObject);
var
  LRequest: TsgcOpenAIChatRequest;
  LResponse: TsgcOpenAIChatResponse;
begin
  LRequest := TsgcOpenAIChatRequest.Create;
  try
    LRequest.Messages.Add('system', 'Answer as a senior support engineer.');
    LRequest.Messages.Add('user', MemoPrompt.Lines.Text);
    LResponse := OpenAI.Chat.Create(LRequest);
    try
      ListBoxHistory.Items.Add(LResponse.Choices[0].Message.Content);
    finally
      LResponse.Free;
    end;
  finally
    LRequest.Free;
  end;
end; 

Increase your Opportunities

Delphi vendors can unlock new revenue streams by packaging AI copilots, knowledge search, and audio transcription as subscription tiers. With built-in analytics events and token accounting, it is straightforward to measure engagement, justify upsells, and build personalized customer success workflows.