Enables OpenAI models to search the web for up-to-date information. The search behavior varies by model: non-reasoning models perform simple searches, while reasoning models can perform agentic, iterative searches.
Learn more at https://platform.openai.com/docs/guides/tools-web-search
Usage
openai_tool_web_search(
allowed_domains = NULL,
user_location = NULL,
external_web_access = TRUE
)Arguments
- allowed_domains
Character vector. Restrict searches to specific domains (e.g.,
c("nytimes.com", "bbc.com")). Maximum 20 domains. URLs will be automatically cleaned (http/https prefixes removed).- user_location
List with optional elements:
country(2-letter ISO code),city,region, andtimezone(IANA timezone) to localize search results.- external_web_access
Logical. Whether to allow live internet access (
TRUE, default) or use only cached/indexed results (FALSE).
See also
Other built-in tools:
claude_tool_web_fetch(),
claude_tool_web_search(),
google_tool_web_fetch(),
google_tool_web_search()
Examples
if (FALSE) { # \dontrun{
chat <- chat_openai()
chat$register_tool(openai_tool_web_search())
chat$chat("Very briefly summarise the top 3 news stories of the day")
chat$chat("Of those stories, which one do you think was the most interesting?")
} # }
