Back to skills
SkillHub ClubShip Full StackFull StackBackend

xai-search

Search X/Twitter and the web in real-time using xAI's Grok API with agentic search tools.

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
3,131
Hot score
99
Updated
March 20, 2026
Overall rating
C0.0
Composite score
0.0
Best-practice grade
B81.2

Install command

npx @skill-hub/cli install openclaw-skills-xai-search

Repository

openclaw/skills

Skill path: skills/aydencook03/xai-search

Search X/Twitter and the web in real-time using xAI's Grok API with agentic search tools.

Open repository

Best for

Primary workflow: Ship Full Stack.

Technical facets: Full Stack, Backend.

Target audience: everyone.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: openclaw.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install xai-search into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/openclaw/skills before adding xai-search to shared team environments
  • Use xai-search for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: xai-search
description: Search X/Twitter and the web in real-time using xAI's Grok API with agentic search tools.
metadata: {"clawdbot":{"emoji":"πŸ”"}}
---

# xAI Search (Grok API)

Use xAI's agentic search to query X/Twitter and the web in real-time. This leverages Grok's `web_search` and `x_search` tools.

**Docs:** https://docs.x.ai/docs/

## Requirements

- `XAI_API_KEY` environment variable
- Python 3 + xai-sdk: `pip install xai-sdk`

## Quick Usage (curl)

### Web Search
```bash
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 Search
```bash
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'
```

### Combined (Web + X)
```bash
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'
```

## Helper Script

For convenience, use the `xai-search.py` script in the `scripts/` folder:

```bash
# 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"
```

## Models

- `grok-3-fast` β€” fast, good for quick searches
- `grok-4-1-fast` β€” reasoning model, better for complex queries

## X Search Filters

You can filter X searches by:
- `allowed_x_handles` / `excluded_x_handles` β€” limit to specific accounts
- `from_date` / `to_date` β€” date range (ISO8601 format)
- `enable_image_understanding` β€” analyze images in posts
- `enable_video_understanding` β€” analyze videos in posts

## Web Search Filters

- `allowed_domains` / `excluded_domains` β€” limit to specific sites
- `enable_image_understanding` β€” analyze images on pages

## Tips

- For breaking news: use X search
- For factual/research queries: use web search or both
- For sentiment/opinions: use X search
- The model will make multiple search calls if needed (agentic)


---

## Skill Companion Files

> Additional files collected from the skill directory layout.

### _meta.json

```json
{
  "owner": "aydencook03",
  "slug": "xai-search",
  "displayName": "xAI Search",
  "latest": {
    "version": "1.0.4",
    "publishedAt": 1769575005647,
    "commit": "https://github.com/clawdbot/skills/commit/40e4c18b008d3c97b2347f98f0a59a9f51381a69"
  },
  "history": [
    {
      "version": "1.0.1",
      "publishedAt": 1769555809505,
      "commit": "https://github.com/clawdbot/skills/commit/85b58987f202a17a09fce79ceec3d84cfcc691a1"
    }
  ]
}

```

### scripts/xai-search.py

```python
#!/usr/bin/env python3
"""xai-search - Search X/Twitter and web using xAI's agentic search."""

import sys
import os

def main():
    if len(sys.argv) < 3:
        print("Usage: xai-search <web|x|both> \"query\"")
        print("  web  - Search the web only")
        print("  x    - Search X/Twitter only")
        print("  both - Search both web and X")
        sys.exit(1)
    
    # Try to import xai_sdk
    try:
        from xai_sdk import Client
        from xai_sdk.chat import user
        from xai_sdk.tools import web_search, x_search
    except ImportError:
        print("Error: xai-sdk not installed.")
        print("Install it with: pip install xai-sdk")
        sys.exit(1)
    
    mode = sys.argv[1]
    query = " ".join(sys.argv[2:])
    
    api_key = os.environ.get("XAI_API_KEY")
    if not api_key:
        print("Error: XAI_API_KEY not set")
        sys.exit(1)
    
    tools = []
    if mode in ("web", "both"):
        tools.append(web_search())
    if mode in ("x", "both"):
        tools.append(x_search())
    
    if not tools:
        print(f"Unknown mode: {mode} (use web, x, or both)")
        sys.exit(1)
    
    client = Client(api_key=api_key)
    chat = client.chat.create(
        model="grok-4-1-fast",  # grok-4 required for server-side tools
        tools=tools,
    )
    
    chat.append(user(query))
    
    # Stream and collect response
    full_response = ""
    for response, chunk in chat.stream():
        if chunk.content:
            full_response += chunk.content
            print(chunk.content, end="", flush=True)
    
    print()  # newline at end
    
    # Print citations if any
    if response.citations:
        print("\n--- Sources ---")
        for i, url in enumerate(response.citations[:5], 1):
            print(f"[{i}] {url}")

if __name__ == "__main__":
    main()

```

xai-search | SkillHub