网淘吧来吧,欢迎您!

xAI Search技能使用说明

2026-03-29 新闻来源:网淘吧 围观:6
电脑广告
手机广告

xAI 搜索 (Grok API)

使用 xAI 的代理搜索功能,实时查询 X/Twitter 和网络。这利用了 Grok 的web_searchx_search工具。

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

xAI Search

要求

  • 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": "YOUR QUERY HERE"}],
    "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": "YOUR QUERY HERE"}],
    "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": "YOUR QUERY HERE"}],
    "tools": [
      {"type": "function", "function": {"name": "web_search"}},
      {"type": "function", "function": {"name": "x_search"}}
    ]
  }' | jq -r '.choices[0].message.content'

辅助脚本

为方便起见,请使用xai-search.py脚本,该脚本位于scripts/文件夹中:

# Web search (adjust path to your skill location)
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py web "latest news about AI"

# X/Twitter search  
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py x "what are people saying about Clawdbot"

# Both
python ~/.clawdbot/skills/xai-search/scripts/xai-search.py both "current events today"

模型

  • grok-3-fast——快速,适合快速搜索
  • grok-4-1-快速版——推理模型,更适合复杂查询

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搜索
  • 模型将在需要时进行多次搜索调用(自主代理)

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏
文章底部电脑广告
手机广告位-内容正文底部

相关文章

您是本站第326239名访客 今日有220篇新文章/评论