grok-imagine
Skill128 starsChanged 5 months agoMITView on GitHub
Generate or edit images via Grok Imagine Image 2.0 through DroidProxy (no XAI_API_KEY). Use when the user asks to generate, create, draw, imagine, or edit an image, illustration, icon, mockup, or similar visual asset and DroidProxy Grok OAuth is available. Prefer this over inventing image URLs or base64.
- Reads credentials
3 other projects use a version of this.
Adopted by
Most recently taken up by
- kadaliao/skillstheir own version, first seen Jul 29, 2026
- heslanx/grok-imaginetheir own version, first seen Jul 14, 2026
- JinchengGao-Infty/agent-loadouttheir own version, first seen Mar 25, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- JinchengGao-Infty/agent-loadout★ 3same name
- heslanx/grok-imagine★ 0same name
- kadaliao/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- windows-wip/AGENTS.mdAGENTS.md
- claude-apiSkill
- droid-model-setupSkill
- gpt-imageSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
Use for generating or editing visual assets.
- Distinctive: line 157
When someone asks for a transparent PNG:
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Grok Imagine Image 2.0 (via DroidProxy)
Generate and edit images with grok-imagine-image-2.0 using the SuperGrok /
X Premium+ OAuth session that powers DroidProxy chat. This is the current
Imagine image model (text or image → image). Do not use the older
grok-imagine-image / grok-imagine-image-quality ids unless the user
explicitly asks for them.
Two things you can't guess and that everything else depends on:
- The endpoint is
http://localhost:8317, notapi.x.ai. DroidProxy TLS-forwards any request whosemodelstarts withgrok-and injects the OAuth bearer. - Auth is
Authorization: Bearer dummy-not-used. The real token comes from the proxy. Never ask for or use anXAI_API_KEY.
Use for generating or editing visual assets. Not for understanding an image the user already attached — that's chat multimodal, not this skill.
Prompting
xAI rewrites the prompt with an upsampler before generation, so write a clear scene rather than a tag soup. If the user gives a detailed prompt or asks you to use theirs, use it verbatim. Otherwise craft 2–5 sentences of natural prose:
subject → action/pose → setting → style → composition → lighting/mood → key details
- Front-load the subject. Give strong high-level direction for mood, composition, lighting, and style without specifying every pixel.
- State what to include, not what to exclude. No negative prompts.
- One coherent scene per prompt. Match
aspect_ratioto the use case: icons1:1, banners16:9, stories9:16. - For edits, describe only what changes and what must stay the same.
- For multi-image edits, address sources as
<IMAGE_0>,<IMAGE_1>,<IMAGE_2>in the prompt (max 3). Combining subjects, transferring a style, or composing a scene from references is the intended use. - Ground real people, brands, places, and “current/latest” facts with a web search first and put the verified details in the prompt. For a named real person, edit from a real reference photo — do not generate the likeness from text alone.
Generate
RESP=$(curl -sS http://localhost:8317/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer dummy-not-used" \
-d "$(jq -n --arg p "A red balloon on a wooden table, soft natural light" \
'{model:"grok-imagine-image-2.0", prompt:$p, aspect_ratio:"1:1",
resolution:"1k", response_format:"b64_json"}')")
if B64=$(printf '%s' "$RESP" | jq -er '.data[0].b64_json' 2>/dev/null); then
printf '%s' "$B64" | base64 -d > out.jpg
else
printf '%s\n' "$RESP" >&2 # errors are plain text, not JSON
exit 1
fiTwo things that bite here:
- Check
.data[0].b64_jsonbefore decoding. On failure there is no b64 field, and piping the error body throughbase64 -dwrites a corrupt file that passes anlscheck and only reveals itself when someone opens it. - Print the raw body on failure, not
jq '.error.message'. Errors come back astext/plain, so parsing them as JSON discards the useful part. The raw text is specific and worth reading — a badaspect_ratiorepliesunknown variant `21:9`, expected one of `1:1`, `3:4`, ..., which tells you exactly what to send.
Edit
POST /v1/images/edits, same auth and routing. Pass either image (single)
or images (up to 3 references, addressed as <IMAGE_0>, <IMAGE_1>,
<IMAGE_2> in the prompt) — never both. Each source is JPEG, PNG, or WebP.
curl -sS http://localhost:8317/v1/images/edits \
-H "Content-Type: application/json" \
-H "Authorization: Bearer dummy-not-used" \
-d "$(jq -n --arg p "Make it blue-tinted studio lighting" --arg u "$SRC" \
'{model:"grok-imagine-image-2.0", prompt:$p,
image:{url:$u, type:"image_url"},
response_format:"b64_json"}')"The source url takes a public HTTPS URL, an xAI file_id (on the image
object, mutually exclusive with url), or a data URL. For a local file
there's no upload step — inline it as a data URL:
SRC="data:image/jpeg;base64,$(base64 -i ./photo.jpg)"Omit aspect_ratio on single-image edits; it follows the source, and setting
it can crop or letterbox. On multi-image edits it follows the first source
unless you override it.
Chain edits by feeding each output back as the next image. That is how you
refine, restyle, or correct without starting over.
Parameters
Source of truth: Image Generation, Image Editing, Multi-Image Editing, and the Images REST API.
| Field | Values | Notes |
model | grok-imagine-image-2.0 | Must start with grok- or the proxy won't route it. Always send this id. |
prompt | string | See Prompting. Required on edits. |
aspect_ratio | 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 | Default auto (model picks the ratio). Icons 1:1, banners 16:9, stories 9:16. |
resolution | 1k, 2k | Default 1k. Stay there unless the user asks for print/hi-dpi — 2k returns much larger files. |
quality | low, medium | 2.0 only. Default medium when omitted. Do not send high, hd, or standard. Omit unless the user asks for low. |
response_format | url, b64_json | url is the default but expires fast — prefer b64_json when saving to disk. |
n | 1–10 | Default 1. Same-prompt variations belong in one request via n, not parallel calls. |
image / images | object or array (max 3) | Edits only. Mutually exclusive. Each item is {url, type:"image_url"} or {file_id}. |
storage_options | {filename, expires_after?, public_url?} | Persists to the xAI Files API; response gains file_output: {file_id, filename}. expires_after is seconds, max 2592000. |
user | string | Optional end-user id for abuse monitoring. Don't invent one. |
Anything outside these enums returns 422, and OpenAI-only fields (size,
style, background, output_format, quality:"hd") return 400 or are
silently ignored. Don't reach for them.
Response
{"data": [{"b64_json": "...", "mime_type": "image/jpeg", "url": "https://imgen.x.ai/..."}]}Pick the file extension from mime_type, not from the prompt or the filename
the user asked for — 1k usually returns JPEG and 2k often returns PNG, so a
.jpg name on PNG bytes is a real outcome. If that contradicts the name they
gave, save the correct extension and say why. mime_type may also be
image/webp.
With response_format: "url" the URL is temporary (imgen.x.ai) — download it
immediately rather than handing it to the user.
No transparency
Imagine has no alpha channel; output is always opaque JPEG, PNG, or WebP. There is no API field that changes this, so don't send one.
When someone asks for a transparent PNG:
- Generate on a flat, uniform background that contrasts with the subject.
- Key it out locally (PIL, ImageMagick).
- Recolor the subject for the background they named, before you finish. Someone asking for transparency has told you where it's going — "over our dark header," "on a white card." Keying preserves whatever ink Imagine happened to render, which is usually near-black, so a mark destined for a dark background comes out invisible. Compare the subject's luminance to the target background and invert it if they collide. That's the difference between a usable asset and one the user has to send back.
- Say what you did, and mention the ink color you chose so they can ask for the other one.
Failures
Most errors explain themselves; these three don't:
| Symptom | Fix |
| Connection refused | DroidProxy isn't running — tell the user to launch it |
| 401, or 401 after a long idle | OAuth session dead — Settings → Connect Grok |
| 403 permission / quota | Subscription tier gates API OAuth. A BYOK XAI_API_KEY is the only fallback |
On a moderation / safety block, stop. Don't retry and don't paraphrase the prompt to evade the filter. Tell the user it was blocked and offer a different direction.
Report the API's own message rather than guessing, and never invent image content or a URL for a request that failed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

