langchain-ai/langchain · error · ValueError

Unsupported function {function} To use a JSON schema as a

Error message

Unsupported function

{function}

To use a JSON schema as a function, it must have a top-level 'title' key to be used as the function name.

What it means

Error "Unsupported function {function} To use a JSON schema as a function, it must have a top-level 'title' key to be used as the function name." thrown in langchain-ai/langchain.

Source

Thrown at libs/core/langchain_core/utils/function_calling.py:461

            "dict[str, Any]",
            _convert_typed_dict_to_openai_function(cast("type", function)),
        )
    elif isinstance(function, langchain_core.tools.base.BaseTool):
        oai_function = cast("dict[str, Any]", _format_tool_to_openai_function(function))
    elif callable(function):
        oai_function = cast(
            "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:

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Add a top-level 'title' key to the JSON schema dict so it can be used as the function name.
  2. Alternatively wrap the schema in OpenAI function format: {'type': 'function', 'function': {'name': ..., 'parameters': schema}}.

Example fix

schema = {'title': 'my_func', 'type': 'object', 'properties': {...}}

When it happens

Trigger: Raised when a dict passed as a function to convert_to_openai_function lacks a top-level 'title' key, so no function name can be derived.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/226b62f12f95a34a. Report an issue: GitHub.