Install & Compatibility
Where this runs
tested against v1.0.0b9 · 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.000s · 44MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.8s · import 0.000s · 44MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AzureAIInferenceClient
✓ from azure.ai.inference import AzureAIInferenceClient
ChatCompletionsOptions
✓ from azure.ai.inference.models import ChatCompletionsOptions
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
This quickstart demonstrates how to initialize the `AzureAIInferenceClient`, authenticate using `DefaultAzureCredential`, and perform a basic chat completion request. Ensure your `AZURE_AI_INFERENCE_ENDPOINT` environment variable is set and you are logged into Azure CLI or have appropriate service principal environment variables configured.
import os
from azure.ai.inference import AzureAIInferenceClient
from azure.ai.inference.models import ChatCompletionsOptions
from azure.identity import DefaultAzureCredential
# Set your Azure AI Inference service endpoint as an environment variable:
# export AZURE_AI_INFERENCE_ENDPOINT="https://<your-service-name>.inference.ai.azure.com/"
endpoint = os.environ.get("AZURE_AI_INFERENCE_ENDPOINT", "")
if not endpoint:
raise ValueError("Please set the AZURE_AI_INFERENCE_ENDPOINT environment variable.")
# Authenticate using DefaultAzureCredential (checks environment variables, Azure CLI, etc.)
credential = DefaultAzureCredential()
try:
# Initialize the client
client = AzureAIInferenceClient(endpoint=endpoint, credential=credential)
# Example: Chat Completion
messages = [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "What is the capital of France?"},
]
chat_options = ChatCompletionsOptions(
messages=messages,
model="gpt-35-turbo", # Replace with your deployed model name
max_tokens=128
)
print(f"Sending chat completion request to model: {chat_options.model}...")
response = client.chat.completions(chat_options)
for choice in response.choices:
print(f"Assistant: {choice.message.content}")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure AZURE_AI_INFERENCE_ENDPOINT is set and you are authenticated to Azure (e.g., via `az login`).")
Upgrade
Version history
1.0.0b9latest on PyPI · released Feb 15, 2025
Audit
Dependencies
No dependency data recorded yet.