BerriAI/litellm · error · ValueError
Missing required parameter: name
Error message
Missing required parameter: name
What it means
For Anthropic hosted tools (types in ANTHROPIC_HOSTED_TOOLS, e.g. web_search, code_execution), LiteLLM requires a 'name' — read from tool['name'] or tool['function']['name'] — and it must be a string. If neither location holds a string name, this ValueError aborts request transformation.
Source
Thrown at litellm/llms/anthropic/chat/transformation.py:712
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_obj
additional_tool_params: Final = {}
for k, v in tool.items():
if k != "type" and k != "name":
additional_tool_params[k] = v
returned_tool = AnthropicHostedTools(
type=tool["type"],
name=function_name,
**additional_tool_params,
)
elif tool["type"] == "url": # mcp server tool
mcp_server = AnthropicMcpServerTool(**tool)
elif tool["type"] == "mcp":
mcp_server = self._map_openai_mcp_server_tool(cast(OpenAIMcpServerTool, tool))
elif tool["type"] == "tool_search_tool_regex_20251119":
# Tool search tool using regexView on GitHub (pinned to 6c2dcb801b)
Solutions
- Include a string 'name' for hosted tools, either at the top level or under 'function'.
- Use the conventional name for the tool family (e.g. 'web_search', 'code_execution') or match Anthropic's docs.
- If the tool came from the Anthropic SDK, pass it through as-is rather than rebuilding it without name.
- Pre-validate hosted tools have a string name before calling completion().
Example fix
# before
tools = [{"type": "web_search_20250305", "max_uses": 3}]
# after
tools = [{"type": "web_search_20250305", "name": "web_search", "max_uses": 3}] Defensive patterns
Strategy: validation
Validate before calling
def validate_hosted_tools(tools, hosted_types):
for t in tools:
if any(str(t.get("type", "")).startswith(h) for h in hosted_types):
name = t.get("name") or t.get("function", {}).get("name")
if not isinstance(name, str) or not name:
raise ValueError(f"hosted tool '{t['type']}' missing string 'name'")
return tools Type guard
def hosted_tool_has_name(tool) -> bool:
name = tool.get("name") or tool.get("function", {}).get("name")
return isinstance(name, str) and len(name) > 0 Prevention
- Pass raw Anthropic SDK hosted-tool dicts through unchanged.
- Use one canonical name per hosted tool family in your codebase.
When it happens
Trigger: Passing a hosted tool like {'type': 'web_search_20250305'} with no name at either level, or with name set to a non-string (dict, None, number); mixing OpenAI-style {'type': 'function', 'function': {...}} shapes with Anthropic hosted tool types.
Common situations: Porting raw Anthropic SDK tool dicts (which use {'type': 'web_search_20250305', 'name': 'web_search'}) through code that strips the top-level name; schemas generated by other frameworks that omit name for non-function tools.
Related errors
- Missing required parameter: parameters
- Missing required parameter: display_width_px or display_heig
- 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/af12333bc5d93e1d.
Report an issue: GitHub.