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.
Speak with the OpenAI Realtime model in milliseconds — bi-directional audio and text over a single WebSocket session, driven from Delphi/C++Builder.
WebSocket client for the OpenAI Realtime API — full session lifecycle, function tools, audio frame streaming and transcription events.
TsgcWSAPI_OpenAI
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
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();
Wraps the OpenAI Realtime WebSocket gateway as a typed Delphi component with session, conversation and audio helpers.
SessionUpdate applies modalities, voice, instructions, input_audio_format, output_audio_format and turn_detection settings to the active Realtime session.
ConversationCreateMessageText and ConversationCreateMessageAudio push user/system content; ConversationItemDelete and ConversationItemTruncate reshape the running history.
InputAudioBufferAppend pushes PCM frames (base64-encoded), InputAudioBufferCommit ends a user turn. Output audio arrives as response.audio.delta events.
Declare tools in SessionUpdate; arguments arrive as response.function_call_arguments.delta events, results go back via ConversationCreateFunctionCallOutput.
Server-side VAD (turn_detection: {type: server_vad}) automatically detects end-of-speech — the component delivers each phase as its own event.
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.
Authoritative sources for the APIs this component implements.
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. | Open | |
| Free Trial — sgcWebSockets Download the trial package and start streaming Realtime audio and text into your Delphi applications. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |