Grok imagine
Generate images and videos with xAI Grok Imagine from any coding agent. Supports text-to-image, image edit, image-to-video, and text-to-video via a stdlib Python CLI. Auth with XAI_API_KEY or `grok login`. Use when the user says "grok imagine", "grok image", "grok video", "xAI image", "Imagine API", "/grok-imagine", or asks to generate/edit image or video with Grok.From its SKILL.md
npx -y skills add heslanx/grok-imagine --skill grok-imagineAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
4.2 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Grok Imagine — Image & Video for Agents
GitHub · Install · API map · vs GPT Image 2
Generate images and videos with Grok Imagine (xAI) from Claude Code, Cursor, Codex, Grok Build, or a plain shell.
Auth (first match wins):
XAI_API_KEYGROK_API_KEY- OIDC token from
grok login(~/.grok/auth.json→key)
Only endpoints validated live are implemented — see docs/API.md.
When to trigger
- "grok imagine" / "grok image" / "grok video" / "xAI Imagine"
- "/grok-imagine"
- explicit request to generate or edit media with Grok
Do not hijack a generic "generate an image" if the user named another provider (GPT Image 2, Fal, etc.). If they named Grok Imagine, do not silently fall back.
How to invoke
Scripts live next to this file:
bash scripts/gen.sh \
--mode <image|edit|video> \
--prompt "<user's raw prompt>" \
--out <absolute/path>
Text-to-image
bash scripts/gen.sh \
--mode image \
--prompt "A tiny blue boat on a calm sea at dusk, cinematic" \
--out /absolute/path/image.jpg \
--aspect-ratio 16:9
Optional: --fast → grok-imagine-image. Default → grok-imagine-image-quality. --n 2 writes stem-1.ext, stem-2.ext.
Image edit
bash scripts/gen.sh \
--mode edit \
--prompt "Repaint as neon cyan" \
--ref /absolute/path/source.jpg \
--out /absolute/path/edited.jpg
--ref required. Only the first ref is used (multi-image edit not validated).
Image-to-video
bash scripts/gen.sh \
--mode video \
--prompt "gentle camera push-in with subtle motion" \
--ref /absolute/path/frame.jpg \
--out /absolute/path/clip.mp4 \
--duration 6
Default model: grok-imagine-video-1.5. Duration: 6 or 10. Optional --resolution 480p.
Text-to-video
bash scripts/gen.sh \
--mode video \
--prompt "A tiny blue boat rocking gently on a calm sea at dusk" \
--out /absolute/path/clip.mp4 \
--duration 6 \
--aspect-ratio 16:9
Default model: grok-imagine-video.
Critical: grok-imagine-video-1.5 does not support T2V. Without --ref, the script uses the T2V-capable model.
Agent defaults
- Pass the user prompt raw (no unsolicited style padding).
- If no path given, choose
./grok-image-<YYYYMMDD-HHMMSS>.jpgor./grok-video-<YYYYMMDD-HHMMSS>.mp4(absolute when calling the script). - After success, show/attach the file — do not stop at path-only.
- Prefer this skill’s CLI over inventing raw
curlpayloads.
Exit codes
| code | meaning |
|---|---|
| 0 | success — path(s) on stdout |
| 2 | bad args |
| 3 | python3 missing |
| 4 | --ref missing on disk |
| 5 | API / network / video failure |
| 6 | empty media / download failed |
| 7 | auth missing or 401 |
On failure, name the layer in one sentence. Never print tokens or huge base64.
Hard constraints
- Do not substitute DALL·E / GPT Image 2 / HTML mockups when Grok Imagine was requested.
- Do not claim T2V works on
grok-imagine-video-1.5. - Do not invent unvalidated endpoints (video edit, extension, r2v) — re-test first.
- Do not log credentials.
Prerequisites
python3on PATH (stdlib only — nopip install)XAI_API_KEYor workinggrok loginwith Imagine entitlement
What this is not
Not the interactive Grok TUI slash commands alone. Not a free unlimited generation grant. Not multi-tenant SaaS. Concurrent calls are safe (stateless HTTPS).
What ships with it: 2 files
15.4 KB alongside SKILL.md, 2 of them executable