BerriAI/litellm · error · ValueError

Missing required parameter: parameters

Error message

Missing required parameter: parameters

What it means

Raised while translating OpenAI-format tools to Anthropic format: for a computer-use tool (type starting with 'computer_'), the tool dict must contain a 'parameters' key inside 'function'. LiteLLM needs that dict to read display dimensions for Anthropic's computer-use tool, so its absence is a client-side request-construction error, thrown before any HTTP call.

Source

Thrown at litellm/llms/anthropic/chat/transformation.py:690

            input_anthropic_schema: Final = sanitize_input_schema_for_anthropic(_input_schema)

            _tool: Final = AnthropicMessagesTool(
                name=tool["function"]["name"],
                input_schema=input_anthropic_schema,
                type="custom",
            )

            _description: Final = tool["function"].get("description")
            if _description is not None:
                _tool["description"] = _description

            returned_tool = _tool

        elif tool["type"].startswith("computer_"):
            ## check if all required 'display_' params are given
            if "parameters" not in tool["function"]:
                raise ValueError("Missing required parameter: parameters")

            _display_width_px: Final[int | None] = tool["function"]["parameters"].get("display_width_px")
            _display_height_px: Final[int | None] = tool["function"]["parameters"].get("display_height_px")
            if _display_width_px is None or _display_height_px is None:
                raise ValueError("Missing required parameter: display_width_px or display_height_px")

            _computer_tool: Final = AnthropicComputerTool(
                type=tool["type"],
                name=tool["function"].get("name", "computer"),
                display_width_px=_display_width_px,
                display_height_px=_display_height_px,
            )

            _display_number: Final = tool["function"]["parameters"].get("display_number")
            if _display_number is not None:
                _computer_tool["display_number"] = _display_number

            returned_tool = _computer_tool

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Add a 'parameters' dict under 'function' for every computer_ tool.
  2. Ensure it includes display_width_px and display_height_px (checked next, at line 695).
  3. If you already have a raw Anthropic computer tool dict, wrap it: {'type': 'computer_20250124', 'function': {'name': 'computer', 'parameters': {...}}}.
  4. Validate tools before calling completion() (see validation below) to fail fast with a clear message.

Example fix

# before
tools = [{"type": "computer_20250124", "function": {"name": "computer"}}]

# after
tools = [{
    "type": "computer_20250124",
    "function": {
        "name": "computer",
        "parameters": {
            "display_width_px": 1280,
            "display_height_px": 720,
        },
    },
}]
Defensive patterns

Strategy: validation

Validate before calling

def validate_computer_tools(tools):
    for t in tools:
        if str(t.get("type", "")).startswith("computer_"):
            params = t.get("function", {}).get("parameters")
            if not isinstance(params, dict):
                raise ValueError(f"computer tool '{t.get('type')}' needs function.parameters dict")
    return tools

Type guard

def is_valid_computer_tool(tool) -> bool:
    return (
        isinstance(tool, dict)
        and str(tool.get("type", "")).startswith("computer_")
        and isinstance(tool.get("function", {}).get("parameters"), dict)
    )

Prevention

When it happens

Trigger: Passing tools=[{'type': 'computer_20250124', 'function': {'name': 'computer'}}] (or equivalent) to an anthropic/ model without a 'parameters' dict; building computer-use tools by hand or via a helper that omits parameters.

Common situations: Migrating computer-use code from the raw Anthropic SDK (where display params sit at the top level) to LiteLLM's OpenAI-style tool schema; LLM-generated tool definitions missing the parameters field.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/624e098de52f0eea. Report an issue: GitHub.