OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  xai-search:利用 xAI 的 Grok API 实时检索 X/Twitter 与网页信息

xai-search:利用 xAI 的 Grok API 实时检索 X/Twitter 与网页信息

 
  saas ·  2026-02-18 16:13:54 · 3 次点击  · 0 条评论  

名称: xai-search
描述: 使用 xAI 的 Grok API 及其智能搜索工具,实时搜索 X/Twitter 和网络信息。
元数据: {"clawdbot":{"emoji":"🔍"}}


xAI 搜索 (Grok API)

利用 xAI 的智能搜索功能,实时查询 X/Twitter 和网络信息。此功能基于 Grok 的 web_searchx_search 工具实现。

官方文档: https://docs.x.ai/docs/

环境要求

  • 设置环境变量 XAI_API_KEY
  • Python 3 及 xai-sdk 库:pip install xai-sdk

快速使用 (curl)

网络搜索

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"}}]
  }' | jq -r '.choices[0].message.content'

X/Twitter 搜索

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'

组合搜索 (网络 + 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": "在此输入您的查询"}],
    "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 搜索过滤器

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 — 分析网页中的图片

使用建议

  • 突发新闻:使用 X 搜索
  • 事实查询/研究:使用网络搜索或组合搜索
  • 情绪/观点分析:使用 X 搜索
  • 模型会根据需要自动发起多次搜索调用(智能代理模式)
3 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor