xAI Imagine
Use xAI's Grok Imagine API to generate images based on text prompts.
Quick Start
To generate an image, use the scripts/generate.js script. It handles the API call and returns the image URL.
Triggers
- "xai 畫..."
- "imagine [prompt]"
- "用 grok 畫一個..."
Aspect Ratios
Supported ratios: "1:1", "3:4", "4:3", "9:16", "16:9", "2:3", "3:2", "9:19.5", "19.5:9", "9:20", "20:9", "1:2", "2:1", "auto".
Usage Example
需先設定
XAI_API_KEY:
- 建議在環境變數中設
XAI_API_KEY- 或放在
~/.openclaw/.env(格式:XAI_API_KEY=...)
# Generate a 16:9 image
node scripts/generate.js --prompt "A futuristic neon city with a black cat" --ratio "16:9"
# Equivalent (equals style)
node scripts/generate.js --prompt="A futuristic neon city with a black cat" --ratio="16:9"
Workflow
- Identify the prompt and desired aspect ratio (default is 1:1).
- Execute
scripts/generate.jswith the--promptand optional--ratio. - The script will output a JSON with the image URL.
- Use the
messagetool to deliver the image to the user.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.