Built-in tool that enables Claude to search the web for current information.
Usage
claude_web_search(
max_uses = 5L,
allowed_domains = NULL,
blocked_domains = NULL,
user_location = NULL
)Arguments
- max_uses
Integer. Maximum search attempts per request. Default 5.
- allowed_domains
Character vector. Restrict searches to these domains. Mutually exclusive with
blocked_domains.- blocked_domains
Character vector. Exclude these domains from search.
- user_location
List. Location for localized results with elements:
country,city,region,timezone.
Value
An ellmer tool object for use with claude_new().
Details
Web search must be enabled in your Anthropic Console. Cost: ~$10 per 1,000 searches.
Claude will automatically cite sources from search results.
Examples
if (FALSE) { # \dontrun{
# Basic web search
chat <- claude_new(tools = list(claude_web_search()))
chat$chat("What happened in tech news today?")
# Restricted to specific domains
chat <- claude_new(tools = list(
claude_web_search(allowed_domains = c("cran.r-project.org", "r-project.org"))
))
chat$chat("Find the latest R package updates")
# Block certain domains
chat <- claude_new(tools = list(
claude_web_search(blocked_domains = c("reddit.com", "twitter.com"))
))
chat$chat("Research machine learning best practices")
# With location for localized results
chat <- claude_new(tools = list(
claude_web_search(user_location = list(
country = "US",
city = "New York",
region = "NY",
timezone = "America/New_York"
))
))
chat$chat("What are local art exhibitions this week?")
} # }
