Loading...
Loading...
AI-powered X/Twitter research via xAI Grok. Returns AI SUMMARIES with analysis, not raw tweets. Use for "what's trending", "social sentiment", "summarize X discussion about", "analyze X conversation about", "research topic on X". For RAW tweet data, use x-user-timeline, x-tweet-search, x-tweet-fetch instead. Requires XAI_API_KEY.
npx skill4agent add b-open-io/prompts x-researchWant raw tweets instead? Use these skills:
- Raw tweets from a userx-user-timeline - Raw search resultsx-tweet-search - Raw single tweetx-tweet-fetch - User profile datax-user-lookupThese requireinstead ofX_BEARER_TOKEN.XAI_API_KEY
if [ -z "$XAI_API_KEY" ]; then
echo "ERROR: XAI_API_KEY is not set"
echo "1. Get API key from https://x.ai/api"
echo "2. Add to profile: export XAI_API_KEY=\"your-key\""
echo "3. Restart terminal and Claude Code"
exit 1
else
echo "XAI_API_KEY is configured"
fihttps://api.x.ai/v1/responsesgrok-4-1-fastgrok-4-1-fastgrok-4-1-fast-reasoninggrok-4-1-fast-non-reasoningweb_searchx_searchcurl -s "https://api.x.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "grok-4-1-fast",
"input": [{"role": "user", "content": "[YOUR QUERY]"}],
"tools": [{"type": "web_search"}, {"type": "x_search"}]
}' | jq -r '.output[-1].content[0].text'RESPONSE=$(curl -s "https://api.x.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "grok-4-1-fast",
"input": [{"role": "user", "content": "[YOUR QUERY]"}],
"tools": [{"type": "web_search"}, {"type": "x_search"}]
}')
# Extract usage stats
TOOL_CALLS=$(echo "$RESPONSE" | jq -r '.usage.num_server_side_tools_used // 0')
COST_TICKS=$(echo "$RESPONSE" | jq -r '.usage.cost_in_usd_ticks // 0')
COST_USD=$(echo "scale=4; $COST_TICKS / 1000000000" | bc)
echo "Tool calls: $TOOL_CALLS | Estimated cost: \$$COST_USD"
echo ""
echo "$RESPONSE" | jq -r '.output[-1].content[0].text'"tools": [{
"type": "web_search",
"allowed_domains": ["github.com", "stackoverflow.com"],
"excluded_domains": ["pinterest.com"],
"enable_image_understanding": true
}]allowed_domainsexcluded_domainsenable_image_understanding"tools": [{
"type": "x_search",
"allowed_x_handles": ["elikimonimus", "anthropaboris"],
"excluded_x_handles": ["spambot"],
"from_date": "2025-01-01",
"to_date": "2025-01-16",
"enable_image_understanding": true,
"enable_video_understanding": true
}]allowed_x_handlesexcluded_x_handlesfrom_dateto_dateenable_image_understandingenable_video_understandingcurl -s "https://api.x.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "grok-4-1-fast",
"input": [{"role": "user", "content": "What is currently trending on X? Include viral posts and major discussions."}],
"tools": [{"type": "x_search"}]
}' | jq -r '.output[-1].content[0].text'curl -s "https://api.x.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "grok-4-1-fast",
"input": [{"role": "user", "content": "What are developers saying about [TOPIC] on X? Include recent discussions and opinions."}],
"tools": [{"type": "x_search"}, {"type": "web_search"}]
}' | jq -r '.output[-1].content[0].text'curl -s "https://api.x.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "grok-4-1-fast",
"input": [{"role": "user", "content": "Latest news and developments about [TOPIC]"}],
"tools": [{"type": "web_search"}]
}' | jq -r '.output[-1].content[0].text'curl -s "https://api.x.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "grok-4-1-fast",
"input": [{"role": "user", "content": "What happened with [TOPIC] last week?"}],
"tools": [{
"type": "x_search",
"from_date": "2025-01-09",
"to_date": "2025-01-16"
}, {
"type": "web_search"
}]
}' | jq -r '.output[-1].content[0].text'{
"output": [
{"type": "web_search_call", "status": "completed", ...},
{"type": "custom_tool_call", "name": "x_semantic_search", ...},
{
"type": "message",
"content": [{
"type": "output_text",
"text": "The actual response with [[1]](url) inline citations",
"annotations": [{"type": "url_citation", "url": "...", ...}]
}]
}
],
"citations": ["url1", "url2", ...],
"usage": {
"input_tokens": 11408,
"output_tokens": 2846,
"num_server_side_tools_used": 8,
"cost_in_usd_ticks": 429052500
}
}jq -r '.output[-1].content[0].text'jq -r '.citations[]'response.usage.cost_in_usd_ticksgrok-4-1-fasttools"Internal error"search_parameters{
"model": "grok-4-latest",
"messages": [...],
"search_parameters": {"mode": "on"}
}{
"model": "grok-4-1-fast",
"input": [...],
"tools": [{"type": "web_search"}, {"type": "x_search"}]
}