SLOPSHOPPER

codex-imagegen

Adds a generate_image tool: Claude hands image requests to the local Codex (ChatGPT) CLI and gets back the saved file.

guardstatustoolprocess
★ 1v0.1.0no licenseupdated 2026-10-17bngxyz/codex-imagegen
A shopper browsing a rack in a slop shop
Preview could not run: Error: codex-imagegen: option "codexPath" is required (full path to codex.exe) at register (file:///inner.js:51:20) at run (inner.js:986:21) at /home/runner/work/slopshopper/slopshopper/sc
README

codex-imagegen

🇬🇧 English · 🇹🇭 ภาษาไทย

A Claude Code mod that lets Claude generate images through ChatGPT. It adds a generate_image tool; when you ask Claude to create an image, Claude hands the request to your local Codex CLI (signed in with your ChatGPT account), and Codex saves the image to disk.

How it works

  1. You ask Claude: "draw an orange cat on a rooftop at sunset, save it to D:\images\cat.png".
  2. Claude calls the generate_image tool with a prompt and an output_path.
  3. The mod runs codex exec with that request. Codex generates the image with its image tool and saves it at output_path.
  4. Claude reads the result and tells you where the file is.

Requirements

  • Claude Code (terminal) with mod / plugin support
  • Codex CLI installed and signed in with ChatGPT (check with codex login status)
  • A ChatGPT plan that includes image generation in Codex

Install

At the prompt of a Claude Code terminal session:

/plugin install codex-imagegen --marketplace bngxyz/codex-imagegen

From a shell:

claude plugin install codex-imagegen --marketplace bngxyz/codex-imagegen

Answer y to "Add marketplace?", pick a scope (user scope = every session), then enter the option below when asked.

In the desktop app, where /plugin does not run: click + next to the prompt box, then Plugins, Add marketplace with bngxyz/codex-imagegen, then Add plugin.

Configure

The mod has one required option, codexPath: the full path to the Codex executable. Without it the mod refuses to load (it never guesses a path).

Find it:

  • Windows (PowerShell): (Get-Command codex).Source
  • Desktop-app installs often live at C:\Users\<you>\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
  • macOS / Linux: which codex

Set it in the plugin's config screen at install time, or in ~/.claude/settings.json:

{
  "pluginConfigs": {
    "codex-imagegen": {
      "options": {
        "codexPath": "C:\\Users\\<you>\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin\\codex.exe"
      }
    }
  }
}

Usage

Just ask Claude for an image and say where to save it:

Generate a watercolor mountain landscape and save it to D:\images\mountain.png

Notes

  • Codex runs with --sandbox workspace-write and --skip-git-repo-check. Generation can take a while (timeout: 10 minutes).
  • Image generation uses your ChatGPT plan's Codex quota.
  • If Codex fails, the tool returns its exit code and the end of its error output.

ภาษาไทย

mod สำหรับ Claude Code ที่ทำให้ Claude สร้างรูปผ่าน ChatGPT ได้ โดยเพิ่มเครื่องมือ generate_image เมื่อคุณสั่งให้ Claude สร้างรูป Claude จะส่งงานต่อให้ Codex CLI ในเครื่องคุณ (ล็อกอินด้วยบัญชี ChatGPT) แล้ว Codex จะบันทึกรูปลงไฟล์ให้

หลักการทำงาน

  1. คุณสั่ง Claude เช่น "วาดแมวส้มนั่งบนหลังคาตอนพระอาทิตย์ตก เซฟที่ D:\images\cat.png"
  2. Claude เรียกเครื่องมือ generate_image พร้อม prompt และ output_path
  3. mod รัน codex exec ส่งคำขอนั้นให้ Codex สร้างรูปและบันทึกไว้ที่ output_path
  4. Claude อ่านผลลัพธ์แล้วบอกคุณว่าไฟล์อยู่ที่ไหน

สิ่งที่ต้องมี

  • Claude Code (เทอร์มินัล) ที่รองรับ mod / plugin
  • ติดตั้ง Codex CLI และล็อกอินด้วย ChatGPT แล้ว (เช็คด้วย codex login status)
  • แพ็กเกจ ChatGPT ที่ใช้สร้างรูปใน Codex ได้

วิธีติดตั้ง

พิมพ์ใน Claude Code (เทอร์มินัล):

/plugin install codex-imagegen --marketplace bngxyz/codex-imagegen

หรือจาก shell:

claude plugin install codex-imagegen --marketplace bngxyz/codex-imagegen

ตอบ y เมื่อถามว่า "Add marketplace?" เลือก scope (user scope = ใช้ได้ทุก session) แล้วใส่ค่า option ด้านล่างเมื่อถูกถาม

ถ้าใช้แอป desktop ซึ่งไม่รองรับ /plugin: กดปุ่ม + ข้างช่องพิมพ์ → Plugins → Add marketplace ใส่ bngxyz/codex-imagegen → Add plugin

การตั้งค่า

mod มี option ที่ต้องกรอกหนึ่งตัวคือ codexPath (path เต็มของไฟล์ Codex) ถ้าไม่ตั้ง mod จะไม่โหลด เพราะไม่เดา path ให้

วิธีหา path:

  • Windows (PowerShell): (Get-Command codex).Source
  • ถ้าติดตั้งจากแอป Codex มักอยู่ที่ C:\Users\<ชื่อคุณ>\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
  • macOS / Linux: which codex

ตั้งค่าในหน้า config ตอนติดตั้ง หรือแก้ ~/.claude/settings.json:

{
  "pluginConfigs": {
    "codex-imagegen": {
      "options": {
        "codexPath": "C:\\Users\\<ชื่อคุณ>\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin\\codex.exe"
      }
    }
  }
}

วิธีใช้

สั่ง Claude ให้สร้างรูปและบอกที่เซฟได้เลย เช่น

สร้างรูปภูเขาสไตล์สีน้ำ เซฟที่ D:\images\mountain.png

หมายเหตุ

  • Codex รันด้วย --sandbox workspace-write และ --skip-git-repo-check การสร้างรูปอาจใช้เวลานาน (timeout 10 นาที)
  • การสร้างรูปใช้โควตา Codex ของแพ็กเกจ ChatGPT ของคุณ
  • ถ้า Codex ล้มเหลว เครื่องมือจะคืนค่า exit code และท้าย error ให้ดู
Source 1 files
hooks/register.ts 74 lines
1import type { Register } from 'claude-code'
2
3const TOOL = 'mcp__codex-imagegen__generate_image'
4
5export const register: Register = (on, options) => {
6  const codexPath = options.codexPath
7  if (typeof codexPath !== 'string' || codexPath === '') {
8    throw new Error('codex-imagegen: option "codexPath" is required (full path to codex.exe)')
9  }
10
11  on('session.start', async ($, e, next) => {
12    await $.tool.register({
13      name: 'generate_image',
14      description:
15        'Generate an image by delegating to ChatGPT via the local Codex CLI. ' +
16        'Use this whenever the user asks to create/draw/generate an image. ' +
17        'Codex saves the image to output_path; the tool returns that path.',
18      inputSchema: {
19        type: 'object',
20        properties: {
21          prompt: { type: 'string', description: 'Detailed description of the image to generate.' },
22          output_path: {
23            type: 'string',
24            description: 'Absolute path of the PNG file to save, e.g. D:\\images\\cat.png.',
25          },
26        },
27        required: ['prompt', 'output_path'],
28      },
29      isDeferred: false,
30    })
31    return next(e)
32  })
33
34  on('tool.call', { tool: TOOL }, async ($, e) => {
35    const { prompt, output_path } = e as unknown as { prompt?: unknown; output_path?: unknown }
36    if (typeof prompt !== 'string' || prompt === '') {
37      return { deny: 'generate_image: "prompt" is required.' }
38    }
39    if (typeof output_path !== 'string' || output_path === '') {
40      return { deny: 'generate_image: "output_path" is required.' }
41    }
42
43    $.ui.status('Codex: generating image…')
44    try {
45      const instruction =
46        'Use your image generation tool to create the following image, then save the ' +
47        `resulting image file exactly at this absolute path: ${output_path}\n` +
48        'Reply with only the final saved path, or an error message if you could not.\n\n' +
49        `Image request:\n${prompt}`
50
51      const run = await $.process.run(
52        [
53          codexPath,
54          'exec',
55          '--skip-git-repo-check',
56          '--sandbox',
57          'workspace-write',
58          '--color',
59          'never',
60          '-',
61        ],
62        { stdin: instruction, timeoutMs: 600000 },
63      )
64
65      if (run.exitCode !== 0) {
66        return { result: `Codex failed (exit ${run.exitCode}): ${run.stderr.slice(-2000)}`, isError: true }
67      }
68      return { result: `Codex finished. Output:\n${run.stdout.trim()}\nExpected file: ${output_path}` }
69    } finally {
70      $.ui.status(undefined)
71    }
72  })
73}
74