{"record":{"id":"8dcc221d0e8b95ce","repo":"microsoft/autogen","slug":"model-info-is-required-for-azureaichatcompletioncl","errorCode":null,"errorMessage":"model_info is required for AzureAIChatCompletionClient","messagePattern":"model_info 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":306,"sourceCode":"    \"\"\"\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]:\n        create_args = {k: v for k, v in config.items() if k in create_kwargs}\n        return create_args\n\n    def add_usage(self, usage: RequestUsage) -> None:","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py#L288-L324","documentation":"Raised by AzureAIChatCompletionClient._validate_config when kwargs lack 'model_info'. Unlike the OpenAI client, the Azure AI client cannot infer capabilities from a model name string, so the required ModelInfo dict (family, vision, function_calling, json_output, ...) must be supplied; it is then passed through validate_model_info().","triggerScenarios":"Constructing AzureAIChatCompletionClient(endpoint=..., credential=...) without model_info; passing model='gpt-4o' expecting AutoGen to look up capabilities (it will not).","commonSituations":"Porting code from OpenAIChatCompletionClient where model_info was optional; assuming model_capabilities can be auto-detected from the deployment.","solutions":["Supply model_info explicitly: model_info={'family': ModelFamily.GPT_4O, 'vision': True, 'function_calling': True, 'json_output': True, 'structured_output': False}","Copy a known ModelInfo from autogen_ext.models.openai configurations for the same underlying model","Set the 'model' kwarg too when targeting GitHub Models so the right deployment is used"],"exampleFix":"# before\nclient = AzureAIChatCompletionClient(endpoint=ep, credential=cred)\n\n# after\nfrom autogen_ext.models.openai import OpenAIChatCompletionClient\nfrom autogen_core.models import ModelInfo\nclient = AzureAIChatCompletionClient(\n    endpoint=ep, credential=cred,\n    model_info=ModelInfo(family=\"gpt-4o\", vision=True, function_calling=True,\n                         json_output=True, structured_output=False),\n)","handlingStrategy":"validation","validationCode":"REQUIRED = (\"endpoint\", \"credential\", \"model_info\")\nmissing = [k for k in REQUIRED if k not in cfg]\nif missing:\n    raise ValueError(f\"AzureAI config missing: {missing}\")\nclient = AzureAIChatCompletionClient(**cfg)","typeGuard":"from typing import Mapping\n\ndef is_complete_azure_config(cfg: Mapping) -> bool:\n    return all(k in cfg for k in (\"endpoint\", \"credential\", \"model_info\"))","tryCatchPattern":null,"preventionTips":["Never port OpenAI client kwargs directly; model_info is mandatory here","Keep a canonical ModelInfo dict per deployment in config","Validate config dicts in tests"],"tags":["azure","configuration","model-info","constructor"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}