Skip to content

Python: Bug: AzureRealtimeWebsocket can not read api_key #11134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
r4hulp opened this issue Mar 23, 2025 · 1 comment
Closed

Python: Bug: AzureRealtimeWebsocket can not read api_key #11134

r4hulp opened this issue Mar 23, 2025 · 1 comment
Labels
bug Something isn't working python Pull requests for the Python Semantic Kernel triage

Comments

@r4hulp
Copy link

r4hulp commented Mar 23, 2025

I am trying out Realtime Websocket for OpenAI's realtime API. I followed the exact steps provided in the sample.

But I get the folllowing error on this code realtime_client = AzureRealtimeWebsocket(settings=settings) -

rahul@Mac sk-openai-realtime % uv run main.py
checking audio devices
Instructions: Start speaking. The model will detect when you stop and automatically start responding. Press ctrl + c to stop the program.
creating realtime client
creating with these configurations:
REDACTED
2024-10-01-preview
gpt-4o-realtime-preview-2
https://ai-REDACTED.openai.azure.com/openai/realtime?api-version=2024-10-01-preview&deployment=gpt-4o-realtime-preview
https://ai-REDACTED.openai.azure.com/openai/realtime?api-version=2024-10-01-preview&deployment=gpt-4o-realtime-preview-2
WARNING:azure.identity._credentials.chained:DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
        EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.
        AzureCliCredential: Azure CLI not found on path
        AzurePowerShellCredential: PowerShell is not installed
        AzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://aka.ms/azure-dev for installation instructions and then,once installed, authenticate to your Azure account using 'azd auth login'.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/t
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
ERROR:semantic_kernel.utils.authentication.entra_id_authentication:Failed to retrieve Azure token for the specified endpoint: `https://REDACTED`.
ERROR:semantic_kernel.utils.authentication.entra_id_authentication:Failed to retrieve Azure token for the specified endpoint: `https://cognitiveservices.azure.com/.default`.
Traceback (most recent call last):
  File "/Users/rahul/Developer/Cursor Projects/sk-openai-realtime/main.py", line 109, in <module>
    asyncio.run(main())
  File "/Users/rahul/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/rahul/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rahul/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
  File "/Users/rahul/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/rahul/Developer/Cursor Projects/sk-openai-realtime/main.py", line 73, in main
    realtime_client = AzureRealtimeWebsocket(settings=settings, 
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rahul/Developer/Cursor Projects/sk-openai-realtime/.venv/lib/python3.11/site-packages/semantic_kernel/connectors/ai/open_ai/s
  File "/Users/rahul/Developer/Cursor Projects/sk-openai-realtime/.venv/lib/python3.11/site-packages/semantic_kernel/connectors/ai/open_ai/services/azure_realtime.py", line 105, in __init__
    super().__init__(
  File "/Users/rahul/Developer/Cursor Projects/sk-openai-realtime/.venv/lib/python3.11/site-packages/pydantic/_internal/_validate_call.py", 
  File "/Users/rahul/Developer/Cursor Projects/sk-openai-realtime/.venv/lib/python3.11/site-packages/pydantic/_internal/_validate_call.py", line 38, in wrapper_function
    return wrapper(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^

My environment file .env contains all the configurations. However, to confirm I explicitely provided those values as parameters like below -

print(f"""creating with these configurations:
{os.getenv("AZURE_OPENAI_API_KEY")}
{os.getenv("AZURE_OPENAI_API_VERSION")}
{os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME")}
{os.getenv("AZURE_OPENAI_ENDPOINT")}""")

    realtime_client = AzureRealtimeWebsocket(settings=settings, 
                                             api_key=os.getenv("AZURE_OPENAI_API_KEY"),
                                             api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
                                             deployment_name=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
                                               endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"))

But I still get the same error. Is this a bug in the package?

@r4hulp r4hulp added the bug Something isn't working label Mar 23, 2025
@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel triage labels Mar 23, 2025
@github-actions github-actions bot changed the title Bug: AzureRealtimeWebsocket can not read api_key Python: Bug: AzureRealtimeWebsocket can not read api_key Mar 23, 2025
@moonbox3
Copy link
Contributor

Hi @r4hulp, thanks for filing. This bug was fixed in #11056. It will be included in the next release (in a day or so).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests for the Python Semantic Kernel triage
Projects
None yet
Development

No branches or pull requests

3 participants