microsoft/autogen · error · ValueError
model is required for OllamaChatCompletionClient
Error message
model is required for OllamaChatCompletionClient
What it means
OllamaChatCompletionClient's constructor requires a 'model' keyword argument. Unlike some clients, there is no default or environment fallback: if kwargs contains no 'model' key, __init__ raises ValueError immediately. The model name is needed both for the API call and to look up default capabilities.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/ollama/_ollama_client.py:976
response_format=StructuredOutput,
)
result = await ollama_client.create([UserMessage(content="Who was the first man on the moon?", source="user")]) # type: ignore
print(result)
Note:
Tool usage in ollama is stricter than in its OpenAI counterparts. While OpenAI accepts a map of [str, Any], Ollama requires a map of [str, Property] where Property is a typed object containing ``type`` and ``description`` fields. Therefore, only the keys ``type`` and ``description`` will be converted from the properties blob in the tool schema.
To view the full list of available configuration options, see the :py:class:`OllamaClientConfigurationConfigModel` class.
"""
component_type = "model"
component_config_schema = BaseOllamaClientConfigurationConfigModel
component_provider_override = "autogen_ext.models.ollama.OllamaChatCompletionClient"
def __init__(self, **kwargs: Unpack[BaseOllamaClientConfiguration]):
if "model" not in kwargs:
raise ValueError("model is required for OllamaChatCompletionClient")
model_capabilities: Optional[ModelCapabilities] = None # type: ignore
copied_args = dict(kwargs).copy()
if "model_capabilities" in kwargs:
model_capabilities = kwargs["model_capabilities"]
del copied_args["model_capabilities"]
model_info: Optional[ModelInfo] = None
if "model_info" in kwargs:
model_info = kwargs["model_info"]
del copied_args["model_info"]
client = _ollama_client_from_config(copied_args)
create_args = _create_args_from_config(copied_args)
self._raw_config: Dict[str, Any] = copied_args
super().__init__(
client=client, create_args=create_args, model_capabilities=model_capabilities, model_info=model_info
)View on GitHub (pinned to 027ecf0a37)
Solutions
- Pass model='...' as a keyword argument: OllamaChatCompletionClient(model='llama3.1')
- If loading from config, validate the dict contains the 'model' key before constructing and fix the config source
- Check for misspellings like model_name or model_name_or_path and rename to model
Example fix
# before client = OllamaChatCompletionClient(host='http://localhost:11434') # no model # after client = OllamaChatCompletionClient(model='llama3.1', host='http://localhost:11434')
Defensive patterns
Strategy: validation
Validate before calling
config = {'host': 'http://localhost:11434'}
assert 'model' in config, 'Ollama client config must include the model name'
client = OllamaChatCompletionClient(**config) Try / catch
try:
client = OllamaChatCompletionClient(**config)
except ValueError as e:
if 'model is required' in str(e):
config = {**config, 'model': os.environ['OLLAMA_MODEL']}
client = OllamaChatCompletionClient(**config)
else:
raise Prevention
- Include 'model' in every config template for Ollama clients
- Validate config dicts with a schema (pydantic) before constructing components
- Prefer component_config_schema-based loading which surfaces required fields
When it happens
Trigger: Constructing OllamaChatCompletionClient() with no arguments, or passing the model under a different key (model_name=..., model_id=...) so 'model' is absent from kwargs. Also occurs when loading from a config/component dict that lacks the 'model' key.
Common situations: Loading client config from JSON/YAML where the model field was omitted or misspelled; component-based deserialization of a config blob saved without the model; migrating code where another client used a different parameter name.
Related errors
- Required create args are missing: {required_create_args - cr
- modelName is a required property for LMStudioConfig and cann
- Could not create chat manager; make sure that it contains a
- Expected Memory, List[Memory], or None, got {type(memory)}
- At least one participant is required.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/95da2348c246ad62.
Report an issue: GitHub.