名称: xai-search
描述: 使用 xAI 的 Grok API 及其智能搜索工具,实时搜索 X/Twitter 和网络信息。
元数据: {"clawdbot":{"emoji":"🔍"}}
利用 xAI 的智能搜索功能,实时查询 X/Twitter 和网络信息。此功能基于 Grok 的 web_search 和 x_search 工具实现。
官方文档: https://docs.x.ai/docs/
XAI_API_KEYpip install xai-sdkcurl -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": "在此输入您的查询"}],
"tools": [{"type": "function", "function": {"name": "web_search"}}]
}' | jq -r '.choices[0].message.content'
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": "在此输入您的查询"}],
"tools": [{"type": "function", "function": {"name": "x_search"}}]
}' | jq -r '.choices[0].message.content'
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": "在此输入您的查询"}],
"tools": [
{"type": "function", "function": {"name": "web_search"}},
{"type": "function", "function": {"name": "x_search"}}
]
}' | jq -r '.choices[0].message.content'
为方便使用,可调用 scripts/ 目录下的 xai-search.py 脚本:
# 网络搜索(请根据技能安装路径调整)
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py web "关于 AI 的最新消息"
# X/Twitter 搜索
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py x "人们如何评价 Clawdbot"
# 组合搜索
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py both "今日时事"
grok-3-fast — 响应迅速,适合快速搜索grok-4-1-fast — 推理模型,适合处理复杂查询X 搜索支持以下过滤选项:
- allowed_x_handles / excluded_x_handles — 限定或排除特定账号
- from_date / to_date — 日期范围(ISO8601 格式)
- enable_image_understanding — 分析帖子中的图片
- enable_video_understanding — 分析帖子中的视频
allowed_domains / excluded_domains — 限定或排除特定网站enable_image_understanding — 分析网页中的图片