Example: OpenAI Realtime on Azure
Example: OpenAI Realtime on Azure
Use the VoxEngine OpenAI Realtime client with an Azure OpenAI Realtime deployment.
For the complete documentation index, see llms.txt.
Overview
This example answers an inbound call and bridges call audio to an Azure OpenAI Realtime deployment using OpenAI.createRealtimeAPIClient().
Use this pattern when you have an Azure OpenAI Realtime model deployment and want VoxEngine call control, recording, media bridging, and OpenAI-compatible Realtime session handling in the same scenario.
⬇️ Jump to the Full VoxEngine scenario.
Prerequisites
- An Azure subscription with access to Azure OpenAI in Microsoft Foundry Models.
- A Microsoft Foundry or Azure OpenAI resource in a region that supports GPT Realtime models. Check Microsoft’s Realtime audio model and region documentation before creating the deployment.
- Quota for the selected Realtime model and deployment type. Azure OpenAI quota is region-specific, so confirm the requested model has available quota in the target region. See Azure OpenAI quotas and limits.
- An Azure OpenAI Realtime model deployment, for example
gpt-realtime-1.5. Themodelvalue in this VoxEngine scenario must match the Azure deployment name. - The Azure OpenAI resource endpoint from Foundry. The current Azure v1 API format uses
/openai/v1in the endpoint URL. See Azure OpenAI v1 API. - Store the Azure OpenAI API key in Voximplant Secrets under
AZURE_API_KEY. - Store the Azure OpenAI endpoint in Voximplant Secrets under
AZURE_OPENAI_BASE_URL. - Create a Voximplant routing rule that points your test destination to this scenario.
Azure setup checklist
- Create or select a Microsoft Foundry project with an Azure OpenAI resource.
- Confirm the target region supports your Realtime model and has quota.
- Deploy a GPT Realtime model from the Foundry Build area. For
gpt-realtime-1.5, use the deployed model name as theAZURE_OPENAI_MODELvalue in the scenario. - Open the deployment details and copy both the API key and Azure OpenAI endpoint.
- Add the API key to Voximplant Secrets as
AZURE_API_KEY. - Add the Azure OpenAI endpoint to Voximplant Secrets as
AZURE_OPENAI_BASE_URL. - Keep the
AZURE_OPENAI_MODELscenario constant set to the Azure deployment name, not just the model family name unless you used the same value for the deployment name. - Test the deployment in the Foundry Audio playground before routing live calls through Voximplant.
Microsoft’s Azure OpenAI v1 documentation shows endpoint values like
https://your-resource.openai.azure.com/openai/v1/.
VoxEngine accepts the same endpoint with or without the openai/v1 path.
Both of these are valid for baseUrl:
https://your-resource.openai.azure.com/openai/v1/https://your-resource.openai.azure.com/
Architecture
How it works
- The scenario reads
AZURE_API_KEYandAZURE_OPENAI_BASE_URLfrom Voximplant Secrets. baseUrlpoints the OpenAI Realtime client at the Azure OpenAI resource.modeluses the Azure deployment name.VoxEngine.sendMediaBetween(call, voiceAIClient)bridges call audio to the Realtime client after the session is updated.responseCreate(...)afterSessionUpdatedcreates the audible greeting for the caller.- The barge-in handler clears the media buffer when the caller starts speaking.
Usage highlights
- Create the Realtime client with
OpenAI.createRealtimeAPIClient(...). - Set
baseUrlfromAZURE_OPENAI_BASE_URLto route the VoxEngine OpenAI module to Azure instead of OpenAI’s default endpoint. - Set
modelto the Azure deployment name. - Use
sessionUpdate(...)to configure Realtime instructions, voice, output modalities, and turn detection. - Bridge audio with
VoxEngine.sendMediaBetween(call, voiceAIClient). - Handle barge-in with
InputAudioBufferSpeechStartedandclearMediaBuffer().
Full VoxEngine scenario
voxeengine-byollm-azure-openai-rt.js
More info
- VoxEngine OpenAI module API: https://voximplant.com/docs/references/voxengine/openai
- Realtime client parameters: /api-reference/voxengine/openai#createrealtimeapiclient
- Voximplant Secrets: /platform/voxengine/secrets
- Voximplant routing rules: /platform/voxengine/routing-rules
- Azure OpenAI Realtime audio: https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/realtime-audio
- Azure OpenAI v1 API: https://learn.microsoft.com/en-us/azure/foundry/openai/api-version-lifecycle
- Azure OpenAI quotas and limits: https://learn.microsoft.com/en-us/azure/foundry/openai/quotas-limits