OpenAI Realtime API

Speak with the OpenAI Realtime model in milliseconds — bi-directional audio and text over a single WebSocket session, driven from Delphi/C++Builder.

TsgcWSAPI_OpenAI

WebSocket client for the OpenAI Realtime API — full session lifecycle, function tools, audio frame streaming and transcription events.

Component class

TsgcWSAPI_OpenAI

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Standard / Professional / Enterprise

Drop the component, set the API key, talk

Pair with TsgcWebSocketClient, set OpenAI.ApiKey and OpenAI.Model, then push audio or text and listen for response events.

uses
  sgcWebSocket, sgcWebSocket_API_OpenAI;

var
  WSClient: TsgcWebSocketClient;
  OpenAI: TsgcWSAPI_OpenAI;
begin
  WSClient := TsgcWebSocketClient.Create(nil);

  OpenAI := TsgcWSAPI_OpenAI.Create(nil);
  OpenAI.Client := WSClient;
  OpenAI.OpenAI.ApiKey := 'sk-...';
  OpenAI.OpenAI.Model  := 'gpt-realtime';

  WSClient.Active := True;

  // send a text turn
  OpenAI.ConversationCreateMessageText('Hello', 'user');
  OpenAI.ResponseCreate;
end;
// uses: sgcWebSocket, sgcWebSocket_API_OpenAI
TsgcWebSocketClient *WSClient = new TsgcWebSocketClient(this);
TsgcWSAPI_OpenAI *OpenAI = new TsgcWSAPI_OpenAI(this);
OpenAI->Client = WSClient;
OpenAI->OpenAI->ApiKey = "sk-...";
OpenAI->OpenAI->Model  = "gpt-realtime";

WSClient->Active = true;
OpenAI->ConversationCreateMessageText("Hello", "user");
OpenAI->ResponseCreate();

What's inside

Wraps the OpenAI Realtime WebSocket gateway as a typed Delphi component with session, conversation and audio helpers.

Session lifecycle

SessionUpdate applies modalities, voice, instructions, input_audio_format, output_audio_format and turn_detection settings to the active Realtime session.

Conversation items

ConversationCreateMessageText and ConversationCreateMessageAudio push user/system content; ConversationItemDelete and ConversationItemTruncate reshape the running history.

Audio streaming

InputAudioBufferAppend pushes PCM frames (base64-encoded), InputAudioBufferCommit ends a user turn. Output audio arrives as response.audio.delta events.

Function calling

Declare tools in SessionUpdate; arguments arrive as response.function_call_arguments.delta events, results go back via ConversationCreateFunctionCallOutput.

Voice activity detection

Server-side VAD (turn_detection: {type: server_vad}) automatically detects end-of-speech — the component delivers each phase as its own event.

Auth headers

The component injects the Authorization and OpenAI-Beta: realtime=v1 headers on the WebSocket handshake. Pair with TsgcWebSocketClient_WinHTTP on Windows for OS-managed TLS.

Specifications & references

Authoritative sources for the APIs this component implements.

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Online Help — API_OpenAI Full property, method and event reference for this component.
Free Trial — sgcWebSockets Download the trial package and start streaming Realtime audio and text into your Delphi applications.
Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.

Ready to Stream OpenAI Realtime?

Download the free trial and add live AI audio and text to your Delphi applications.