{"record":{"id":"9afe0d627e4dd025","repo":"langchain-ai/deepagents","slug":"invalid-model-configuration-for-provider-model","errorCode":null,"errorMessage":"Invalid model configuration for '{provider}:{model_name}': {e}","messagePattern":"Invalid model configuration for '(.+?):(.+?)': (.+?)","errorType":"validation","errorClass":"ModelConfigError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/config.py","lineNumber":5509,"sourceCode":"                else:\n                    install_hint = f\"Install the '{package}' package manually\"\n                msg = (\n                    f\"Missing package for provider '{provider}'. \"\n                    f\"{install_hint}, then retry with `/model`.\"\n                )\n            raise MissingProviderPackageError(\n                msg, provider=provider, package=package\n            ) from e\n        raise ModelConfigError(msg) from e\n    except (ValueError, TypeError) as e:\n        if not provider:\n            # Both app auto-detection and `init_chat_model`'s own inference\n            # failed; surface a structured error so the UI can render the\n            # docs URL as a clickable link.\n            raise UnknownProviderError(model_spec=model_name) from e\n        spec = f\"{provider}:{model_name}\"\n        msg = f\"Invalid model configuration for '{spec}': {e}\"\n        raise ModelConfigError(msg) from e\n    except Exception as e:  # provider SDK auth/network errors\n        spec = f\"{provider}:{model_name}\" if provider else model_name\n        msg = f\"Failed to initialize model '{spec}': {e}\"\n        raise ModelConfigError(msg) from e\n\n\n@dataclass(frozen=True)\nclass ModelResult:\n    \"\"\"Result of creating a chat model, bundling the model with its metadata.\n\n    This separates model creation from runtime-state mutation so callers can\n    decide when to commit the metadata to process-wide state.\n\n    Attributes:\n        model: The instantiated chat model.\n        model_name: Resolved model name.\n        provider: Resolved provider name.\n        context_limit: Max input tokens from the model profile, or `None`.","sourceCodeStart":5491,"sourceCodeEnd":5527,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L5491-L5527","documentation":"Raised when the provider was resolved but `init_chat_model` raised ValueError/TypeError while constructing the model, meaning the spec/provider is known but the model configuration is invalid for that provider. The original exception is chained for diagnosis.","triggerScenarios":"`create_model('provider:model')` where the provider package is installed but the constructor rejects the arguments — e.g. an unknown/unsupported model name for that provider, or invalid extra_kwargs / retry kwargs passed through.","commonSituations":"Model ID not offered by the named provider ('anthropic:gpt-4'), deprecated model removed from the provider SDK, config.toml kwargs incompatible with the provider class version.","solutions":["Verify the model name is valid for the named provider and correct the spec.","Read the chained exception (raised `from e`) for the underlying cause.","Check extra_kwargs / config.toml model kwargs for invalid or renamed options.","Upgrade the provider package (e.g. langchain-openai) in case the model id is newer than the integration supports."],"exampleFix":"// before\nmodel = create_model(\"anthropic:gpt-5.5\")  # wrong provider for model\n// after\nmodel = create_model(\"openai:gpt-5.5\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = create_model(spec)\nexcept ModelConfigError as e:\n    logger.error(\"%s (cause: %r)\", e, e.__cause__)\n    # fall back to a known-good default spec","preventionTips":["Confirm the model id exists for the named provider before shipping a config","Pin/upgrade the langchain-<provider> package to a version that knows the model id","Validate extra_kwargs against the provider integration's constructor signature","Prefer provider: prefix over bare names to make the failing provider obvious"],"tags":["model-config","langchain","validation"],"backgroundTag":"invalid-model-configuration","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}