Skip to content

Python: [Bug]: AzureOpenAIChatClient credentials coroutine error #3262

@TimLovellSmith

Description

@TimLovellSmith

Description

What happened? I'm trying to use AzureOpenAIChatClient with AzureCliCredential and it is not working.

I get an error message

AttributeError: 'coroutine' object has no attribute 'token'

I see also

<sys>:0: RuntimeWarning: coroutine 'AzureCliCredential.get_token' was never awaited

Does this mean there's a type error, in the form of a missing await in the implementation?

Here is a pyproject.toml that I got generated for me using uv

[project]
name = "azure-redis-conversation-py"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14"
dependencies = [
    "agent-framework>=1.0.0b260114",
    "agent-framework-redis>=1.0.0b260114",
]

Code Sample

from agent_framework.azure import AzureOpenAIChatClient
from azure.identity.aio import AzureCliCredential

    # Create Azure CLI credential provider (uses 'az login' credentials)
    azure_credential = AzureCliCredential()

    endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
    model_deployment = os.environ.get("OPENAI_CHAT_MODEL_ID")

    client = AzureOpenAIChatClient(
        endpoint=endpoint,
        deployment_name=model_deployment,
        credential=azure_credential,
    )


which is similar in spirit to the sample

AIAgent agent = new AzureOpenAIClient(
  new Uri("https://xyz.openai.azure.com/"),
  new AzureCliCredential())

Error Messages / Stack Traces

Traceback (most recent call last):
  File "c:\repo\agent_framework_explore\azure_redis_conversation.py\main.py", line 123, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "C:\Users\tilovell\AppData\Roaming\uv\python\cpython-3.14.2-windows-x86_64-none\Lib\asyncio\runners.py", line 204, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "C:\Users\tilovell\AppData\Roaming\uv\python\cpython-3.14.2-windows-x86_64-none\Lib\asyncio\runners.py", line 127, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "C:\Users\tilovell\AppData\Roaming\uv\python\cpython-3.14.2-windows-x86_64-none\Lib\asyncio\base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "c:\repo\agent_framework_explore\azure_redis_conversation.py\main.py", line 456, in main
    client = AzureOpenAIChatClient(
        endpoint=endpoint,
        deployment_name=model_deployment,
        credential=azure_credential,
    )
  File "C:\repo\agent_framework_explore\azure_redis_conversation.py\.venv\Lib\site-packages\agent_framework\azure\_chat_client.py", line 253, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        deployment_name=azure_openai_settings.chat_deployment_name,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<11 lines>...
        **kwargs,
        ^^^^^^^^^
    )
    ^
  File "C:\repo\agent_framework_explore\azure_redis_conversation.py\.venv\Lib\site-packages\agent_framework\azure\_shared.py", line 199, in __init__
    ad_token = get_entra_auth_token(credential, token_endpoint)
  File "C:\repo\agent_framework_explore\azure_redis_conversation.py\.venv\Lib\site-packages\agent_framework\azure\_entra_id_authentication.py", line 48, in get_entra_auth_token
    return auth_token.token if auth_token else None
           ^^^^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'token'
<sys>:0: RuntimeWarning: coroutine 'AzureCliCredential.get_token' was never awaited

Package Versions

agent-framework>=1.0.0b260114, agent-framework-redis>=1.0.0b260114,

Python Version

Python 3.14

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions