Codex images: screenshots, the -i flag, and $imagegen
How to give Codex CLI an image (Ctrl+V paste, a file path, -i in codex exec, Shift-drag in the IDE), which models read images, and making images with $imagegen.
Codex reads images you give it: in the CLI, press Ctrl+V to paste a screenshot from the clipboard, paste or @-pick the path of an image file, or start with -i/--image; in codex exec the same -i flag works; in the IDE extension and the ChatGPT desktop app, hold Shift and drag the image into the composer. PNG and JPEG are the formats the docs name. Codex also makes images: ask for one, or write $imagegen, and it uses gpt-image-2 against your Codex usage. On a server over SSH, clipboard paste does not reach you, so copy the file across with scp and give Codex its path. As read on December 1, 2026, with Codex CLI 0.172.0 (released November 24).
Give Codex an image in the CLI
In an interactive session there are three ways in, from the image inputs docs and the 0.172.0 source:
- Paste from the clipboard. Take the screenshot, then press
Ctrl+VorAlt+Vin the Codex composer (on a Mac too: Control, not Command, sinceCmd+Vis your terminal’s own text paste). On Windows,Shift+Insertalso works, and under WSL Codex fetches the Windows clipboard’s image through PowerShell. If you copied an image file rather than pixels, the file wins over its preview. Codex saves the pasted image as a PNG in your temp folder and shows it in the composer as[Image #1]. - Paste or drop a path. Pasting the path of an image file attaches the image instead of typing the path. If your terminal pastes a file’s path when you drag the file onto it, dragging attaches the image the same way.
- Pick it with
@. Choosing an image file in the@file picker attaches it as an image rather than inserting its name.
To start a session with images already attached, pass them on the command line. The flag takes one or more paths, separated by commas or with the flag repeated:
codex "Explain this error and suggest the smallest fix" -i screenshot.png
codex "Compare these states and list the regressions" --image before.png,after.pngCopiedIn 0.172.0 a single -i is defined to take one or more values, so the prompt written before the flag, as above, is the order that leaves no doubt which word is the prompt and which are paths. If you prefer the prompt last, ending the paths with -- (codex -i screenshot.png -- "Explain this error") marks where they stop.
You can also just name a file in your message. Codex has a built-in image viewer tool, on by default, that the model calls with a path (relative paths are taken from the working directory), so “look at docs/mockup.png and build this page” works for any image already on the machine. Describe what the image shows and what you want from it; the docs advise saying which part of the image matters and, with several, how to compare them.
Images in codex exec
codex exec, the non-interactive mode for scripts and CI, takes the same -i flag for the first message, and codex exec resume takes it for the follow-up (command reference). The same ordering advice applies:
codex exec "List every visual difference between these two screenshots" -i before.png,after.png
codex exec resume --last "Now check this one too" -i third.pngCopiedThere is no clipboard in a script, so -i and paths named in the prompt are the two routes. The codex exec guide covers the sandbox, JSON output and API-key sign-in for unattended runs.
In the IDE extension and the ChatGPT desktop app
In the Codex extension for VS Code and its forks, hold Shift while you drag an image into the Codex composer; the docs say this is so “the extension accepts the drop instead of passing it to the editor”. The ChatGPT desktop app, where the Codex app now lives, works the same way: Shift and drag into the composer. The desktop app on macOS and Windows also has Appshots, which send the frontmost window’s image and text to a chat when you press both Command keys (macOS) or both Alt keys (Windows); the CLI can resume a chat that holds one but cannot take one. The Codex in VS Code and Codex app guides cover those surfaces more widely.
Which models read images, and how big an image can be
The image inputs page names no model requirement. In the model catalogue bundled with 0.172.0, the two models at the top of the list, gpt-6.2-sol and gpt-6.2-astra, both list image input ("input_modalities": ["text", "image"]), and the models page singles out GPT-6.1 Terra for “visual understanding”. A model without image input, such as a text-only local model run with --oss, cannot use them: Codex’s image viewer refuses with “view_image is not allowed because you do not support image inputs”. The Codex models guide has the full list and how to switch.
The docs give no size limit. In the 0.172.0 source:
- The interactive CLI refuses a message whose attached images come to more than 32 MiB once encoded (an encoded image is about a third bigger than the file), with “image attachments exceed the 32 MiB transport limit”, and keeps your message in the composer.
- Codex scales a large image down to a pixel budget that depends on the model before the model sees it, so a huge screenshot is not read at full resolution. Cropping to the part that matters keeps the detail where you want it.
- It recognises PNG, JPEG, GIF and WebP, and converts a GIF to PNG.
Screenshots when Codex runs on a server over SSH
Ctrl+V reads the clipboard of the machine Codex runs on. When you are connected over SSH, that is the server, which has no display and none of your screenshots, so the paste brings nothing. Dragging a file onto the terminal pastes your laptop’s path, which does not exist on the server. The route that works is to put the file on the server and give Codex the server’s path. From your own machine, in a second terminal:
scp ~/Desktop/screenshot.png you@your-server:CopiedThat copies it into your home directory on the server (the trailing colon means “home”; add a folder after it to put it elsewhere). Then, in the Codex session on the server, name it in your message (“read ~/screenshot.png and fix the layout bug it shows”) or start a new session with -i ~/screenshot.png. Screenshots can show tokens, email addresses or customer data, so avoid a shared folder such as /tmp on a server other people use, and delete the file when you are done:
rm ~/screenshot.pngCopiedThat removes the copy on the server for good; the original on your machine is untouched. Going the other way, an image Codex made on the server comes back with scp in reverse (scp you@your-server:path/to/image.png .). Setting the server up is in Codex CLI on a Linux server, and installing the CLI in install Codex CLI.
Generating images with Codex
Codex also creates and edits images. Per the image generation docs: in the CLI, “Describe the image in an interactive session or include $imagegen to invoke the image generation skill explicitly”, and attach a reference image with -i when it should guide the result. In the IDE extension you ask in the chat and Shift-drag a reference image in. Typed into the Codex composer, not the shell:
$imagegen a 1200x630 social card for the docs site: dark background, the project name in large white typeCopied“Built-in image generation uses gpt-image-2 and counts toward your general Codex usage limits”, and the docs say an image uses included limits three to five times faster on average than a similar turn without one, depending on quality and size. For larger batches they suggest setting OPENAI_API_KEY in your environment and asking for the images to be generated through the API, “so API pricing applies”.
The built-in skill shipped in 0.172.0 saves its output under $CODEX_HOME/generated_images/ (~/.codex/ unless you have moved CODEX_HOME), and its instructions tell the agent to move or copy an image the project uses into the workspace before finishing. To edit an image you already have, give it to Codex first by any of the routes above; the skill edits images that are in the conversation, not arbitrary paths.
The same in Claude Code
Claude Code takes images the same three ways. Its common workflows page lists: “Drag and drop an image into the Claude Code window”; copy an image and paste it into the CLI with Ctrl+V, or Alt+V on Windows and WSL; or give a path, “for example ‘Analyze this image: /path/to/your/image.png’”. Attached images appear as [Image #1], and Cmd+Click or Ctrl+Click opens one in your viewer. On a server the same rule holds: copy the screenshot over with scp and give the path. Running it there is covered in Claude Code on Linux.