{"record":{"id":"be412a7b09059c8d","repo":"langchain-ai/langchain","slug":"configuration-key-key-not-found-in-self-avail","errorCode":null,"errorMessage":"Configuration key {key} not found in {self}: available keys are {model_fields.keys()}","messagePattern":"Configuration key (.+?) not found in (.+?): available keys are (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/runnables/base.py","lineNumber":2897,"sourceCode":"                model.with_config(configurable={\"output_token_number\": 200})\n                .invoke(\"tell me something about chess\")\n                .content,\n            )\n            ```\n        \"\"\"\n        # Import locally to prevent circular import\n        from langchain_core.runnables.configurable import (  # noqa: PLC0415\n            RunnableConfigurableFields,\n        )\n\n        model_fields = type(self).model_fields\n        for key in kwargs:\n            if key not in model_fields:\n                msg = (\n                    f\"Configuration key {key} not found in {self}: \"\n                    f\"available keys are {model_fields.keys()}\"\n                )\n                raise ValueError(msg)\n\n        return RunnableConfigurableFields(default=self, fields=kwargs)\n\n    def configurable_alternatives(\n        self,\n        which: ConfigurableField,\n        *,\n        default_key: str = \"default\",\n        prefix_keys: bool = False,\n        **kwargs: Runnable[Input, Output] | Callable[[], Runnable[Input, Output]],\n    ) -> RunnableSerializable[Input, Output]:\n        \"\"\"Configure alternatives for `Runnable` objects that can be set at runtime.\n\n        Args:\n            which: The `ConfigurableField` instance that will be used to select the\n                alternative.\n            default_key: The default key to use if no alternative is selected.\n            prefix_keys: Whether to prefix the keys with the `ConfigurableField` id.","sourceCodeStart":2879,"sourceCodeEnd":2915,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/runnables/base.py#L2879-L2915","documentation":"Raised by `Runnable.with_config`-style field configuration (the `configure`/`ConfigurableField` path at the end of `base.py`) when a keyword argument names a key that is not a field of the Runnable's pydantic model (`type(self).model_fields`). Runtime configurability can only override declared fields, so unknown keys raise `ValueError`, and the message lists the actually available field names for that instance.","triggerScenarios":"`llm.with_config(tags=[...])` is fine, but the configurable-fields path `chain.configure(temperature=0.1)` on an object whose model has no `temperature` field (e.g. a prompt or a wrapper that stores settings under another name) raises. Also `.configure(model_name=...)` where the field is named `model`.","commonSituations":"Field-name drift between LangChain versions (e.g. `model_name` vs `model` on chat models); configuring through YAML/JSON run-config files where key names were hand-written; wrapping Runnables in custom classes and trying to configure inner attributes through the outer object.","solutions":["Read the error message — it prints `model_fields.keys()`, the exact set of configurable keys; use one of those names","For renamed fields across versions, resolve the right name at runtime: `key = 'model' if 'model' in type(obj).model_fields else 'model_name'`","Validate config keys against `type(runnable).model_fields` before applying them when the config comes from a file"],"exampleFix":"# before\nchain.configure(model_name=\"gpt-4o-mini\")  # ValueError: key not found\n\n# after\nfields = type(chain).model_fields\nkey = \"model\" if \"model\" in fields else \"model_name\"\nchain.configure(**{key: \"gpt-4o-mini\"})","handlingStrategy":"validation","validationCode":"from typing import Any\nfrom langchain_core.runnables import Runnable\n\ndef filter_configurable(runnable: Runnable, config: dict[str, Any]) -> dict[str, Any]:\n    fields = type(runnable).model_fields\n    bad = set(config) - set(fields)\n    if bad:\n        msg = f\"non-configurable keys {sorted(bad)}; available: {sorted(fields)}\"\n        raise ValueError(msg)\n    return config","typeGuard":"def is_configurable_key(runnable: Runnable, key: str) -> bool:\n    return key in type(runnable).model_fields","tryCatchPattern":"try:\n    runnable.configure(**config)\nexcept ValueError as e:\n    if \"not found in\" in str(e):\n        fields = type(runnable).model_fields\n        usable = {k: v for k, v in config.items() if k in fields}\n        runnable.configure(**usable)  # apply valid subset, log the rest\n    else:\n        raise","preventionTips":["Derive config keys from type(runnable).model_fields, never hand-type them","Resolve renamed fields (model vs model_name) at runtime against model_fields","Schema-validate YAML/JSON run-config against model_fields on load"],"tags":["runnables","configuration","configurable-fields","valueerror","field-names"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}