microsoft/autogen · error · ValueError

endpoint is required for AzureAIChatCompletionClient

Error message

endpoint is required for AzureAIChatCompletionClient

What it means

Raised by AzureAIChatCompletionClient._validate_config (called from __init__, which only accepts keyword arguments) when the kwargs dict has no 'endpoint' key. The Azure AI Foundry / GitHub Models inference SDK's ChatCompletionsClient requires an endpoint URL, so the AutoGen wrapper fails fast at construction instead of at first request.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py:302

        if __name__ == "__main__":
            asyncio.run(main())


    """

    def __init__(self, **kwargs: Unpack[AzureAIChatCompletionClientConfig]):
        config = self._validate_config(kwargs)  # type: ignore
        self._model_info = config["model_info"]  # type: ignore
        self._client = self._create_client(config)
        self._create_args = self._prepare_create_args(config)

        self._actual_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)
        self._total_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)

    @staticmethod
    def _validate_config(config: Dict[str, Any]) -> AzureAIChatCompletionClientConfig:
        if "endpoint" not in config:
            raise ValueError("endpoint is required for AzureAIChatCompletionClient")
        if "credential" not in config:
            raise ValueError("credential is required for AzureAIChatCompletionClient")
        if "model_info" not in config:
            raise ValueError("model_info is required for AzureAIChatCompletionClient")
        validate_model_info(config["model_info"])
        if _is_github_model(config["endpoint"]) and "model" not in config:
            raise ValueError("model is required for when using a Github model with AzureAIChatCompletionClient")
        return cast(AzureAIChatCompletionClientConfig, config)

    @staticmethod
    def _create_client(config: AzureAIChatCompletionClientConfig) -> ChatCompletionsClient:
        # Only pass the parameters that ChatCompletionsClient accepts
        # Remove 'model_info' and other client-specific parameters
        client_config = {k: v for k, v in config.items() if k not in ("model_info",)}
        return ChatCompletionsClient(**client_config)  # type: ignore

    @staticmethod
    def _prepare_create_args(config: Mapping[str, Any]) -> Dict[str, Any]:

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Pass endpoint as a keyword argument, e.g. AzureAIChatCompletionClient(endpoint='https://<resource>.services.ai.azure.com/models', ...)
  2. If migrating from Azure OpenAI client code, change azure_endpoint/base_url keys to endpoint
  3. Load endpoint from AZURE_AI_ENDPOINT env var and assert it is non-empty before constructing the client

Example fix

# before
client = AzureAIChatCompletionClient(credential=cred, model_info=info)

# after
client = AzureAIChatCompletionClient(
    endpoint="https://my-resource.services.ai.azure.com/models",
    credential=cred, model_info=info,
)
Defensive patterns

Strategy: validation

Validate before calling

import os

endpoint = os.environ.get("AZURE_AI_ENDPOINT")
assert endpoint, "Set AZURE_AI_ENDPOINT before constructing the Azure AI client"
client = AzureAIChatCompletionClient(endpoint=endpoint, ...)

Try / catch

try:
    client = AzureAIChatCompletionClient(**cfg)
except ValueError as e:
    raise SystemExit(f"Bad AzureAI client config: {e}") from e

Prevention

When it happens

Trigger: AzureAIChatCompletionClient(model_info=..., credential=...) with endpoint omitted; passing endpoint under a different key name (e.g. 'azure_endpoint', 'base_url', 'api_base') which __init__'s Unpack[...Config] silently drops.

Common situations: Copy-pasting config from the OpenAI or Azure OpenAI client, whose key names differ; reading settings from env vars and forgetting AZURE_AI_ENDPOINT; typos in YAML/JSON config keys.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/260c061ac5b8080e. Report an issue: GitHub.