langchain-ai/langchain · error · ValueError
Unsupported function {function} Functions must be passed i
Error message
Unsupported function
{function}
Functions must be passed in as Dict, pydantic.BaseModel, or Callable. If they're a dict they must either be in OpenAI function format or valid JSON schema with top-level 'title' key. What it means
Error "Unsupported function {function} Functions must be passed in as Dict, pydantic.BaseModel, or Callable. If they're a dict they must either be in OpenAI function format or valid JSON schema with top-level 'title' key." thrown in langchain-ai/langchain.
Source
Thrown at libs/core/langchain_core/utils/function_calling.py:468
"dict[str, Any]", _convert_python_function_to_openai_function(function)
)
else:
if isinstance(function, dict) and (
"type" in function or "properties" in function
):
msg = (
f"Unsupported function\n\n{function}\n\nTo use a JSON schema as a "
"function, it must have a top-level 'title' key to be used as the "
"function name."
)
raise ValueError(msg)
msg = (
f"Unsupported function\n\n{function}\n\nFunctions must be passed in"
" as Dict, pydantic.BaseModel, or Callable. If they're a dict they must"
" either be in OpenAI function format or valid JSON schema with top-level"
" 'title' key."
)
raise ValueError(msg)
if strict is not None:
if "strict" in oai_function and oai_function["strict"] != strict:
msg = (
f"Tool/function already has a 'strict' key with value "
f"{oai_function['strict']} which is different from the explicit "
f"`strict` arg received {strict=}."
)
raise ValueError(msg)
oai_function["strict"] = strict
if strict:
# All fields must be `required`
parameters = oai_function.get("parameters")
if isinstance(parameters, dict):
fields = parameters.get("properties")
if isinstance(fields, dict) and fields:
parameters = dict(parameters)
parameters["required"] = list(fields.keys())View on GitHub (pinned to e32fa9a52e)
Solutions
- Pass the function as a dict in OpenAI function format, a pydantic.BaseModel subclass, or a Python callable.
- If passing a dict, ensure it is either OpenAI function format or a valid JSON schema with a top-level 'title' key.
Example fix
convert_to_openai_function(MyModel) # or a callable, or {'name':..., 'parameters': {...}} When it happens
Trigger: Raised when convert_to_openai_function receives an unsupported object: not a dict in OpenAI function format, not a valid JSON schema with 'title', not a pydantic.BaseModel, and not a callable.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/782aeeaf8ddf1aec.
Report an issue: GitHub.