x-research by b-open-io/prompts
npx skills add https://github.com/b-open-io/prompts --skill x-research使用 xAI 的 Grok API 进行 AI 驱动的搜索研究。返回 带有引用的 AI 摘要,而非原始推文数据。
想要原始推文? 请使用这些技能:
x-user-timeline- 来自用户的原始推文x-tweet-search- 原始搜索结果x-tweet-fetch- 原始单条推文x-user-lookup- 用户资料数据
这些技能需要
X_BEARER_TOKEN而非XAI_API_KEY。
此技能适用于:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
不适用于:
检查 API 密钥是否已设置:
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"
fi
如果未设置,请告知用户在使用此技能前必须先配置 XAI_API_KEY。
端点:https://api.x.ai/v1/responses
推荐模型:grok-4-1-fast(专门为智能体搜索训练)
可用模型:
grok-4-1-fast - 推荐用于智能体搜索(自动选择推理模式)grok-4-1-fast-reasoning - 针对复杂研究的显式推理grok-4-1-fast-non-reasoning - 响应更快,适用于简单查询可用搜索工具:
web_search - 搜索互联网并浏览网页x_search - 对 X 帖子进行语义和关键词搜索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"}]
}' | 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_domains - 仅限这些域名(最多 5 个)excluded_domains - 排除这些域名(最多 5 个)enable_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_handles - 仅包含来自这些账户的帖子(最多 10 个)excluded_x_handles - 排除来自这些账户的帖子(最多 10 个)from_date / to_date - ISO8601 日期范围 (YYYY-MM-DD)enable_image_understanding - 分析帖子中的图片enable_video_understanding - 分析帖子中的视频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 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_ticks 跟踪成本(除以 1,000,000,000 得到美元)。
如果 API 返回错误:
XAI_API_KEY 是否已设置且有效grok-4-1-fast)tools 数组格式正确常见错误:
"Internal error" - 通常是错误的模型名称或格式错误的请求已弃用(2026年1月12日):使用 search_parameters 的旧版实时搜索 API 正在被弃用。本技能使用新的智能体工具调用 API,该 API 速度更快、能力更强。
旧格式(已弃用):
{
"model": "grok-4-latest",
"messages": [...],
"search_parameters": {"mode": "on"}
}
新格式(请使用此格式):
{
"model": "grok-4-1-fast",
"input": [...],
"tools": [{"type": "web_search"}, {"type": "x_search"}]
}
每周安装次数
68
代码仓库
GitHub 星标数
7
首次出现
2026年1月24日
安全审计
安装于
opencode52
claude-code49
cursor49
gemini-cli48
codex45
github-copilot40
AI-powered research using xAI's Grok API. Returns AI summaries with citations , not raw tweet data.
Want raw tweets instead? Use these skills:
x-user-timeline- Raw tweets from a userx-tweet-search- Raw search resultsx-tweet-fetch- Raw single tweetx-user-lookup- User profile data
These require
X_BEARER_TOKENinstead ofXAI_API_KEY.
USE THIS SKILL FOR:
DON'T USE FOR:
Check if the API key is set:
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"
fi
If unavailable, inform the user that XAI_API_KEY must be configured before using this skill.
Endpoint : https://api.x.ai/v1/responses
Recommended Model : grok-4-1-fast (specifically trained for agentic search)
Available Models :
grok-4-1-fast - Recommended for agentic search (auto-selects reasoning mode)grok-4-1-fast-reasoning - Explicit reasoning for complex researchgrok-4-1-fast-non-reasoning - Faster responses, simpler queriesAvailable Search Tools :
web_search - Searches the internet and browses web pagesx_search - Semantic and keyword search across X postscurl -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_domains - Restrict to these domains only (max 5)excluded_domains - Exclude these domains (max 5)enable_image_understanding - Analyze images found during search"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_handles - Only include posts from these accounts (max 10)excluded_x_handles - Exclude posts from these accounts (max 10)from_date / to_date - ISO8601 date range (YYYY-MM-DD)enable_image_understanding - Analyze images in postsenable_video_understanding - Analyze videos in postscurl -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'
The response contains:
{
"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
}
}
Extracting content : jq -r '.output[-1].content[0].text'
Extracting citations : jq -r '.citations[]'
Search tools are currently FREE (promotional pricing).
Standard pricing when active:
Track costs via response.usage.cost_in_usd_ticks (divide by 1,000,000,000 for USD).
If the API returns an error:
grok-4-1-fast)tools array is properly formattedCommon errors:
"Internal error" - Usually wrong model name or malformed requestDEPRECATED (January 12, 2026) : The old Live Search API using search_parameters is being deprecated. This skill uses the new agentic tool calling API which is faster and more capable.
Old format (deprecated):
{
"model": "grok-4-latest",
"messages": [...],
"search_parameters": {"mode": "on"}
}
New format (use this):
{
"model": "grok-4-1-fast",
"input": [...],
"tools": [{"type": "web_search"}, {"type": "x_search"}]
}
Weekly Installs
68
Repository
GitHub Stars
7
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode52
claude-code49
cursor49
gemini-cli48
codex45
github-copilot40
AI 代码实施计划编写技能 | 自动化开发任务分解与 TDD 流程规划工具
50,900 周安装