An Azure service that integrates speech processing into apps and services.
Hello @Prasanna Sai Kommineni
Thank you for reaching out to Microsoft Q&A.
Your concern about the authentication token being visible in the browser is valid. The recommended approach depends on whether you are using Voice Live directly or integrating it with Microsoft Foundry Agent Service.
Authentication for Voice Live
Microsoft recommends Microsoft Entra ID authentication for Voice Live rather than exposing an API key. For Microsoft Foundry resources, the token should be requested with the https://ai.azure.com/.default scope. The legacy https://cognitiveservices.azure.com/.default scope is also supported.
For a browser WebSocket connection, the standard browser WebSocket API cannot set the Authorization header during the WebSocket handshake. Voice Live therefore supports passing the Entra bearer token as an Authorization query-string parameter for browser scenarios. Microsoft documents that query-string parameters are encrypted when transmitted over wss://.
However, this does not mean the token is hidden from the browser. If the browser receives the token, the user can potentially see it through browser developer tools. Therefore, if your security requirement is that the browser should never have access to a service credential, a backend-brokered/proxy architecture is the preferred approach.
If you are using Foundry Agent Service
For the current Voice Live Agent Service integration, Microsoft explicitly states that agent mode does not support key-based authentication. Microsoft Entra ID is required for agent invocation. The documented samples use credentials such as DefaultAzureCredential/AzureCliCredential on the application side.
Therefore, an architecture such as the following is recommended when you want to keep credentials server-side:
Browser --> Your backend --> Microsoft Entra ID --> Voice Live / Foundry Agent Service
Your backend can authenticate using a managed identity or another appropriate Entra credential, while the browser communicates with your application rather than holding a long-lived Azure service credential.
About the 24-hour token
The token obtained for https://cognitiveservices.azure.com/.default is an Microsoft Entra access token; it should not be treated as a Voice Live API key. Its lifetime is controlled by Microsoft Entra ID and applicable token policies.
If the browser receives an access token, it should be treated as sensitive and kept only for the required session. Do not store Azure API keys or long-lived service credentials in browser code or persistent client-side storage.
Recommended options
1. Direct browser WebSocket
Use Microsoft Entra ID and pass the bearer token through the documented Voice Live browser WebSocket authentication mechanism.
This is supported, but the token is necessarily available to the browser.
2. Backend broker/proxy - preferred when token exposure is unacceptable
Keep the Azure credential on your backend and have the backend establish/broker the Voice Live connection. This prevents the browser from receiving the Azure service credential.
3. WebRTC
For browser-based real-time scenarios, WebRTC can also be considered. Microsoft documents browser-oriented real-time architectures where the server can procure session credentials and the browser receives only the credential/session information necessary for the connection.
Since you also mentioned that the Python SDK does not provide the avatar experience you need, you don't necessarily need to abandon the browser Voice Live approach. Voice Live itself supports avatar-related WebSocket events, including session.avatar.connect, so the browser-based Voice Live API can be used for scenarios requiring avatar functionality.
Using an Entra ID token directly in the browser is supported by the Voice Live API, but the token will be visible to the browser because the browser is using it. If your requirement is specifically "the browser must never see the Azure credential", use a backend-brokered architecture instead of exposing the token to JavaScript.
Please refer this Microsoft documentation:
- How to use the Voice Live API
- Voice Live API Reference
- Voice Agent with Foundry Agent Service
- Use GPT Realtime API via WebRTC
- Speech features in Microsoft Foundry (new): https://learn.microsoft.com/azure/ai-services/speech-service/speech-features-foundry?wt.mc_id=knowledgesearch_inproduct_azure-cxp-community-insider
- What is Azure Speech?: https://learn.microsoft.com/azure/ai-services/speech-service/overview?wt.mc_id=knowledgesearch_inproduct_azure-cxp-community-insider
I Hope this helps. Do let me know if you have any further queries.
If this answers your query, please do click Accept Answer and Yes for was this answer helpful.
Thank you!