BerriAI/litellm · error · ValueError
Missing required parameter: display_width_px or display_heig
Error message
Missing required parameter: display_width_px or display_height_px
What it means
For computer-use tools, LiteLLM reads display_width_px and display_height_px from tool['function']['parameters'] and requires both to be non-None. If either key is missing or explicitly null, this ValueError is raised during request transformation, before the API call.
Source
Thrown at litellm/llms/anthropic/chat/transformation.py:695
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
elif any(tool["type"].startswith(t) for t in ANTHROPIC_HOSTED_TOOLS):
function_name_obj: Final = tool.get("name", tool.get("function", {}).get("name"))
if function_name_obj is None or not isinstance(function_name_obj, str):
raise ValueError("Missing required parameter: name")
function_name: Final = function_name_objView on GitHub (pinned to 6c2dcb801b)
Solutions
- Set both display_width_px and display_height_px to integers in the parameters dict.
- Derive them from the actual environment/screenshot (e.g. image.size) rather than hardcoding when automating a real screen.
- Add a pre-flight assertion for computer_ tools so the failure is caught at build time.
- Note display_number is optional — only the two dimensions are mandatory.
Example fix
# before
"parameters": {"display_number": 0}
# after
"parameters": {
"display_width_px": 1024,
"display_height_px": 768,
"display_number": 0, # optional
} Defensive patterns
Strategy: validation
Validate before calling
def validate_display_dims(tools):
for t in tools:
if str(t.get("type", "")).startswith("computer_"):
p = t["function"]["parameters"]
for k in ("display_width_px", "display_height_px"):
if not isinstance(p.get(k), int):
raise ValueError(f"{t['type']}: {k} must be a set integer")
return tools Type guard
def has_display_dims(tool) -> bool:
p = tool.get("function", {}).get("parameters", {})
return isinstance(p.get("display_width_px"), int) and isinstance(p.get("display_height_px"), int) Prevention
- Derive dimensions from the screenshot you send (image.size), not constants.
- Treat display_number as optional; dimensions as mandatory.
- Add a fast unit test over your tool list before every anthropic call.
When it happens
Trigger: A computer_ tool whose parameters dict exists but lacks display_width_px/display_height_px, or sets one to None; e.g. {'parameters': {'display_number': 0}} only.
Common situations: Copy-pasted computer-use snippets from older Anthropic examples that did not include dimensions; dynamically built parameter dicts where the dimension keys are conditionally omitted; screenshots/vision code that forgot to pass the actual screen size.
Related errors
- Missing required parameter: parameters
- Missing required parameter: name
- Tool search tool must have a valid name
- Advisor tool must have a valid model
- Unsupported tool type: {tool['type']}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/b3376f08e0f4a8bb.
Report an issue: GitHub.