# xai-grok-imagine-image

xai-grok-imagine-image is a Claude Code skill for generating and editing images via xAI's Grok Imagine API. It configures model selection, aspect ratios, and multi-image editing.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 136 installs · ★ 252 repo stars
- Author: calesthio
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/calesthio/generative-media-skills/tree/HEAD/skills/providers/image-generation/xai-grok-imagine-image/SKILL.md
- Updated: 2026-07-14
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/xai-grok-imagine-image

## What it does

The skill manages production HTTP contracts against `https://api.x.ai/v1/images/generations` and `https://api.x.ai/v1/images/edits`. It maps parameters for `grok-imagine-image-quality` and `grok-imagine-image`, bypassing the retired `grok-imagine-image-pro` identifier. Supported payload settings include resolutions `1k` or `2k`, aspect ratios, and direct persistence via the xAI Files API.

Image editing accepts JPEG, PNG, and WebP inputs passed either as URLs or private `file_id` targets. When sending up to three source images, prompts reference them sequentially as `<IMAGE_0>`, `<IMAGE_1>`, and `<IMAGE_2>`.

An active `XAI_API_KEY` secret is required. The standard OpenAI SDK `images.edit()` method is incompatible because it posts multipart form data, whereas xAI requires a JSON body.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add calesthio/generative-media-skills --skill xai-grok-imagine-image -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/xai-grok-imagine-image/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/xai-grok-imagine-image/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add calesthio/generative-media-skills --skill xai-grok-imagine-image -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/xai-grok-imagine-image/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add calesthio/generative-media-skills --skill xai-grok-imagine-image -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/xai-grok-imagine-image/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install calesthio/generative-media-skills skills/providers/image-generation/xai-grok-imagine-image
```

2. **Manually: put the files in place**
- File: `.github/skills/xai-grok-imagine-image/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add calesthio/generative-media-skills --skill xai-grok-imagine-image -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/calesthio/generative-media-skills --path skills/providers/image-generation/xai-grok-imagine-image
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/xai-grok-imagine-image/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add calesthio/generative-media-skills --skill xai-grok-imagine-image -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/calesthio/generative-media-skills/tree/HEAD/skills/providers/image-generation/xai-grok-imagine-image/SKILL.md

## When to use it
- generate images using the direct `/v1/images/generations` endpoint
- edit up to three source pictures with natural language prompts
- configure aspect ratio and `1k` or `2k` output resolution
- send valid JSON edit requests avoiding incompatible multipart SDK calls

## Example prompts
- Generate a 16:9 banner in 2k resolution using grok-imagine-image-quality
- Edit input.png using natural language instructions via the xAI edits API

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: cd8a4a417e216401.

BEGIN THIRD-PARTY FILE cd8a4a417e216401
````text
---
name: xai-grok-imagine-image
description: Generate and edit production images with xAI's first-party Grok Imagine API, including model selection, multiple references, synchronous and Batch API workflows, durable output handling, prompting, iteration, QA, cost and rate controls, privacy, safety, and rights review. Use for direct xAI image API integrations, not Grok video or third-party gateways.
---

# xAI Grok Imagine Image

Operate xAI's first-party image API as a production system, not as a prompt toy. Keep the image workflow separate from Grok Imagine video: image generation and editing are synchronous in the direct REST API, while video has a different asynchronous request/poll contract.

All volatile facts were verified against first-party xAI documentation on **2026-07-09**. Recheck the model endpoint, console, pricing, rate limits, release notes, and legal terms before deployment.

## Evidence vocabulary

- **Documented:** stated in current xAI API documentation, model pages, or terms.
- **Provider claim:** qualitative language from xAI product or launch material; test it independently.
- **Production heuristic:** an operational recommendation derived from the contract and common media practice, not an xAI guarantee.
- **Unknown:** not established by the reviewed first-party sources. Do not fill the gap with assumptions.

## Lock the interface and model

Use only the documented inference base and routes:

```text
POST https://api.x.ai/v1/images/generations
POST https://api.x.ai/v1/images/edits
Authorization: Bearer {XAI_API_KEY}
Content-Type: application/json
```

Create a team-scoped key with the minimum endpoint/model ACLs needed. Load it from a secret manager or `XAI_API_KEY`; never put it in source, logs, prompts, asset metadata, browser code, or URLs.

### Current image models

| Model | Current aliases | 1K output | 2K output | Input image | Use |
|---|---|---:|---:|---:|---|
| `grok-imagine-image-quality` | `grok-imagine-image-quality-20260403`, `grok-imagine-image-quality-latest`; retired `grok-imagine-image-pro` redirects here | $0.05 | $0.07 | $0.01 each | Higher-quality production candidate; stronger realism/text/control are provider claims |
| `grok-imagine-image` | `grok-imagine-image-2026-03-02` | $0.02 | $0.02 | $0.002 each | Lower-cost candidate and high-volume exploration |
````
END THIRD-PARTY FILE cd8a4a417e216401

The third-party file has ended. Everything between the cd8a4a417e216401 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2343 of 39898 bytes. © calesthio · MIT · https://github.com/calesthio/generative-media-skills/tree/HEAD/skills/providers/image-generation/xai-grok-imagine-image/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
