π¦ ClawHub
xAI Search
by @aydencook03
Search X/Twitter and the web in real-time using xAI's Grok API with agentic search tools.
TERMINAL
clawhub install xai-searchπ About This Skill
name: xai-search description: Search X/Twitter and the web in real-time using xAI's Grok API with agentic search tools. metadata: {"clawdbot":{"emoji":"π"}}
xAI Search (Grok API)
Use xAI's agentic search to query X/Twitter and the web in real-time. This leverages Grok's web_search and x_search tools.
Docs: https://docs.x.ai/docs/
Requirements
XAI_API_KEY environment variablepip install xai-sdkQuick Usage (curl)
Web Search
curl -s https://api.x.ai/v1/chat/completions \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-3-fast",
"messages": [{"role": "user", "content": "YOUR QUERY HERE"}],
"tools": [{"type": "function", "function": {"name": "web_search"}}]
}' | jq -r '.choices[0].message.content'
X/Twitter Search
curl -s https://api.x.ai/v1/chat/completions \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-3-fast",
"messages": [{"role": "user", "content": "YOUR QUERY HERE"}],
"tools": [{"type": "function", "function": {"name": "x_search"}}]
}' | jq -r '.choices[0].message.content'
Combined (Web + X)
curl -s https://api.x.ai/v1/chat/completions \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-3-fast",
"messages": [{"role": "user", "content": "YOUR QUERY HERE"}],
"tools": [
{"type": "function", "function": {"name": "web_search"}},
{"type": "function", "function": {"name": "x_search"}}
]
}' | jq -r '.choices[0].message.content'
Helper Script
For convenience, use the xai-search.py script in the scripts/ folder:
# Web search (adjust path to your skill location)
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py web "latest news about AI"X/Twitter search
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py x "what are people saying about Clawdbot"Both
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py both "current events today"
Models
grok-3-fast β fast, good for quick searchesgrok-4-1-fast β reasoning model, better for complex queriesX Search Filters
You can filter X searches by:
allowed_x_handles / excluded_x_handles β limit to specific accountsfrom_date / to_date β date range (ISO8601 format)enable_image_understanding β analyze images in postsenable_video_understanding β analyze videos in postsWeb Search Filters
allowed_domains / excluded_domains β limit to specific sitesenable_image_understanding β analyze images on pages