aiWebSearch
BoxLang AI aiWebSearch() built-in function reference
Search the web using the configured or selected provider and return normalized results.
Syntax
aiWebSearch( query, options = {} )Parameters
query
string
Yes
Search query text
options
struct
No
Search options including provider, limits, filters, and logging
Common Options
provider
string
module default or http
Provider: http, brave, google, tavily, exa
maxResults
numeric
5
Maximum number of results
timeout
numeric
30
HTTP timeout in seconds
logRequest
boolean
false
Log provider request details
logResponse
boolean
false
Log provider response details
Provider-Specific Options
Brave
country
Country filter
language
Language filter
safeSearch
Safe search mode
gl
Country target
hl
Interface language
safe
Safe search mode
Tavily
topic
Topic mode
includeAnswer
Include summary answer
includeRawContent
Include raw page content
days
Recency in days
Exa
type
keyword, neural, or magic
country
Country filter
language
Language filter
Returns
Array of structs with normalized fields:
API keys follow the standard resolution order used in BoxLang AI integrations: constructor/config options, then module settings, then environment variables.
Events Fired
beforeAIWebSearch
Before provider search execution
onAIWebSearchRequest
Right before HTTP request dispatch
onAIWebSearchResponse
After provider HTTP response
afterAIWebSearch
After successful search completion
onAIWebSearchError
On provider/search error
Examples
Default provider
Brave search with filters
Exa neural search
Agent usage
Last updated