microsoft/autogen · error · ValueError
model_info is required when model name is not a valid OpenAI
Error message
model_info is required when model name is not a valid OpenAI model
What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/ollama/_ollama_client.py:473
create_args: Dict[str, Any]
class BaseOllamaChatCompletionClient(ChatCompletionClient):
def __init__(
self,
client: AsyncClient,
*,
create_args: Dict[str, Any],
model_capabilities: Optional[ModelCapabilities] = None, # type: ignore
model_info: Optional[ModelInfo] = None,
):
self._client = client
self._model_name = create_args["model"]
if model_capabilities is None and model_info is None:
try:
self._model_info = _model_info.get_info(create_args["model"])
except KeyError as err:
raise ValueError("model_info is required when model name is not a valid OpenAI model") from err
elif model_capabilities is not None and model_info is not None:
raise ValueError("model_capabilities and model_info are mutually exclusive")
elif model_capabilities is not None and model_info is None:
warnings.warn("model_capabilities is deprecated, use model_info instead", DeprecationWarning, stacklevel=2)
info = cast(ModelInfo, model_capabilities)
info["family"] = ModelFamily.UNKNOWN
self._model_info = info
elif model_capabilities is None and model_info is not None:
self._model_info = model_info
self._resolved_model: Optional[str] = None
self._model_class: Optional[str] = None
if "model" in create_args:
self._resolved_model = create_args["model"]
self._model_class = _model_info.resolve_model_class(create_args["model"])
if (
not self._model_info["json_output"]View on GitHub (pinned to 027ecf0a37)
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
Example fix
# before
client = OllamaChatCompletionClient(model="llama3.2:latest")
# after
client = OllamaChatCompletionClient(
model="llama3.2:latest",
model_info={"vision": True, "function_calling": True, "json_output": True, "structured_output": True, "family": ModelFamily.UNKNOWN},
) Defensive patterns
Strategy: validation
Validate before calling
from autogen_ext.models._model_info import ModelInfo
def with_model_info(cfg: dict) -> dict:
try:
ModelInfo.get_info(cfg["model"])
except KeyError:
cfg.setdefault("model_info", {
"vision": False, "function_calling": True,
"json_output": True, "structured_output": True,
"family": ModelFamily.UNKNOWN,
})
return cfg
client = OllamaChatCompletionClient(**with_model_info(cfg)) Try / catch
try:
client = OllamaChatCompletionClient(model=name)
except ValueError as e:
if "model_info is required" in str(e):
client = OllamaChatCompletionClient(model=name, model_info=default_info)
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- model_info is required for AzureAIChatCompletionClient
- model_capabilities and model_info are mutually exclusive
- Model does not support JSON output.
- Unsupported config type {config.GetType()}
- model_client.model_info must be provided when max_retries_on
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/b11618c348482b12.
Report an issue: GitHub.