{"record":{"id":"008735612439c0b2","repo":"langchain-ai/langchain","slug":"input-must-be-a-valid-openai-format-tool","errorCode":null,"errorMessage":"Input must be a valid OpenAI-format tool.","messagePattern":"Input must be a valid OpenAI-format tool\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/utils/function_calling.py","lineNumber":606,"sourceCode":"        strict: If `True`, model output is guaranteed to exactly match the JSON Schema\n            provided in the function definition.\n\n            If `None`, `strict` argument will not be included in function definition.\n\n    Raises:\n        ValueError: If the input is not a valid OpenAI-format tool.\n\n    Returns:\n        A JSON schema representation of the input schema.\n    \"\"\"\n    openai_tool = convert_to_openai_tool(schema, strict=strict)\n    if (\n        not isinstance(openai_tool, dict)\n        or \"function\" not in openai_tool\n        or \"name\" not in openai_tool[\"function\"]\n    ):\n        error_message = \"Input must be a valid OpenAI-format tool.\"\n        raise ValueError(error_message)\n\n    openai_function = openai_tool[\"function\"]\n    json_schema = {}\n    json_schema[\"title\"] = openai_function[\"name\"]\n\n    if \"description\" in openai_function:\n        json_schema[\"description\"] = openai_function[\"description\"]\n\n    if \"parameters\" in openai_function:\n        parameters = openai_function[\"parameters\"].copy()\n        json_schema.update(parameters)\n\n    return json_schema\n\n\n@beta()\ndef tool_example_to_messages(\n    input: str,","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/utils/function_calling.py#L588-L624","documentation":"Error \"Input must be a valid OpenAI-format tool.\" thrown in langchain-ai/langchain.","triggerScenarios":"Raised when the input to a conversion expecting an OpenAI-format tool dict is missing required keys ('type': 'function' and a 'function' payload) or is of the wrong type.","commonSituations":"See trigger scenarios.","solutions":["Pass a dict in OpenAI tool format: {'type': 'function', 'function': {...}}.","Convert other schema forms first with convert_to_openai_tool or convert_to_openai_function."],"exampleFix":"tool = {'type': 'function', 'function': {'name': 'f', 'parameters': {...}}}","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}