{"record":{"id":"260c061ac5b8080e","repo":"microsoft/autogen","slug":"endpoint-is-required-for-azureaichatcompletionclie","errorCode":null,"errorMessage":"endpoint is required for AzureAIChatCompletionClient","messagePattern":"endpoint is required for AzureAIChatCompletionClient","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py","lineNumber":302,"sourceCode":"        if __name__ == \"__main__\":\n            asyncio.run(main())\n\n\n    \"\"\"\n\n    def __init__(self, **kwargs: Unpack[AzureAIChatCompletionClientConfig]):\n        config = self._validate_config(kwargs)  # type: ignore\n        self._model_info = config[\"model_info\"]  # type: ignore\n        self._client = self._create_client(config)\n        self._create_args = self._prepare_create_args(config)\n\n        self._actual_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)\n        self._total_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)\n\n    @staticmethod\n    def _validate_config(config: Dict[str, Any]) -> AzureAIChatCompletionClientConfig:\n        if \"endpoint\" not in config:\n            raise ValueError(\"endpoint is required for AzureAIChatCompletionClient\")\n        if \"credential\" not in config:\n            raise ValueError(\"credential is required for AzureAIChatCompletionClient\")\n        if \"model_info\" not in config:\n            raise ValueError(\"model_info is required for AzureAIChatCompletionClient\")\n        validate_model_info(config[\"model_info\"])\n        if _is_github_model(config[\"endpoint\"]) and \"model\" not in config:\n            raise ValueError(\"model is required for when using a Github model with AzureAIChatCompletionClient\")\n        return cast(AzureAIChatCompletionClientConfig, config)\n\n    @staticmethod\n    def _create_client(config: AzureAIChatCompletionClientConfig) -> ChatCompletionsClient:\n        # Only pass the parameters that ChatCompletionsClient accepts\n        # Remove 'model_info' and other client-specific parameters\n        client_config = {k: v for k, v in config.items() if k not in (\"model_info\",)}\n        return ChatCompletionsClient(**client_config)  # type: ignore\n\n    @staticmethod\n    def _prepare_create_args(config: Mapping[str, Any]) -> Dict[str, Any]:","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py#L284-L320","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass endpoint as a keyword argument, e.g. AzureAIChatCompletionClient(endpoint='https://<resource>.services.ai.azure.com/models', ...)","If migrating from Azure OpenAI client code, change azure_endpoint/base_url keys to endpoint","Load endpoint from AZURE_AI_ENDPOINT env var and assert it is non-empty before constructing the client"],"exampleFix":"# before\nclient = AzureAIChatCompletionClient(credential=cred, model_info=info)\n\n# after\nclient = AzureAIChatCompletionClient(\n    endpoint=\"https://my-resource.services.ai.azure.com/models\",\n    credential=cred, model_info=info,\n)","handlingStrategy":"validation","validationCode":"import os\n\nendpoint = os.environ.get(\"AZURE_AI_ENDPOINT\")\nassert endpoint, \"Set AZURE_AI_ENDPOINT before constructing the Azure AI client\"\nclient = AzureAIChatCompletionClient(endpoint=endpoint, ...)","typeGuard":null,"tryCatchPattern":"try:\n    client = AzureAIChatCompletionClient(**cfg)\nexcept ValueError as e:\n    raise SystemExit(f\"Bad AzureAI client config: {e}\") from e","preventionTips":["Use the exact key 'endpoint' (not azure_endpoint/base_url)","Centralize client construction in one factory so required keys are checked once","Fail fast on missing env vars at app startup"],"tags":["azure","configuration","constructor","required-argument"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}