Docly Developers
Knowledge base Best practice Recommended

Generate images from Claude with the Codex CLI

In shortClaude cannot generate images, but it can call the Codex CLI, which can. Install it once with npm install -g @openai/codex, sign in once with codex login (a ChatGPT account, no API key), and let the agent run codex exec in a scratch folder with a prompt that says what to draw and where to save the file. One image takes a couple of minutes, so give the call a long timeout. Then upload the PNG and let Docly scale and convert it.
Applies to AI agentsImagesCodex CLI
  1. What you'll see

    An AI agent such as Claude (Claude Code) is building or updating a Docly site and needs a photo or an illustration — a hero image, a background, a picture for an article — but answers that it cannot generate images, or falls back to a placeholder.

  2. What's actually happening

    Claude cannot create images. It can write SVG and CSS, but not a photo or a painted illustration. The Codex CLI from OpenAI can: it has a built-in image generation tool, and codex exec runs Codex without its interactive screen. Claude Code, or any agent with a terminal, calls it like any other command and gets a PNG file back.

    What happens in a call. Codex generates the image and saves it under ~/.codex/generated_images/, in a folder per session. Then it does what the prompt asks for — here, copying the file into the folder the agent works in. If the prompt does not ask for the copy, the file stays under ~/.codex.

    Measured 2026-11-12 with codex-cli 0.156.1 on Windows: one square illustration, 1254×1254 pixels, a 1.4 MB PNG, in 2 minutes 7 seconds.

  3. What to do

    1. Install the Codex CLI (once per machine)

    The Codex CLI needs Node.js. Install it with npm and check the version:

    npm install -g @openai/codex
    codex --version

    Update it later with codex update.

    2. Sign in (once, by a person)

    codex login

    This opens the browser to sign in with a ChatGPT account. The built-in image tool runs on that account; no OpenAI API key is needed. Signing in is the person's job: the agent asks for it and waits.

    Check that image generation is on: in the output of codex features list, the line image_generation must end in true.

    3. Let the agent call Codex

    codex exec --skip-git-repo-check -s workspace-write -C "<scratch folder>" "Generate one image with your built-in image generation tool: <what the image shows, style, format>. Copy the generated file into this folder as images/hero.png. Reply with the saved path only."
    • -C sets the folder Codex works in, and -s workspace-write lets it write only there. Use a scratch folder outside the docly working copy, so drafts are never pushed.
    • --skip-git-repo-check lets Codex run in a folder that is not a git repository.
    • Say what the image shows, the style and the format (square, wide 16:9), and give the file name. One call per image.
    • Give the call time. One image took just over two minutes in the measurement above, which is longer than the two-minute default of Claude Code's shell tool. Set the timeout to five minutes or more, or run the call in the background.

    4. Look at the image before using it

    Claude can open the PNG and see it. Check it against what was asked for. If something is off, ask for a new image with one specific change rather than a new prompt from scratch.

    5. Put it on the site

    Copy the chosen file into the working copy and push it, like any other image. Keep the full-size original and let Docly scale and convert it to WebP or AVIF when it is served — see Scale and convert images in Docly. Images for social sharing must stay JPEG or PNG.

    Icons, diagrams and simple shapes are still better as SVG or CSS: they scale cleanly and can be edited.

Last reviewed 12 Nov 2026