Generate Image
generate_imageCreate or edit images from prompts, reference images, or masks, then save PNG, JPEG, or WebP files to a chosen project folder with preview paths.
Instructions
Generate/edit images and save originals in the current directory or requested folder.
Reuse Codex relay URL and credentials. Discover dialogue/image models independently; explicit responses_model/image_model values override automatic selection. When the user chooses this MCP, the host can reuse its installed system imagegen skill for prompt preparation and visual review while executing generation here. The server does not load skills itself; skill-specific built-in/CLI settings do not govern this tool. Supports PNG/JPEG/WebP, visual options, reference images and masks. Returns previews, absolute paths and edit IDs; successful images survive partial failures.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"prompt": "<prompt>",
"cwd": "<cwd>"
},
"name": "generate_image"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes | Absolute CURRENT task working directory, supplied by Codex from context. | |
| mask | No | Mask for the first image; local/data masks need alpha and must match comparable local input dimensions/format. | |
| size | No | auto or WIDTHxHEIGHT. Model-specific limits are decided by upstream. | |
| action | No | Choose automatically, generate, or edit supplied/previous images. | |
| prompt | Yes | Describe what to draw or edit and important visual requirements. | |
| quality | No | Optional quality; available levels depend on the upstream image model. | |
| filename | No | Filename only, e.g. cover.webp. Infer format from extension; default is a unique name. Never overwrite existing files. | |
| background | No | Transparent backgrounds require PNG or WebP. | |
| moderation | No | Optional official moderation setting; upstream policy still applies. | |
| output_dir | No | Directory relative to cwd or an explicitly requested absolute directory. Default: cwd itself. | |
| image_model | No | Explicit tools[].model from the official image catalog. Omit for automatic selection; upstream_default omits the upstream field. | |
| input_images | No | Reference images, each with exactly one path, image_url or file_id. | |
| model_policy | No | Automatic model-selection preference. Default: configured policy, normally quality. Separate from image quality. | |
| current_model | No | Exact dialogue-model API ID only when reliably known from the session. Otherwise omit; config fallback is explicit. | |
| output_format | No | Infer from filename if omitted, otherwise default PNG. No SVG or animated output. | |
| input_fidelity | No | Optional fidelity only if supported upstream; omit by default. | |
| partial_images | No | 0: final-only default. 1–3: streaming drafts and progress; host live display varies. | |
| include_preview | No | Return bounded inline previews and original file paths. | |
| responses_model | No | Explicit top-level dialogue model, overriding automatic provider-model selection; does not change the Codex session. | |
| safety_identifier | No | Optional privacy-preserving end-user ID for multi-user deployments. | |
| output_compression | No | JPEG/WebP only: strictly integer 0–100. | |
| previous_image_ids | No | Prior image_generation_call IDs from the same provider. | |
| previous_response_id | No | Prior response ID from the same provider; requires retained upstream state. |