Image generation belongs inside the coding session
image_gen saves images into the project with the same approval as a file write. It uses your ChatGPT login or an API key, takes up to five reference images and never writes outside the project.

Why in the session
A coding session already knows where the assets go, what the page looks like and which image needs replacing. Leaving it to make an image means describing all of that again somewhere else and copying the file back. image_gen is an ordinary tool with write permission: the file lands in the project, and you approve it like any other write.
What it takes
Arguments
| Argument | Values |
|---|---|
| prompt | required |
| size | 1024x1024 (default), 1536x1024, 1024x1536 |
| n | 1 or 2 |
| path | optional; refused before any paid call when it lies outside the project, also through a symlink |
| referenced_image_paths | up to five local images, at most 50 MB each |
Without a path an image is saved as generated/<prompt-slug>-<n>.png, taking the first free number, so it never overwrites. The result shows the image in the session.
make a 1536x1024 cover for the blog post in the style of
public/blog/art/connected-memory.png and save it as
public/blog/art/pr-reviewer.pngWhere it generates
The first configured one wins
- With
OPENROUTER_API_KEY: OpenRouter, modelgoogle/gemini-2.5-flash-image. - With
OPENAI_API_KEY: OpenAI Images, modelgpt-image-2. - With the subscription adapter
codex-oauth: your ChatGPT plan, using MendCode’s own ChatGPT login first, then the Codex CLI’s.
The tool picks its own image model, independent of the model you chat with. Keys are sent only to the provider’s own host and never written to a log or error. MENDCODE_IMAGE_GEN=0 turns the hosted image tool off.
In Claude Code sessions
Claude Code has no image tool of its own. In a Claude Code session run by MendCode, image generation counts as on while a ChatGPT login or a saved OpenAI key exists, and Claude calls it as mcp__mendcode__image_gen.