openai/openai-python · error · ValueError

Currently only `function` tool types support auto-parsing; R

Error message

Currently only `function` tool types support auto-parsing; Received `{tool['type']}`

What it means

The completions auto-parsing helpers (chat.completions.parse / maybe_parse_content) only support tools of type 'function'; the model's structured-output parsing cannot auto-parse other tool types like 'custom' or code-interpreter tools. The library validates tools before sending the request.

Source

Thrown at src/openai/lib/_parsing/_completions.py:73

def select_strict_chat_completion_tools(
    tools: Iterable[ChatCompletionToolUnionParam] | Omit = omit,
) -> Iterable[ChatCompletionFunctionToolParam] | Omit:
    """Select only the strict ChatCompletionFunctionToolParams from the given tools."""
    if not is_given(tools):
        return omit

    return [t for t in tools if is_strict_chat_completion_tool_param(t)]


def validate_input_tools(
    tools: Iterable[ChatCompletionToolUnionParam] | Omit = omit,
) -> Iterable[ChatCompletionFunctionToolParam] | Omit:
    if not is_given(tools):
        return omit

    for tool in tools:
        if tool["type"] != "function":
            raise ValueError(
                f"Currently only `function` tool types support auto-parsing; Received `{tool['type']}`",
            )

        strict = tool["function"].get("strict")
        if strict is not True:
            raise ValueError(
                f"`{tool['function']['name']}` is not strict. Only `strict` function tools can be auto-parsed"
            )

    return cast(Iterable[ChatCompletionFunctionToolParam], tools)


def parse_chat_completion(
    *,
    response_format: type[ResponseFormatT] | completion_create_params.ResponseFormat | Omit,
    input_tools: Iterable[ChatCompletionToolUnionParam] | Omit,
    chat_completion: ChatCompletion | ParsedChatCompletion[object],
) -> ParsedChatCompletion[ResponseFormatT]:

View on GitHub (pinned to 9917c6e28e)

Solutions

  1. Remove non-function tools when using .parse() and auto-parsing
  2. Split the request: use .parse() for strict function tools and completions.create for other tool types
  3. Implement a custom tool loop manually if you need custom tools with parsing

Example fix

# before
client.chat.completions.parse(model=..., tools=[{"type":"custom","custom":{...}}], ...)
# after
client.chat.completions.parse(model=..., tools=[{"type":"function","function":{...}}], ...)
Defensive patterns

Strategy: validation

Validate before calling

bad = [t for t in tools if t.get("type") != "function"]
assert not bad, f"non-function tools not supported by .parse(): {bad}"

Type guard

def is_function_tool(t: dict) -> bool:
    return t.get("type") == "function"

Prevention

When it happens

Trigger: Passing a tools=[{'type': 'custom', ...}] (or any non-'function' type) to client.chat.completions.parse.

Common situations: Reusing a tool list built for regular completions.create with .parse(); migrating code to .parse() while keeping freeform/custom tools; copying tool JSON from newer API docs.

Related errors


AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28). Data as JSON: /api/errors/58734069ee715abf. Report an issue: GitHub.