格罗克
- 作者仓库星标 0
- 作者仓库 nano-core
- 领域
- 通用
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @0-CYBERDYNE-SYSTEMS-0 · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 需要 · Vendor-specific
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# xAI Grok Search
## When not to use this skill
- Do not use when another skill is a better direct match for the task.
- Do not use when the request is outside this skill's scope.
Search the web and X (Twitter) using xAI's Grok API with real-time internet access, citations, and optional image/video understanding.
## When to Use This Skill
### Use Web Search For:
- Current information from websites, news articles, documentation
- Real-time data (stock prices, weather, recent events)
- Research topics with up-to-date web sources
- Finding information from specific websites/domains
- Verifying current facts
### Use X Search For:
- What people are saying on X/Twitter about a topic
- Trending discussions and social sentiment
- Real-time reactions to events
- Posts from specific X handles/users
- Recent social media activity within date ranges
**Do NOT use for:**
- Historical facts that won't change
- General knowledge already available
- Mathematical calculations
- Code generation
- Creative writing
## Setup
### Required Environment Variables
```bash
export XAI_API_KEY="your-xai-api-key-here"
```
Get your API key from: https://console.x.ai/
## Usage
The agent will automatically choose the right tool based on the user's query:
**User:** "What's the latest news about AI regulation?"
→ Uses `web_search`
**User:** "What are people saying about OpenAI on X?"
→ Uses `x_search`
## API Reference
### Function: search_web
Search the web using xAI's Grok API.
**Parameters:**
- `query` (required): Search query string
- `model` (optional): Model to use (default: "grok-4-1-fast-reasoning")
- `allowed_domains` (optional): Array of domains to restrict search (max 5)
- `excluded_domains` (optional): Array of domains to exclude (max 5)
- `enable_image_understanding` (optional): Enable image analysis (default: false)
**Returns:**
- `content`: The search response text
- `citations`: Array of sources with url, title, and snippet
- `usage`: Token usage statistics
### Function: search_x
Search X (Twitter) using xAI's Grok API.
**Parameters:**
- `query` (required): Search query string
- `model` (optional): Model to use (default: "grok-4-1-fast-reasoning")
- `allowed_x_handles` (optional): Array of X handles to search (max 10, without @)
- `excluded_x_handles` (optional): Array of X handles to exclude (max 10, without @)
- `from_date` (optional): Start date in ISO8601 format (YYYY-MM-DD)
- `to_date` (optional): End date in ISO8601 format (YYYY-MM-DD)
- `enable_image_understanding` (optional): Enable image analysis (default: false)
- `enable_video_understanding` (optional): Enable video analysis (default: false)
**Returns:**
- `content`: The search response text
- `citations`: Array of X posts with url, title, and snippet
- `usage`: Token usage statistics
## Implementation
This skill uses the xAI Responses API (`/v1/responses` endpoint).
### Web Search
```javascript
async function search_web(options) {
const { query, model = 'grok-4-1-fast-reasoning',
allowed_domains, excluded_domains, enable_image_understanding } = options;
const tool = { type: 'web_search' };
if (allowed_domains) tool.allowed_domains = allowed_domains;
if (excluded_domains) tool.excluded_domains = excluded_domains;
if (enable_image_understanding) tool.enable_image_understanding = true;
const response = await fetch('https://api.x.ai/v1/responses', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.XAI_API_KEY}`
},
body: JSON.stringify({
model,
input: [{ role: 'user', content: query }],
tools: [tool]
})
});
const data = await response.json();
return {
content: data.output[data.output.length - 1].content,
citations: data.citations
};
}
```
### X Search
```javascript
async function search_x(options) {
const { query, model = 'grok-4-1-fast-reasoning',
allowed_x_handles, excluded_x_handles, from_date, to_date,
enable_image_understanding, enable_video_understanding } = options;
const tool = { type: 'x_search' };
if (allowed_x_handles) tool.allowed_x_handles = allowed_x_handles;
if (excluded_x_handles) tool.excluded_x_handles = excluded_x_handles;
if (from_date) tool.from_date = from_date;
if (to_date) tool.to_date = to_date;
if (enable_image_understanding) tool.enable_image_understanding = true;
if (enable_video_understanding) tool.enable_video_understanding = true;
const response = await fetch('https://api.x.ai/v1/responses', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.XAI_API_KEY}`
},
body: JSON.stringify({
model,
input: [{ role: 'user', content: query }],
tools: [tool]
})
});
const data = await response.json();
return {
content: data.output[data.output.length - 1].content,
citations: data.citations
};
}
```
## Examples
### Web Search - Current Events
```javascript
const result = await search_web({
query: "latest AI regulation developments"
});
```
### Web Search - Specific Domains
```javascript
const result = await search_web({
query: "UN climate summit latest",
allowed_domains: ["un.org", "gov.uk", "grokipedia.com"]
});
```
### X Search - Social Sentiment
```javascript
const result = await search_x({
query: "new iPhone reactions opinions"
});
```
### X Search - Specific Handles
```javascript
const result = await search_x({
query: "AI thoughts",
allowed_x_handles: ["elonmusk", "cstanley"],
from_date: "2025-01-01"
});
```
### X Search - With Media
```javascript
const result = await search_x({
query: "Mars landing images",
enable_image_understanding: true,
enable_video_understanding: true
});
```
## Best Practices
### Web Search
- Use `allowed_domains` to limit to specific domains (max 5)
- Use `excluded_domains` for known bad sources (max 5)
- Cannot use both at same time
- Enable image understanding only when needed
### X Search
- Use `allowed_x_handles` to focus on specific accounts (max 10)
- Use `excluded_x_handles` to filter noise (max 10)
- Cannot use both at same time
- Don't include @ symbol in handles
- Use ISO8601 date format: YYYY-MM-DD
- Media understanding adds API costs
## Troubleshooting
### "XAI_API_KEY not found"
```bash
export XAI_API_KEY="your-key-here"
```
### Rate Limiting
- Implement exponential backoff
- Cache frequent queries
### Poor Results
- Add domain/handle filters
- Make queries more specific
- Narrow date ranges
### Slow Responses
Search queries using reasoning models (e.g. `grok-4-1-fast-reasoning`) can take 30-60+ seconds to return, especially when the model performs multiple web or X searches. If the search is lagging, inform the user that results are still loading and ask them to type **"poll"** to check for the completed response.
## API Documentation
- Web Search: https://docs.x.ai/developers/tools/web-search
- X Search: https://docs.x.ai/developers/tools/x-search
章节与文件索引
按说明文件中的顺序排列。
什么时候不应该使用这个技能
使用网络搜索:
使用 X 搜索:
用途
功能:搜索网页
文件/命令 -> web_search · x_search · query · model · allowed_domains · excluded_domains · enable_image_understanding · content
内容校验值 -> 8935b226e04d
当前原文的自动摘译,尚未人工审校。
什么时候不应该使用这个技能
当其他技能更适合该任务时,请勿使用。当请求超出该技能的范围时请勿使用。使用 xAI 的 Grok API 搜索网络和 X (Twitter),并具有实时互联网访问、引文和可选的图像/视频理解功能。
使用网络搜索:
来自网站、新闻文章、文档的当前信息 实时数据(股票价格、天气、最近发生的事件) 使用最新网络资源研究主题 从特定网站/域查找信息 验证当前事实
使用 X 搜索:
人们在 X/Twitter 上就某个主题发表的言论 热门讨论和社会情绪 对事件的实时反应 来自特定 X 处理者/用户的帖子 日期范围内最近的社交媒体活动
用途
代理会根据用户的查询自动选择合适的工具: 用户:“人工智能监管的最新消息是什么?” → 使用
web_search用户:“人们对 X 上的 OpenAI 有什么看法?” → 使用x_search功能:搜索网页
使用 xAI 的 Grok API 搜索网络。参数:
query(必需):搜索查询字符串model(可选):要使用的模型(默认:“grok-4-1-fast-reasoning”)allowed_domains(可选):限制搜索的域数组(最多 5 个)