{"record":{"id":"b3376f08e0f4a8bb","repo":"BerriAI/litellm","slug":"missing-required-parameter-display-width-px-or-di","errorCode":null,"errorMessage":"Missing required parameter: display_width_px or display_height_px","messagePattern":"Missing required parameter: display_width_px or display_height_px","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/chat/transformation.py","lineNumber":695,"sourceCode":"                input_schema=input_anthropic_schema,\n                type=\"custom\",\n            )\n\n            _description: Final = tool[\"function\"].get(\"description\")\n            if _description is not None:\n                _tool[\"description\"] = _description\n\n            returned_tool = _tool\n\n        elif tool[\"type\"].startswith(\"computer_\"):\n            ## check if all required 'display_' params are given\n            if \"parameters\" not in tool[\"function\"]:\n                raise ValueError(\"Missing required parameter: parameters\")\n\n            _display_width_px: Final[int | None] = tool[\"function\"][\"parameters\"].get(\"display_width_px\")\n            _display_height_px: Final[int | None] = tool[\"function\"][\"parameters\"].get(\"display_height_px\")\n            if _display_width_px is None or _display_height_px is None:\n                raise ValueError(\"Missing required parameter: display_width_px or display_height_px\")\n\n            _computer_tool: Final = AnthropicComputerTool(\n                type=tool[\"type\"],\n                name=tool[\"function\"].get(\"name\", \"computer\"),\n                display_width_px=_display_width_px,\n                display_height_px=_display_height_px,\n            )\n\n            _display_number: Final = tool[\"function\"][\"parameters\"].get(\"display_number\")\n            if _display_number is not None:\n                _computer_tool[\"display_number\"] = _display_number\n\n            returned_tool = _computer_tool\n        elif any(tool[\"type\"].startswith(t) for t in ANTHROPIC_HOSTED_TOOLS):\n            function_name_obj: Final = tool.get(\"name\", tool.get(\"function\", {}).get(\"name\"))\n            if function_name_obj is None or not isinstance(function_name_obj, str):\n                raise ValueError(\"Missing required parameter: name\")\n            function_name: Final = function_name_obj","sourceCodeStart":677,"sourceCodeEnd":713,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/anthropic/chat/transformation.py#L677-L713","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\n\"parameters\": {\"display_number\": 0}\n\n# after\n\"parameters\": {\n    \"display_width_px\": 1024,\n    \"display_height_px\": 768,\n    \"display_number\": 0,  # optional\n}","handlingStrategy":"validation","validationCode":"def validate_display_dims(tools):\n    for t in tools:\n        if str(t.get(\"type\", \"\")).startswith(\"computer_\"):\n            p = t[\"function\"][\"parameters\"]\n            for k in (\"display_width_px\", \"display_height_px\"):\n                if not isinstance(p.get(k), int):\n                    raise ValueError(f\"{t['type']}: {k} must be a set integer\")\n    return tools","typeGuard":"def has_display_dims(tool) -> bool:\n    p = tool.get(\"function\", {}).get(\"parameters\", {})\n    return isinstance(p.get(\"display_width_px\"), int) and isinstance(p.get(\"display_height_px\"), int)","tryCatchPattern":null,"preventionTips":["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."],"tags":["anthropic","tools","computer-use","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}