Generate images via the local Codex CLI
codex_generate_imageGenerate images from text prompts with the local Codex CLI, returning saved file paths and inline previews. For longer runs, return a job ID to collect results later.
Instructions
Generate images with the local Codex CLI. The prompt is passed through as written. Returns the saved file paths and shows the images inline, downscaling a preview when a file is too large to inline. Defaults to a fast low-quality 1024x1024 draft; raise quality for final assets. Image generation often takes longer than wait_sec, in which case this returns status: running and a job_id; call codex_job_result with it to collect the images.
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>"
},
"name": "codex_generate_image"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| open | No | Open the generated images in the user's default image viewer. Default true, because MCP clients do not render tool-result images into the chat. | |
| size | No | Pixel size as WIDTHxHEIGHT, e.g. "1024x1024" (fastest, the default), "1536x1024" landscape, "1024x1536" portrait, or "auto". This is a request to Codex; the actual dimensions are reported in the result. | |
| count | No | How many images. Default 1. | |
| model | No | Override the Codex model for this image task. | |
| prompt | Yes | What the image should depict. | |
| quality | No | Generation quality. Default "low" - fastest, good for drafts. Use "high" for final assets. | |
| wait_sec | No | Seconds to wait for the result before returning a job_id instead. Default 45, maximum 50, which keeps the call under common 60-second client timeouts. | |
| workspace | No | Workspace folder name. Defaults to a new folder. | |
| background | No | Requested image background. Use PNG or WebP for transparency. | |
| timeout_sec | No | Seconds before Codex is killed. | |
| output_format | No | Requested saved format. Default JPEG for smaller opaque images. | |
| target_file_kb | No | Target KB per image, default 256. A prompt preference; actual size is reported. | |
| reasoning_effort | No | Codex reasoning effort, subject to model support. | |
| output_compression | No | Requested JPEG or WebP output quality, 1 to 100. Default 80. PNG is lossless. |