{"record":{"id":"b11618c348482b12","repo":"microsoft/autogen","slug":"model-info-is-required-when-model-name-is-not-a-va","errorCode":null,"errorMessage":"model_info is required when model name is not a valid OpenAI model","messagePattern":"model_info is required when model name is not a valid OpenAI model","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/ollama/_ollama_client.py","lineNumber":473,"sourceCode":"    create_args: Dict[str, Any]\n\n\nclass BaseOllamaChatCompletionClient(ChatCompletionClient):\n    def __init__(\n        self,\n        client: AsyncClient,\n        *,\n        create_args: Dict[str, Any],\n        model_capabilities: Optional[ModelCapabilities] = None,  # type: ignore\n        model_info: Optional[ModelInfo] = None,\n    ):\n        self._client = client\n        self._model_name = create_args[\"model\"]\n        if model_capabilities is None and model_info is None:\n            try:\n                self._model_info = _model_info.get_info(create_args[\"model\"])\n            except KeyError as err:\n                raise ValueError(\"model_info is required when model name is not a valid OpenAI model\") from err\n        elif model_capabilities is not None and model_info is not None:\n            raise ValueError(\"model_capabilities and model_info are mutually exclusive\")\n        elif model_capabilities is not None and model_info is None:\n            warnings.warn(\"model_capabilities is deprecated, use model_info instead\", DeprecationWarning, stacklevel=2)\n            info = cast(ModelInfo, model_capabilities)\n            info[\"family\"] = ModelFamily.UNKNOWN\n            self._model_info = info\n        elif model_capabilities is None and model_info is not None:\n            self._model_info = model_info\n\n        self._resolved_model: Optional[str] = None\n        self._model_class: Optional[str] = None\n        if \"model\" in create_args:\n            self._resolved_model = create_args[\"model\"]\n            self._model_class = _model_info.resolve_model_class(create_args[\"model\"])\n\n        if (\n            not self._model_info[\"json_output\"]","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/ollama/_ollama_client.py#L455-L491","documentation":"When neither model_capabilities nor model_info is passed, OllamaChatCompletionClient tries to look up the model name in the autogen_ext.models._model_info registry (the OpenAI model table). A KeyError from that lookup is re-raised as this ValueError: custom/Ollama model names are not in the OpenAI registry, so the caller must supply model_info explicitly.","triggerScenarios":"OllamaChatCompletionClient(model='llama3.2:latest') with no model_info; model='mistral-nemo' or any name not present in the OpenAI model info table; version drift where a newly shipped Ollama tag is missing from the bundled registry.","commonSituations":"First-time use with locally pulled Ollama tags; upgrading Ollama to a new model release before autogen-ext's model table updates; copying example code that omitted model_info.","solutions":["Pass model_info describing the model: OllamaChatCompletionClient(model='llama3.2', model_info={'vision': True, 'function_calling': True, 'json_output': True, 'family': ModelFamily.UNKNOWN, 'structured_output': True})","Or use a name that exists in the registry (an OpenAI-known model name)","Build the dict from ModelInfo fields; include 'family' to satisfy the type"],"exampleFix":"# before\nclient = OllamaChatCompletionClient(model=\"llama3.2:latest\")\n\n# after\nclient = OllamaChatCompletionClient(\n    model=\"llama3.2:latest\",\n    model_info={\"vision\": True, \"function_calling\": True, \"json_output\": True, \"structured_output\": True, \"family\": ModelFamily.UNKNOWN},\n)","handlingStrategy":"validation","validationCode":"from autogen_ext.models._model_info import ModelInfo\n\ndef with_model_info(cfg: dict) -> dict:\n    try:\n        ModelInfo.get_info(cfg[\"model\"])\n    except KeyError:\n        cfg.setdefault(\"model_info\", {\n            \"vision\": False, \"function_calling\": True,\n            \"json_output\": True, \"structured_output\": True,\n            \"family\": ModelFamily.UNKNOWN,\n        })\n    return cfg\n\nclient = OllamaChatCompletionClient(**with_model_info(cfg))","typeGuard":null,"tryCatchPattern":"try:\n    client = OllamaChatCompletionClient(model=name)\nexcept ValueError as e:\n    if \"model_info is required\" in str(e):\n        client = OllamaChatCompletionClient(model=name, model_info=default_info)\n    else:\n        raise","preventionTips":["Always pass an explicit model_info when using local Ollama tags","Keep a small dict of model_info per model tag in your config","On autogen-ext upgrades, re-check which Ollama tags the bundled registry knows"],"tags":["ollama","model-info","configuration","constructor"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}