microsoft/autogen · error · ValueError
Required create args are missing: {required_create_args - cr
Error message
Required create args are missing: {required_create_args - create_args_keys} What it means
_create_args_from_config filters an incoming config mapping down to recognized OpenAI completion create-args and asserts that required keys are present. The only required create arg is 'model' (required_create_args = {'model'}); if the config contains no 'model' key, a ValueError listing the missing keys is raised. This runs when a client is constructed from a config mapping/component.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py:141
f"{AZURE_OPENAI_USER_AGENT} {azure_config[DEFAULT_HEADERS_KEY][USER_AGENT_HEADER_NAME]}"
if USER_AGENT_HEADER_NAME in azure_config[DEFAULT_HEADERS_KEY]
else AZURE_OPENAI_USER_AGENT
)
return AsyncAzureOpenAI(**azure_config)
def _openai_client_from_config(config: Mapping[str, Any]) -> AsyncOpenAI:
# Shave down the config to just the OpenAI kwargs
openai_config = {k: v for k, v in config.items() if k in openai_init_kwargs}
return AsyncOpenAI(**openai_config)
def _create_args_from_config(config: Mapping[str, Any]) -> Dict[str, Any]:
create_args = {k: v for k, v in config.items() if k in create_kwargs}
create_args_keys = set(create_args.keys())
if not required_create_args.issubset(create_args_keys):
raise ValueError(f"Required create args are missing: {required_create_args - create_args_keys}")
if disallowed_create_args.intersection(create_args_keys):
raise ValueError(f"Disallowed create args are present: {disallowed_create_args.intersection(create_args_keys)}")
return create_args
# TODO check types
# oai_system_message_schema = type2schema(ChatCompletionSystemMessageParam)
# oai_user_message_schema = type2schema(ChatCompletionUserMessageParam)
# oai_assistant_message_schema = type2schema(ChatCompletionAssistantMessageParam)
# oai_tool_message_schema = type2schema(ChatCompletionToolMessageParam)
def type_to_role(message: LLMMessage) -> ChatCompletionRole:
if isinstance(message, SystemMessage):
return "system"
elif isinstance(message, UserMessage):
return "user"
elif isinstance(message, AssistantMessage):View on GitHub (pinned to 027ecf0a37)
Solutions
- Add 'model': '<model-name>' to the config dict before create_from_config / component load
- Validate config early: assert 'model' in config before constructing, and surface a clear config error
- If the model name lives in an env var, default it: config.setdefault('model', os.environ['OPENAI_MODEL'])
Example fix
# before
client = OpenAIChatCompletionClient.create_from_config({'api_key': key}) # ValueError: Required create args are missing: {'model'}
# after
client = OpenAIChatCompletionClient.create_from_config({'model': 'gpt-4o-mini', 'api_key': key}) Defensive patterns
Strategy: validation
Validate before calling
REQUIRED = {'model'}
missing = REQUIRED - set(config.keys())
if missing:
raise ConfigError(f'Config missing {missing}')
client = OpenAIChatCompletionClient.create_from_config(config) Try / catch
try:
client = OpenAIChatCompletionClient.create_from_config(config)
except ValueError as e:
if 'Required create args are missing' in str(e):
raise ConfigError(f'Add a model to config: {e}') from e
raise Prevention
- Validate config dicts with pydantic before create_from_config
- Default the model from env: config.setdefault('model', os.environ.get('OPENAI_MODEL'))
- Add contract tests for config loading paths
When it happens
Trigger: Building a client via config (e.g. OpenAIChatCompletionClient.create_from_config({'api_key': ...}) or component deserialization) where the dict lacks 'model'. Keys that are OpenAI __init__ kwargs (api_key, base_url, timeout) are filtered into the client config and do not count as create args, so config with only those triggers it.
Common situations: Config file that sets api_key and organization but omits the model field; component config export/import round-trip that dropped 'model'; passing environment-based config where the model key is conditionally set and the condition is false.
Related errors
- Unsupported config type {config.GetType()}
- Messages should not be provided in options
- Parameter name cannot be null
- Value cannot be null. (Parameter 'functionContract.Name')
- At least one participant is required.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/a830897637e11cb0.
Report an issue: GitHub.