From sgcWebSockets 2025.5.0 the OpenAI RealTime API is supported (currently only transcription mode).
The OpenAI Realtime API enables low-latency, multimodal interactions including speech-to-speech conversational experiences and real-time transcription.
The component TsgcWSAPI_OpenAI implements the RealTime OpenAI API.Use the method property to select Conversation or Transcription, currently only Transcription mode is supported.
The InputAudio property allows to customize the following data:
OpenAI
The OpenAI API uses API keys for authentication. Visit your API Keys page to retrieve the API key you'll use in your requests.
Remember that your API key is a secret! Do not share it with others or expose it in any client-side code (browsers, apps). Production requests must be routed through your own backend server where your API key can be securely loaded from an environment variable or key management service.
This API Key must be configured in the OpenAIOptions.ApiKey property of the component. Optionally, for users who belong to multiple organizations, you can set your Organization in the property OpenAIOptions.Organization if your account belongs to an organization.
Once the API Key is configured, find below a list of available functions to interactuate with the OpenAI API.
Azure
The client supports Microsoft Azure OpenAI Services, so you can use your Azure account to interactuate with the Azure OpenAI API too. In order to configure the client to work with Azure, follow the next steps:
WSClient := TsgcWebSocketClient.Create(nil); oAudio := TsgcAudioRecorderWave.Create(nil); OpenAI := TsgcWSAPI_OpenAI.Create(nil); OpenAI.Client := WSClient; OpenAI.AudioRecorder := oAudio; OpenAI.OpenAIOptions.APIKey := 'your-api-key-here'; OpenAI.OpenAIOptions.method := sgcoaimTranscription; OpenAI.OpenAIOptions.provider := sgcoaipOpenAI; OpenAI.InputAudio.Language := 'en'; OpenAI.InputAudio.Model := 'whisper-1'; procedure OnOpenAIAudioTranscriptionCompleted(Sender: TObject; const aItem: TsgcWSOpenAIConversation_Item_Completed); begin Log('#transcription_completed: ' + aItem.Transcript); end;
Find below a Delphi Demo showing the main features of the OpenAI RealTime API
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.