{"record":{"id":"3b8e1bfbb7c7213f","repo":"microsoft/autogen","slug":"required-create-args-are-missing-required-create","errorCode":null,"errorMessage":"Required create args are missing: {required_create_args - create_args_keys}","messagePattern":"Required create args are missing: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py","lineNumber":112,"sourceCode":"}\ndisallowed_create_args = {\"stream\", \"messages\"}\nrequired_create_args: Set[str] = {\"model\"}\n\nanthropic_init_kwargs = set(inspect.getfullargspec(AsyncAnthropic.__init__).kwonlyargs)\n\n\ndef _anthropic_client_from_config(config: Mapping[str, Any]) -> AsyncAnthropic:\n    # Filter config to only include valid parameters\n    client_config = {k: v for k, v in config.items() if k in anthropic_init_kwargs}\n    return AsyncAnthropic(**client_config)\n\n\ndef _create_args_from_config(config: Mapping[str, Any]) -> Dict[str, Any]:\n    create_args = {k: v for k, v in config.items() if k in anthropic_message_params or k == \"model\"}\n    create_args_keys = set(create_args.keys())\n\n    if not required_create_args.issubset(create_args_keys):\n        raise ValueError(f\"Required create args are missing: {required_create_args - create_args_keys}\")\n\n    if disallowed_create_args.intersection(create_args_keys):\n        raise ValueError(f\"Disallowed create args are present: {disallowed_create_args.intersection(create_args_keys)}\")\n\n    return create_args\n\n\ndef type_to_role(message: LLMMessage) -> str:\n    if isinstance(message, SystemMessage):\n        return \"system\"\n    elif isinstance(message, UserMessage):\n        return \"user\"\n    elif isinstance(message, AssistantMessage):\n        return \"assistant\"\n    else:\n        return \"tool\"\n\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py#L94-L130","documentation":"AnthropicChatCompletionClient splits its kwargs into AsyncAnthropic client params and message-create params. _create_args_from_config requires that every entry of required_create_args (in practice 'model') survives the filter into create_args; if none matches (e.g. the key is misspelled or nested), it raises ValueError naming the missing set. This is the config-reconstruction path (e.g. component deserialization) catching an incomplete config.","triggerScenarios":"AnthropicChatCompletionClient(**config) where config lacks 'model' or has it misspelled ('model_name', 'modelId'); building the client from ComponentConfig where model was dropped by exclude_none or a schema mismatch; empty kwargs dict.","commonSituations":"Loading client config from YAML/JSON where the model key name differs; copy-pasting config between OpenAI-style clients (model_name) and Anthropic; component_config round-trips that lose the model field after upgrades.","solutions":["Ensure the top-level kwargs include model='claude-...' when constructing AnthropicChatCompletionClient.","Check spelling: it must be 'model', not 'model_name' or 'deployment'.","When deserializing from component config, validate the dumped dict contains 'model' before calling cls(**copied_config)."],"exampleFix":"# before\nclient = AnthropicChatCompletionClient(model_name='claude-sonnet-4-5', api_key=...)  # ValueError\n\n# after\nclient = AnthropicChatCompletionClient(model='claude-sonnet-4-5', api_key=...)","handlingStrategy":"validation","validationCode":"def make_anthropic_client(cfg: dict):\n    if not cfg.get('model'):\n        raise ValueError('anthropic config missing required key \"model\"')\n    return AnthropicChatCompletionClient(**cfg)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert 'model' is present and non-empty when loading config from files/env","Use the exact key 'model' (not model_name/deployment)","Unit-test config loading to catch schema drift before runtime"],"tags":["anthropic","configuration","llm-client","init"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}