Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate images with xAI's Grok image models (grok-2-image / grok-2-image-1212). Use when the user asks for Grok-generated images, mentions xAI image generation, or wants an OpenAI-compatible image API alternative. Generation only — Grok image models do not support edit, mask, or reference-image inputs.
.claude/skills/satasuk03-grok-image/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -32% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -22% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 2% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 10% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 173% | 0% |
Calls xAI's OpenAI-compatible image endpoint with the Grok image models. One capability:
scripts/generate.py.For the full parameter table, response shape, and pricing notes, see references/api-reference.md. For Python recipes (URL download, base64 decoding, batch generation, prompt revision inspection), see references/examples.md.
XAI_API_KEY exported in the environment (get one at https://console.x.ai/).openai (the OpenAI SDK works against xAI by overriding base_url):bash pip install openai requests works too if you'd rather not pull the SDK; both are shown in references/examples.md.
bash# 1 image, downloaded from the returned URL python scripts/generate.py \ --prompt "A cinematic portrait of a woman on a Hong Kong street with a vintage tram in the background" \ --output portrait.png # 4 images, base64 path (no extra HTTP roundtrip) python scripts/generate.py \ --prompt "Isometric pixel-art of a cozy cyberpunk noodle shop" \ --n 4 --response-format b64_json \ --output shop.png # writes shop_0.png ... shop_3.png # Pin to the dated snapshot python scripts/generate.py \ --prompt "..." --model grok-2-image-1212 --output out.png # Inspect what Grok actually sent to the model after revision python scripts/generate.py --prompt "..." --output out.png --print-revised
When the user wants an image and chooses Grok (or asks for an OpenAI-compatible alternative), use generate.py. If the user wants any of the following, this skill is the wrong tool — escalate:
gpt-image-2 (Grok image models don't expose edit endpoints).gpt-image-2's images.edit with multiple image= files.size / quality; it picks them automatically. Use gpt-image-2 if precise sizing matters.| Flag | Values | Default | Notes | |------|--------|---------|-------| | --model | grok-2-image, grok-2-image-1212 | grok-2-image | Alias and dated snapshot of the same model | | --n | int 1–10 | 1 | Multiple images per call | | --response-format | url, b64_json | url | url returns short-lived hosted URLs; b64_json embeds the bytes | | --base-url | str | https://api.x.ai/v1 | Override only if proxying | | --print-revised | flag | off | Prints the revised_prompt Grok actually used |
Not supported by the Grok image API (don't pass these — the call will error or be ignored):
size, quality, style, response_format=image_url extrasimage / mask (no edit endpoint)stream, partial_imagesbackground, output_format, output_compression, moderationuser (not a useful knob here)data[].revised_prompt. Surface this to the user when the result drifts — they may want to feed the revised prompt back in directly.response_format=url, the URLs are short-lived. Download immediately; don't store them.n=10 can hit per-minute caps. The script doesn't auto-retry.moderation knob to relax it. If a prompt is rejected, rewrite rather than retry.gpt-image-2 for edits, masks, multi-image composition, or precise size/quality control.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 13,542 | 3,338 | -75% | 1 | 1 | 0% | 2,386 | 1,633 | -32% | 0 | 0 | — |
case-02 | fail→pass | 15,311 | 8,375 | -45% | 1 | 1 | 0% | 2,051 | 1,598 | -22% | 0 | 0 | — |
case-03 | fail→pass | 7,690 | 2,875 | -63% | 1 | 1 | 0% | 1,530 | 1,568 | +2% | 0 | 0 | — |
case-04 | fail→pass | 9,844 | 3,178 | -68% | 1 | 1 | 0% | 1,657 | 1,815 | +10% | 0 | 0 | — |
case-05 | fail→pass | 6,473 | 7,356 | +14% | 1 | 1 | 0% | 966 | 2,633 | +173% | 0 | 0 | — |
case-06 | fail→pass | 14,108 | 4,213 | -70% | 1 | 1 | 0% | 2,739 | 1,974 | -28% | 0 | 0 | — |
case-07 | pass→pass | 15,247 | 4,512 | -70% | 1 | 1 | 0% | 2,616 | 1,794 | -31% | 0 | 0 | — |
case-08 | fail→fail | 9,397 | 5,627 | -40% | 1 | 1 | 0% | 762 | 1,496 | +96% | 0 | 0 | — |
case-09 | fail→fail | 27,734 | 7,382 | -73% | 1 | 1 | 0% | 3,176 | 1,617 | -49% | 0 | 0 | — |
case-10 | fail→pass | 28,534 | 2,332 | -92% | 1 | 1 | 0% | 5,217 | 1,530 | -71% | 0 | 0 | — |
case-11 | fail→fail | 11,252 | 6,389 | -43% | 1 | 1 | 0% | 765 | 1,522 | +99% | 0 | 0 | — |
case-17 | fail→pass | 8,336 | 6,891 | -17% | 1 | 1 | 0% | 1,268 | 2,250 | +77% | 0 | 0 | — |
case-12 | fail→pass | 4,924 | 1,723 | -65% | 1 | 1 | 0% | 720 | 1,481 | +106% | 0 | 0 | — |
case-13 | fail→pass | 7,701 | 5,075 | -34% | 1 | 1 | 0% | 1,343 | 2,133 | +59% | 0 | 0 | — |
case-14 | pass→pass | 8,594 | 4,763 | -45% | 1 | 1 | 0% | 1,466 | 2,026 | +38% | 0 | 0 | — |
case-15 | pass→pass | 8,782 | 3,267 | -63% | 1 | 1 | 0% | 1,498 | 1,692 | +13% | 0 | 0 | — |
case-16 | fail→pass | 10,389 | 2,888 | -72% | 1 | 1 | 0% | 1,856 | 1,690 | -9% | 0 | 0 | — |
case-18 | fail→pass | 6,819 | 7,853 | +15% | 1 | 1 | 0% | 661 | 1,942 | +194% | 0 | 0 | — |
case-19 | pass→pass | 12,087 | 5,659 | -53% | 1 | 1 | 0% | 2,096 | 2,268 | +8% | 0 | 0 | — |
case-20 | fail→pass | 11,339 | 4,308 | -62% | 1 | 1 | 0% | 1,652 | 1,940 | +17% | 0 | 0 | — |
case-21 | fail→pass | 9,826 | 5,877 | -40% | 1 | 1 | 0% | 1,596 | 1,631 | +2% | 0 | 0 | — |
case-22 | fail→fail | 11,477 | 5,515 | -52% | 1 | 1 | 0% | 1,742 | 1,508 | -13% | 0 | 0 | — |
case-23 | pass→pass | 5,743 | 1,668 | -71% | 1 | 1 | 0% | 950 | 1,488 | +57% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 19 counted toward the lift figure. The other 4 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +61 percentage points is the difference between those two pass rates over the 19 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.