Registry /
azure / azure-communication-chat
Install & Compatibility
Where this runs
tested against v1.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.446s · 24.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.4s · import 0.408s · 25MB
23MB installed
● package 23MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ChatClient
✓ from azure.communication.chat import ChatClient
CommunicationTokenCredential
✓ from azure.communication.chat import CommunicationTokenCredential
✗ from azure.core.credentials import AccessToken
AccessToken is used internally, but the correct class for chat is CommunicationTokenCredential
Creates a chat thread with two participants using an endpoint and user access token.
import os
from azure.communication.chat import ChatClient, CommunicationTokenCredential
endpoint = os.environ.get("COMMUNICATION_SERVICES_ENDPOINT", "")
user_access_token = os.environ.get("USER_ACCESS_TOKEN", "")
credential = CommunicationTokenCredential(user_access_token)
chat_client = ChatClient(endpoint, credential)
# Create a chat thread
from azure.communication.chat import CreateChatThreadRequest
create_chat_thread_request = CreateChatThreadRequest(
topic="Hello World!",
members=[
{"user": "8:acs:...", "display_name": "User1"},
{"user": "8:acs:...", "display_name": "User2"}
]
)
result = chat_client.create_chat_thread(create_chat_thread_request)
print(f"Chat thread created with ID: {result.chat_thread.id}")
Errors
Common errors & fixes
AttributeError: module 'azure.communication.chat' has no attribute 'ChatThreadClient'
In older versions (pre-1.1.0), ChatThreadClient was accessed differently. In 1.2.0+, ChatThreadClient is obtained via ChatClient.get_chat_thread_client().
fixUse chat_client.get_chat_thread_client(thread_id) to obtain a ChatThreadClient instance.
TypeError: Object of type 'list' is not JSON serializable
Passing a plain Python list for 'members' in CreateChatThreadRequest instead of a list of ChatParticipant objects.
fixCreate ChatParticipant objects: from azure.communication.chat import ChatParticipant; members = [ChatParticipant(user=..., display_name=...)]
HttpRequestError: (InvalidURL) Invalid URL
The endpoint URL is missing a trailing slash or is incorrectly formatted.
fixEnsure the endpoint ends with '/', e.g., 'https://myresource.communication.azure.com/'.
Upgrade
Version history
1.3.0latest on PyPI · released Apr 11, 2024
Audit
Dependencies
azure-corerequiredCore Azure SDK dependency for HTTP pipeline, authentication, and logging
azure-communication-identityrequiredRequired for creating and managing user access tokens for chat