π¦ ClawHub
xAI Grok Search
by @castanley
Search the web and X (Twitter) using xAI's Grok API with real-time access, citations, and image understanding
π‘ Examples
Web Search - Current Events
const result = await search_web({
query: "latest AI regulation developments"
});
Web Search - Specific Domains
const result = await search_web({
query: "UN climate summit latest",
allowed_domains: ["un.org", "gov.uk", "grokipedia.com"]
});
X Search - Social Sentiment
const result = await search_x({
query: "new iPhone reactions opinions"
});
X Search - Specific Handles
const result = await search_x({
query: "AI thoughts",
allowed_x_handles: ["elonmusk", "cstanley"],
from_date: "2025-01-01"
});
X Search - With Media
const result = await search_x({
query: "Mars landing images",
enable_image_understanding: true,
enable_video_understanding: true
});
βοΈ Configuration
Required Environment Variables
export XAI_API_KEY="your-xai-api-key-here"
Get your API key from: https://console.x.ai/
π Tips & Best Practices
Web Search
allowed_domains to limit to specific domains (max 5)excluded_domains for known bad sources (max 5)X Search
allowed_x_handles to focus on specific accounts (max 10)excluded_x_handles to filter noise (max 10)TERMINAL
clawhub install grok