Implementation:Microsoft Agent framework AzureOpenAIResponsesClient Init
| Knowledge Sources | |
|---|---|
| Domains | AI_Infrastructure, Azure, Agent_Architecture |
| Last Updated | 2026-02-11 17:00 GMT |
Overview
Concrete tool for configuring an Azure OpenAI Responses API client with Azure AD or API key authentication, provided by the Microsoft Agent Framework.
Description
The AzureOpenAIResponsesClient initializes an authenticated connection to an Azure OpenAI deployment. It supports direct endpoint connection with API key or Azure AD credentials, as well as creation through an Azure AI Foundry project endpoint. The client extends mixin layers for middleware, function invocation, and telemetry, implementing the SupportsChatGetResponse protocol.
Usage
Import this class when deploying agents against Azure OpenAI. Provide either api_key and endpoint for key-based auth, or credential for Azure AD authentication. Use project_endpoint or project_client for Foundry-based creation requiring the azure-ai-projects package.
Code Reference
Source Location
- Repository: agent-framework
- File: python/packages/core/agent_framework/azure/_responses_client.py
- Lines: L55-245
Signature
class AzureOpenAIResponsesClient(
AzureOpenAIConfigMixin,
ChatMiddlewareLayer[AzureOpenAIResponsesOptionsT],
FunctionInvocationLayer[AzureOpenAIResponsesOptionsT],
ChatTelemetryLayer[AzureOpenAIResponsesOptionsT],
RawOpenAIResponsesClient[AzureOpenAIResponsesOptionsT],
Generic[AzureOpenAIResponsesOptionsT],
):
def __init__(
self,
*,
api_key: str | None = None,
deployment_name: str | None = None,
endpoint: str | None = None,
base_url: str | None = None,
api_version: str | None = None,
ad_token: str | None = None,
ad_token_provider: AsyncAzureADTokenProvider | None = None,
token_endpoint: str | None = None,
credential: TokenCredential | None = None,
default_headers: Mapping[str, str] | None = None,
async_client: AsyncOpenAI | None = None,
project_client: Any | None = None,
project_endpoint: str | None = None,
env_file_path: str | None = None,
env_file_encoding: str | None = None,
instruction_role: str | None = None,
middleware: Sequence[MiddlewareTypes] | None = None,
function_invocation_configuration: FunctionInvocationConfiguration | None = None,
**kwargs: Any,
) -> None:
Import
from agent_framework.azure import AzureOpenAIResponsesClient
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| api_key | str | No | Azure OpenAI API key. Also via env var AZURE_OPENAI_API_KEY. |
| deployment_name | str | No | Azure deployment name. Also via env var AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME. |
| endpoint | str | No | Azure OpenAI endpoint URL. Also via env var AZURE_OPENAI_ENDPOINT. |
| base_url | str | No | Full base URL (must end with /openai/v1/). |
| api_version | str | No | API version (must be "preview"). Also via env var AZURE_OPENAI_API_VERSION. |
| credential | TokenCredential | No | Azure credential for Azure AD authentication. |
| project_client | AIProjectClient | No | Pre-configured Foundry project client. |
| project_endpoint | str | No | Azure AI Foundry project endpoint URL. |
| middleware | Sequence | No | Middleware pipeline for request/response interception. |
Outputs
| Name | Type | Description |
|---|---|---|
| instance | AzureOpenAIResponsesClient | Configured client implementing SupportsChatGetResponse protocol. |
Usage Examples
With Azure CLI Credential
from agent_framework.azure import AzureOpenAIResponsesClient
from azure.identity import AzureCliCredential
client = AzureOpenAIResponsesClient(
credential=AzureCliCredential(),
)
With API Key
from agent_framework.azure import AzureOpenAIResponsesClient
client = AzureOpenAIResponsesClient(
api_key="your-api-key",
endpoint="https://your-resource.openai.azure.com/",
deployment_name="gpt-4o",
)
With Foundry Project Endpoint
from agent_framework.azure import AzureOpenAIResponsesClient
from azure.identity import DefaultAzureCredential
client = AzureOpenAIResponsesClient(
project_endpoint="https://your-project.services.ai.azure.com/api/projects/your-project",
credential=DefaultAzureCredential(),
)