Variable: tools
@providerprotocol/ai / anthropic / tools
Variable: tools
Section titled “Variable: tools”
consttools:object
Defined in: src/providers/anthropic/types.ts:1254
Namespace object containing all Anthropic tool helper constructors.
Provides a convenient way to create built-in tool configurations.
Type Declaration
Section titled “Type Declaration”bash()
Section titled “bash()”bash: () =>
AnthropicBashTool=bashTool
Creates a bash tool configuration
Creates a bash tool configuration.
The bash tool enables Claude to execute shell commands. Sessions persist within the conversation.
Token overhead: ~245 tokens per tool definition.
Returns
Section titled “Returns”A bash tool configuration object
Example
Section titled “Example”const bash = bashTool();codeExecution()
Section titled “codeExecution()”codeExecution: () =>
AnthropicCodeExecutionTool=codeExecutionTool
Creates a code execution tool configuration
Creates a code execution tool configuration.
The code execution tool enables Claude to write and execute Python/Bash code in a secure sandboxed container.
Requires beta header: code-execution-2025-08-25 (automatically injected).
Pricing:
- Free tier: 1,550 hours/month per organization
- Additional: $0.05 per hour, per container
Returns
Section titled “Returns”A code execution tool configuration object
Example
Section titled “Example”const codeExec = codeExecutionTool();computer()
Section titled “computer()”computer: (
options) =>AnthropicComputerTool=computerTool
Creates a computer use tool configuration
Creates a computer use tool configuration.
The computer tool enables Claude to interact with computer interfaces through mouse clicks, keyboard input, and screenshots.
Requires beta header (automatically injected when using this tool):
computer-use-2025-11-24for Claude Opus 4.5computer-use-2025-01-24for other models
Parameters
Section titled “Parameters”options
Section titled “options”Display configuration and optional settings
display_height_px
Section titled “display_height_px”number
display_number?
Section titled “display_number?”number
display_width_px
Section titled “display_width_px”number
enable_zoom?
Section titled “enable_zoom?”boolean
version?
Section titled “version?”"20250124" | "20251124"
Use ‘20251124’ for Claude Opus 4.5, ‘20250124’ for other models
Returns
Section titled “Returns”A computer tool configuration object
Example
Section titled “Example”const computer = computerTool({ display_width_px: 1920, display_height_px: 1080,});
// For Opus 4.5 with zoom supportconst computerOpus = computerTool({ display_width_px: 1920, display_height_px: 1080, version: '20251124', enable_zoom: true,});textEditor()
Section titled “textEditor()”textEditor: (
options?) =>AnthropicTextEditorTool=textEditorTool
Creates a text editor tool configuration
Creates a text editor tool configuration.
The text editor tool enables Claude to view, create, and edit files using commands like view, str_replace, create, and insert.
Token overhead: ~700 tokens per tool definition.
Parameters
Section titled “Parameters”options?
Section titled “options?”Optional configuration
max_characters?
Section titled “max_characters?”number
version?
Section titled “version?”"20250124" | "20250728"
Use ‘20250728’ for Claude 4, ‘20250124’ for Claude 3.7
Returns
Section titled “Returns”A text editor tool configuration object
Example
Section titled “Example”const editor = textEditorTool();
// With max characters for view truncationconst editorWithLimit = textEditorTool({ max_characters: 10000,});toolSearch()
Section titled “toolSearch()”toolSearch: (
options?) =>AnthropicToolSearchTool=toolSearchTool
Creates a tool search tool configuration
Creates a tool search tool configuration.
The tool search tool enables Claude to search through large tool catalogs (up to 10,000 tools) using regex or natural language.
Requires beta header: advanced-tool-use-2025-11-20 (automatically injected).
Parameters
Section titled “Parameters”options?
Section titled “options?”Optional mode selection
"regex" | "bm25"
Search mode: ‘regex’ for pattern matching, ‘bm25’ for natural language
Returns
Section titled “Returns”A tool search tool configuration object
Example
Section titled “Example”// Regex-based search (default)const search = toolSearchTool();
// Natural language (BM25) searchconst nlSearch = toolSearchTool({ mode: 'bm25' });webSearch()
Section titled “webSearch()”webSearch: (
options?) =>AnthropicWebSearchTool=webSearchTool
Creates a web search tool configuration
Creates a web search tool configuration.
The web search tool enables Claude to search the web for up-to-date information. Pricing: $10 per 1,000 searches plus standard token costs.
Parameters
Section titled “Parameters”options?
Section titled “options?”Optional configuration for search behavior
allowed_domains?
Section titled “allowed_domains?”string[]
blocked_domains?
Section titled “blocked_domains?”string[]
max_uses?
Section titled “max_uses?”number
user_location?
Section titled “user_location?”Returns
Section titled “Returns”A web search tool configuration object
Example
Section titled “Example”// Basic web searchconst search = webSearchTool();
// With configurationconst searchWithOptions = webSearchTool({ max_uses: 5, allowed_domains: ['wikipedia.org', 'github.com'], user_location: { type: 'approximate', city: 'San Francisco', country: 'US', },});Example
Section titled “Example”import { anthropic, tools } from 'provider-protocol/anthropic';
const model = llm({ model: anthropic('claude-sonnet-4-20250514'), params: { tools: [ tools.webSearch({ max_uses: 5 }), tools.codeExecution(), ], },});