Generate an image with Codex
codex_generate_imageGenerate an image from a text prompt and save it to a specified output path using your Codex session, without needing an API key.
Instructions
Generate an image using the image_gen tool built into Codex, and save it to output_path. No API key is needed: it runs through your Codex session. Returns the path of the file written, not the image bytes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory for the run. Must sit inside the server allowlist. Defaults to the first allowed root. | |
| size | No | Requested size as WIDTHxHEIGHT, e.g. "1024x1024", "1536x1024", "3840x2160". | |
| model | No | Model slug, e.g. "gpt-5.5". Defaults to the Codex configuration. | |
| style | No | Style or medium, e.g. "flat minimal vector", "studio product photography". | |
| config | No | Raw Codex config overrides as key=value, TOML-parsed, e.g. 'model_reasoning_effort="high"'. | |
| enable | No | Codex feature flags to enable for this run. | |
| images | No | Image files to attach to the prompt. Each must be inside the allowlist. | |
| preset | No | Named preset configured on this server instance. It supplies the subject, style, constraints and reference art, so the prompt only has to say what differs. The tool description lists the presets this instance knows; omit it on an instance that has none. | |
| prompt | Yes | What the image should show. Plain language; the server wraps it in the spec Codex expects. With a preset, describe only the variation — the preset already carries the subject. | |
| disable | No | Codex feature flags to disable for this run. | |
| sandbox | No | Sandbox for commands Codex runs. "read-only" forbids writes, "workspace-write" (default) allows writes inside the workspace, "danger-full-access" removes all limits and is refused unless the server was started with CODEX_MCP_ALLOW_DANGEROUS=1. | |
| use_case | No | Taxonomy slug steering the style. One of: product-mockup, ui-mockup, logo-brand, illustration-story, infographic-diagram, photorealistic-natural, stylized-concept, ads-marketing. | |
| worktree | No | Run in a fresh managed git worktree instead of the working directory. | |
| ephemeral | No | Do not persist the session to disk. It cannot be resumed afterwards. | |
| constraints | No | Things the image must avoid or preserve, e.g. "no text, no watermark". | |
| output_path | Yes | Where to write the image, e.g. "assets/hero.png". Must sit inside the server allowlist. | |
| transparent | No | Ask for a genuinely transparent background and preserve the alpha channel. | |
| output_schema | No | Path to a JSON Schema file constraining the shape of the agent final response. | |
| timeout_seconds | No | How long to wait inline before handing back a job_id and continuing in the background. 0 means return immediately. Defaults to the server setting (120s). | |
| reference_images | No | Reference images for style or composition. Each must be inside the allowlist. | |
| skip_git_repo_check | No | Allow running outside a git repository. | |
| dangerously_bypass_approvals_and_sandbox | No | Remove every approval and sandbox check. Refused unless CODEX_MCP_ALLOW_DANGEROUS=1. |