> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wip.computer/llms.txt
> Use this file to discover all available pages before exploring further.

# xAI Grok

> xAI Grok API. Search the web, search X, generate images, generate video. All from one tool.

# xAI Grok

Search the web, search X, generate images, generate video. All from one tool.

**Sensor:** search\_web, search\_x ... turns questions into knowledge.
**Actuator:** generate\_image, edit\_image, generate\_video ... turns prompts into media.

Zero dependencies. Four interfaces: CLI, Module, Connection Point, Skill.

## Install

Open your AI and say:

```
Clone wipcomputer/wip-xai-grok and read the README and SKILL.md.
Then explain to me:
1. What is this tool?
2. What does it do?
3. What would it change or fix in our current system?

Then ask me if I have more questions, or if I want you to integrate it into our system.
```

Your AI will read the repo, explain the tool, and walk you through integration interactively.

### API Key

Get your xAI API key from [https://console.x.ai/](https://console.x.ai/)

The tool resolves your key automatically:

1. **1Password** (preferred) ... `op://Agent Secrets/X API/api key`. No env vars needed.
2. **Environment variable** ... `export XAI_API_KEY="your-key"` as a fallback.

## Usage

### CLI

```bash theme={null}
# Search (sensor)
wip-xai-grok search-web "latest AI regulation developments"
wip-xai-grok search-x "what people are saying about OpenAI"
wip-xai-grok search-x "AI thoughts" --handles=elonmusk --from=2026-01-01

# Image generation (actuator)
wip-xai-grok imagine "a cat in space, photorealistic" --output=cat.png
wip-xai-grok imagine "minimalist logo" --aspect=16:9 --n=4

# Image editing (actuator)
wip-xai-grok edit "make the sky purple" --image=photo.jpg --output=edited.jpg

# Video generation (actuator)
wip-xai-grok video "a sunset timelapse over the ocean" --duration=10 --resolution=720p --wait
wip-xai-grok video-status abc123
```

### As a Module

```javascript theme={null}
import { search_web, search_x, generate_image, generate_video, wait_for_video } from '@wipcomputer/wip-xai-grok';

// Sensor: search
const web = await search_web({ query: "UN climate summit" });
console.log(web.content);
console.log(web.citations);

const x = await search_x({
  query: "AI regulation",
  allowed_x_handles: ["elonmusk"],
  from_date: "2026-01-01",
});

// Actuator: generate
const img = await generate_image({ prompt: "a red cube on white", aspect_ratio: "1:1" });
console.log(img.images[0].url);

const vid = await generate_video({ prompt: "spinning globe", duration: 5 });
const result = await wait_for_video({ request_id: vid.request_id });
console.log(result.url);
```

### Connection Point

Add to your `.mcp.json`:

```json theme={null}
{
  "wip-xai-grok": {
    "command": "node",
    "args": ["/path/to/wip-xai-grok/mcp-server.mjs"]
  }
}
```

Exposes 6 tools: grok\_search\_web, grok\_search\_x, grok\_imagine, grok\_edit\_image, grok\_generate\_video, grok\_poll\_video.

## Functions

### Sensor (Search)

| Function     | What                      | Endpoint                              |
| ------------ | ------------------------- | ------------------------------------- |
| `search_web` | Web search via Grok       | POST /v1/responses (web\_search tool) |
| `search_x`   | X/Twitter search via Grok | POST /v1/responses (x\_search tool)   |

### Actuator (Generate)

| Function         | What                 | Endpoint                      | Cost            |
| ---------------- | -------------------- | ----------------------------- | --------------- |
| `generate_image` | Text to image        | POST /v1/images/generations   | \$0.02/image    |
| `edit_image`     | Edit image with text | POST /v1/images/edits         | \$0.022/image   |
| `generate_video` | Text/image to video  | POST /v1/video/generations    | \$0.05-0.07/sec |
| `poll_video`     | Check video status   | GET /v1/video/generations/:id | free            |
| `wait_for_video` | Poll until complete  | (convenience wrapper)         | free            |

## Attribution

Search functions ported from [castanley/grok v1.0.3](https://clawhub.ai/castanley/grok) by Christopher Stanley on ClawHub.

## License

MIT
