{"record":{"id":"d86ff11b7fb3497b","repo":"langchain-ai/langchain","slug":"received-unsupported-arguments-kwargs","errorCode":null,"errorMessage":"Received unsupported arguments {kwargs}","messagePattern":"Received unsupported arguments (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/language_models/chat_models.py","lineNumber":2522,"sourceCode":"            structured_model.invoke(\n                \"What weighs more a pound of bricks or a pound of feathers\"\n            )\n            # -> {\n            #     'answer': 'They weigh the same',\n            #     'justification': 'Both a pound of bricks and a pound of feathers weigh one pound. The weight is the same, but the volume and density of the two substances differ.'\n            # }\n            ```\n\n        !!! warning \"Behavior changed in `langchain-core` 0.2.26\"\n\n            Added support for `TypedDict` class.\n\n        \"\"\"  # noqa: E501\n        _ = kwargs.pop(\"method\", None)\n        _ = kwargs.pop(\"strict\", None)\n        if kwargs:\n            msg = f\"Received unsupported arguments {kwargs}\"\n            raise ValueError(msg)\n\n        if type(self).bind_tools is BaseChatModel.bind_tools:\n            msg = \"with_structured_output is not implemented for this model.\"\n            raise NotImplementedError(msg)\n\n        llm = self.bind_tools(\n            [schema],\n            tool_choice=\"any\",\n            ls_structured_output_format={\n                \"kwargs\": {\"method\": \"function_calling\"},\n                \"schema\": schema,\n            },\n        )\n        output_parser: JsonOutputToolsParser\n        if isinstance(schema, type) and is_basemodel_subclass(schema):\n            output_parser = PydanticToolsParser(tools=[schema], first_tool_only=True)\n        else:\n            key_name = convert_to_openai_tool(schema)[\"function\"][\"name\"]","sourceCodeStart":2504,"sourceCodeEnd":2540,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/language_models/chat_models.py#L2504-L2540","documentation":"`ValueError` from the default `with_structured_output`: after popping the tolerated legacy kwargs `method` and `strict`, extra keyword arguments remain. The default implementation only forwards a schema to `bind_tools`; any other kwarg (e.g. `temperature`, `include_usage`, provider-specific options) is unsupported here and must go to `bind_tools`/model construction instead.","triggerScenarios":"Calling `model.with_structured_output(Schema, method=\"json_schema\", temperature=0)` or passing provider-specific kwargs like `parallel_tool_calls=False` directly to `with_structured_output` on a model using the base implementation.","commonSituations":"Copy-pasting provider-specific examples (OpenAI's `method=`, Anthropic options) onto a model whose override doesn't accept them; upgrading providers where kwargs moved; trying to set sampling params at structured-output time.","solutions":["Move non-schema options to model construction (`ChatModel(temperature=0)`) or a `bind_tools(...)` call and build the structured chain manually.","Check the concrete model's `with_structured_output` override signature for supported kwargs (`method`, `strict`, etc.).","Remove the unsupported kwarg entirely if it was accidental.","For full control: `model.bind_tools([Schema], tool_choice=\"any\") | PydanticToolsParser(tools=[Schema], first_tool_only=True)`."],"exampleFix":"# before\nchain = model.with_structured_output(Schema, temperature=0, method=\"function_calling\")\n\n# after\nmodel = ChatModel(temperature=0)\nchain = model.with_structured_output(Schema, method=\"function_calling\")","handlingStrategy":"validation","validationCode":"allowed = {\"method\", \"strict\"}\nextra = set(kwargs) - allowed\nif extra:\n    raise ValueError(f\"pass these to the model constructor instead: {extra}\")","typeGuard":null,"tryCatchPattern":"try:\n    chain = model.with_structured_output(Schema, **opts)\nexcept ValueError as e:\n    if \"unsupported arguments\" in str(e):\n        opts = {k: v for k, v in opts.items() if k in {\"method\", \"strict\"}}\n        chain = model.with_structured_output(Schema, **opts)\n    else:\n        raise","preventionTips":["Set sampling options on the model constructor, not on `with_structured_output`.","Check the concrete provider's override signature before passing kwargs.","Pin provider docs/examples to the version you use."],"tags":["structured-output","kwargs","input-validation"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}