# Send xAI Image Generator to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "xai-image-gen",
    "name": "xAI Image Generator",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/mexicanamerican/xai-image-gen",
    "canonicalUrl": "https://clawhub.ai/mexicanamerican/xai-image-gen",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/xai-image-gen",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=xai-image-gen",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "DEPLOYMENT.md",
      "README.md",
      "SKILL.md",
      "SUMMARY.md",
      "requirements.txt",
      "skill.json"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T17:22:31.273Z",
      "expiresAt": "2026-05-14T17:22:31.273Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
        "contentDisposition": "attachment; filename=\"afrexai-annual-report-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/xai-image-gen"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/xai-image-gen",
    "downloadUrl": "https://openagent3.xyz/downloads/xai-image-gen",
    "agentUrl": "https://openagent3.xyz/skills/xai-image-gen/agent",
    "manifestUrl": "https://openagent3.xyz/skills/xai-image-gen/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/xai-image-gen/agent.md"
  }
}
```
## Documentation

### xai-image-gen

Generate images using xAI's Grok API (grok-imagine-image model).

### Description

Production-ready CLI tool for generating images via xAI's image generation API. Supports multiple output formats, resolutions, and batch generation. Automatically outputs MEDIA: paths for OpenClaw auto-attachment.

Features:

🎨 Simple CLI interface: xai-gen "<prompt>"
🖼️ Multiple output formats: URL download, base64 encoding
🔢 Batch generation (multiple images per prompt)
⚡ Fast, pure API implementation (Pi-safe)
🛡️ Robust error handling with user-friendly messages
📎 Auto-attaches generated images in OpenClaw
🎯 Uses xAI's native resolution (no size parameter needed)

### Installation

# Navigate to skills directory
cd ~/.openclaw/workspace/skills

# Clone or copy this skill
# (or install via clawhub when published)

# Install dependencies
pip3 install requests

# Ensure the script is executable
chmod +x xai-image-gen/xai-gen

Set your xAI API key:

export XAI_API_KEY="your-api-key-here"

Add to your shell profile (~/.bashrc, ~/.zshrc) to persist:

echo 'export XAI_API_KEY="your-api-key-here"' >> ~/.bashrc

### Basic Usage

# Generate with simple prompt
xai-gen "sunset over mountains"

# Custom filename
xai-gen "cyberpunk city" --filename city.png

# Generate multiple images
xai-gen "futuristic vehicle" --n 3

# Base64 output (no download)
xai-gen "logo design" --format b64

# Verbose mode
xai-gen "space station" --verbose

### Options

positional arguments:
  prompt                Text description of the image to generate

options:
  -h, --help            Show help message
  --model MODEL         Model name (default: grok-imagine-image)
  --filename FILENAME   Output filename (default: out.png)
  --format {url,png,b64}
                        Response format: url (download), png (alias), b64 (base64)
  --n N                 Number of images to generate (default: 1)
  --verbose, -v         Show detailed progress

### Examples

Generate a meme:

xai-gen "dumbest trade meme: YOLO panic fail" --filename trade_meme.png

Batch generation:

xai-gen "logo variations for tech startup" --n 5
# Outputs: out_1.png, out_2.png, out_3.png, out_4.png, out_5.png

High-quality artwork:

xai-gen "photorealistic portrait of a cat astronaut" --filename cat_astronaut.png

### Integration with OpenClaw

The tool outputs MEDIA: /path/to/image.png which OpenClaw automatically detects and attaches to messages. Use in agent workflows:

# In an agent skill or automation
xai-gen "chart showing Q1 sales data" --filename sales_chart.png
# → Image auto-attaches to response

### API Details

Endpoint: https://api.x.ai/v1/images/generations
Model: grok-imagine-image
Authentication: Bearer token via XAI_API_KEY
Rate Limits: Subject to xAI API limits (check xAI docs)
Timeout: 60s for generation, 30s for download

### Error Handling

The tool handles common errors gracefully:

❌ Missing API key → Clear instructions
❌ Network errors → Descriptive messages
❌ API timeouts → Retry suggestions
❌ Invalid parameters → Usage hints
❌ File write errors → Permission checks

### Requirements

Python: 3.7+
Dependencies: requests
API Key: xAI API key (get from https://console.x.ai)
Network: Internet connection required

### Platform Compatibility

✅ Linux (tested on Raspberry Pi)
✅ macOS
✅ Windows (via WSL or native Python)
✅ ARM64 / ARMv7 (Pi-safe, pure API calls)

### Troubleshooting

"XAI_API_KEY not found"

export XAI_API_KEY="xai-..."

"requests library not found"

pip3 install requests

Permission denied

chmod +x xai-gen

API errors

Check API key validity
Verify account has credits
Check xAI status page

### License

MIT License - Free to use and modify

### Author

Built for OpenClaw by subagent xAI Image Gen Skill Builder

### Version

1.0.0 - Initial release
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: mexicanamerican
- Version: 1.0.0
## Source health
- Status: healthy
- Source download looks usable.
- Yavira can redirect you to the upstream package for this source.
- Health scope: source
- Reason: direct_download_ok
- Checked at: 2026-05-07T17:22:31.273Z
- Expires at: 2026-05-14T17:22:31.273Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/xai-image-gen)
- [Send to Agent page](https://openagent3.xyz/skills/xai-image-gen/agent)
- [JSON manifest](https://openagent3.xyz/skills/xai-image-gen/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/xai-image-gen/agent.md)
- [Download page](https://openagent3.xyz/downloads/xai-image-gen)