Builders for Anthropic tool definitions, so callers don't need to memorize tool type strings or beta header names.
Each builder returns a plain map suitable for passing in tools: [...]
on a Messages request. Tools that depend on a beta header expose the
beta string via beta_header/1 and via the :beta key on the map, so
the calling resource module can wire it up automatically.
tools = [
ReqAnthropic.Tools.web_search(),
ReqAnthropic.Tools.bash(),
ReqAnthropic.Tools.custom(name: "get_weather", description: "...", input_schema: %{...})
]
ReqAnthropic.Messages.create(model: "...", max_tokens: 1024, tools: tools, messages: [...])
Summary
Functions
Advisor tool. Adds the advisor-tool-2026-03-01 beta header.
Built-in bash tool.
Computer use tool. Required: :display_width_px, :display_height_px.
Optional: :display_number. Adds the computer-use-2025-01-24 beta.
Define a custom tool with a JSON Schema input.
Build a %{name => function} lookup from a list of tool maps. Only
tools that carry a __function__ are included.
Memory tool.
Collect any beta header strings required by a list of tool maps. The resource modules use this to merge required betas into the request before sending.
Strip internal markers (__beta__, __function__) from a list of tool
maps so they can be safely sent over the wire.
Built-in text editor tool. The default name str_replace_based_edit_tool
is what the Claude 4 family expects; override with :name if you need
a different binding.
Web fetch tool.
Web search tool. Pass :max_uses to cap searches per request.
Functions
Advisor tool. Adds the advisor-tool-2026-03-01 beta header.
Built-in bash tool.
Computer use tool. Required: :display_width_px, :display_height_px.
Optional: :display_number. Adds the computer-use-2025-01-24 beta.
Define a custom tool with a JSON Schema input.
An optional :function (1-arity) can be provided. When present,
Messages.run/1 will call it automatically with the tool input map
whenever the model invokes this tool, and feed the result back.
Tools.custom(
name: "get_weather",
description: "Look up the weather for a city.",
input_schema: %{type: "object", properties: %{city: %{type: "string"}}, required: ["city"]},
function: fn %{"city" => city} -> "72°F and sunny in #{city}" end
)
Build a %{name => function} lookup from a list of tool maps. Only
tools that carry a __function__ are included.
Memory tool.
Collect any beta header strings required by a list of tool maps. The resource modules use this to merge required betas into the request before sending.
Strip internal markers (__beta__, __function__) from a list of tool
maps so they can be safely sent over the wire.
Built-in text editor tool. The default name str_replace_based_edit_tool
is what the Claude 4 family expects; override with :name if you need
a different binding.
Web fetch tool.
Web search tool. Pass :max_uses to cap searches per request.