Generate images from text prompts using xAI's Grok API with options for format, batch size, and automatic media attachment in OpenClaw.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install xai-image-gen或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install xai-image-gen⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/xai-image-gen/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
Generate images using xAI's Grok API (grok-imagine-image model).
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:
xai-gen "" # 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
# 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
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
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
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
https://api.x.ai/v1/images/generationsgrok-imagine-imageXAI_API_KEYThe tool handles common errors gracefully:
requests"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
MIT License - Free to use and modify
Built for OpenClaw by subagent xAI Image Gen Skill Builder
1.0.0 - Initial release
安装 xAI Image Generator 后,可以对 AI 说这些话来触发它
Help me get started with xAI Image Generator
Explains what xAI Image Generator does, walks through the setup, and runs a quick demo based on your current project
Use xAI Image Generator to generate images from text prompts using xAI's Grok API with options...
Invokes xAI Image Generator with the right parameters and returns the result directly in the conversation
What can I do with xAI Image Generator in my design & creative workflow?
Lists the top use cases for xAI Image Generator, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/xai-image-gen/ 目录(个人级,所有项目可用),或 .claude/skills/xai-image-gen/(项目级)。重启 AI 客户端后,用 /xai-image-gen 主动调用,或让 AI 根据上下文自动发现并使用。
xAI Image Generator 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
xAI Image Generator 可免费安装使用。请查阅仓库了解许可证信息。
Generate images from text prompts using xAI's Grok API with options for format, batch size, and automatic media attachment in OpenClaw.
xAI Image Generator 属于「Design & Creative」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my design & creative tasks using xAI Image Generator
Identifies repetitive steps in your workflow and sets up xAI Image Generator to handle them automatically