opencode-gpt-imagegen 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yuji Hatakeyama
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # opencode-gpt-imagegen
2
+
3
+ > Bring **GPT image generation** to [OpenCode](https://opencode.ai). Use it through your **ChatGPT subscription** (no API costs!) or through the **OpenAI API** — your call.
4
+
5
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+ [![status](https://img.shields.io/badge/status-v0.1.0-orange.svg)](#roadmap)
7
+
8
+ | Auth path | Status | Billing |
9
+ |---|---|---|
10
+ | **ChatGPT subscription** (OAuth) | **Available now in v0.1.0** | **No extra cost** — comes out of your existing Plus / Pro / Business plan |
11
+ | **OpenAI API key** | **Coming soon in v0.2.0** | Pay-per-image against your API credits, with `generate` + `edit` support |
12
+
13
+ ## Highlights
14
+
15
+ - **Subscription-friendly.** Generations ride on the same Codex backend channel OpenCode already uses for ChatGPT subscription chat — billed against your ChatGPT plan, not your API credits.
16
+ - **Reference images.** Pass any number of input images alongside the prompt for style guidance, edit targets, or compositing inputs.
17
+
18
+ ## Installation
19
+
20
+ *Installation instructions are coming with the upcoming npm release. Stay tuned.*
21
+
22
+ ## Usage
23
+
24
+ Just ask your agent in natural language and `gpt_image_gen` will be picked up.
25
+
26
+ The three examples below are the **actual outputs of this repo's e2e test suite** — see [`tests/e2e.test.ts`](./tests/e2e.test.ts) for the exact prompts and assertions.
27
+
28
+ ### Example A — generate
29
+
30
+ > Draw a man in a navy samue with a red hachimaki, standing in a garden full of cherry blossoms. 90s anime style. Save it as `character.png`, portrait 1024x1536.
31
+
32
+ <p align="center"><img src="./assets/character.png" alt="Example A output: man in samue, portrait" width="320" /></p>
33
+
34
+ ### Example B — auto-versioning
35
+
36
+ `gpt_image_gen` never overwrites an existing file: when the `out` path is already taken, it picks `-v2`, `-v3`, … instead.
37
+
38
+ > Now do the same path but make it a woman in a yellow yukata holding a red wagasa, in a moonlit garden with fireflies. Landscape 1536x1024.
39
+
40
+ The previous `character.png` is left untouched; the new image lands at `character-v2.png`.
41
+
42
+ <p align="center"><img src="./assets/character-v2.png" alt="Example B output: woman in yukata, landscape (auto-versioned)" width="480" /></p>
43
+
44
+ ### Example C — feed existing image files as input
45
+
46
+ Pass any number of image paths via the `images` argument and the model uses them as references for the next generation — for style guidance, characters to keep, scenes to extend, and so on.
47
+
48
+ > Take `character.png` and `character-v2.png` and put both characters together on the engawa of an old Japanese house, smiling at the viewer. 2048x1152, same 90s anime style.
49
+
50
+ <p align="center"><img src="./assets/together.png" alt="Example C output: both characters composed onto an engawa" width="640" /></p>
51
+
52
+ ## Roadmap
53
+
54
+ | Version | Auth path | Scope | Status |
55
+ |---|---|---|---|
56
+ | **v0.1.0** | ChatGPT subscription | `gpt_image_gen` with optional reference images (generation + reference-guided edits via prompting) | **Released** |
57
+ | **v0.2.0** | OpenAI API key | Adds the API-key billing path: both `generate` (`/v1/images/generations`) and `edit` (`/v1/images/edits`) with reference images | Next |
58
+ | **v0.3.0** | OpenAI API key | Adds **pixel-precise mask inpainting** via `/v1/images/edits` (binary PNG alpha mask) | Planned |
59
+
60
+ ## How it works
61
+
62
+ OpenCode already talks to the OpenAI Codex backend to power ChatGPT subscription chat. This plugin reuses that same endpoint, attaching the hosted `image_generation` tool to a single-turn request, then writes the returned PNG to disk. Auth is read from OpenCode's standard `auth.json`; no new credential surface is introduced.
63
+
64
+ ## Disclaimer
65
+
66
+ This is an **unofficial, third-party** plugin, not affiliated with or endorsed by OpenAI or OpenCode.
67
+
68
+ It uses the same Codex backend endpoint OpenCode itself calls for ChatGPT subscription chat — this plugin just adds the hosted `image_generation` tool to that conversation. Use must comply with OpenAI's [Terms of Use](https://openai.com/policies/row-terms-of-use/) and [Usage Policies](https://openai.com/policies/usage-policies/).
@@ -0,0 +1,7 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ declare const _default: {
3
+ id: string;
4
+ server: Plugin;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAS,MAAM,EAA6B,MAAM,qBAAqB,CAAA;;;;;AA6OnF,wBAGwB"}
package/dist/index.js ADDED
@@ -0,0 +1,199 @@
1
+ import * as fs from "node:fs/promises";
2
+ import * as path from "node:path";
3
+ import { tool } from "@opencode-ai/plugin";
4
+ import { EventSourceParserStream } from "eventsource-parser/stream";
5
+ import { fileTypeFromBuffer } from "file-type";
6
+ import { xdgData } from "xdg-basedir";
7
+ // Codex OAuth responses endpoint URL.
8
+ // https://github.com/openai/codex/blob/fca81eeb5bab4cad997622a359d446e6489c445b/codex-rs/model-provider-info/src/lib.rs#L37
9
+ // https://github.com/openai/codex/blob/fca81eeb5bab4cad997622a359d446e6489c445b/codex-rs/core/src/client.rs#L146
10
+ const CODEX_RESPONSES_ENDPOINT = "https://chatgpt.com/backend-api/codex/responses";
11
+ // Codex model slug used for the hosted image_generation turn.
12
+ // https://github.com/openai/codex/blob/fca81eeb5bab4cad997622a359d446e6489c445b/codex-rs/models-manager/models.json#L24
13
+ const SUBSCRIPTION_MODEL = "gpt-5.5";
14
+ const MAX_OUTPUT_VERSION_SUFFIX = 999;
15
+ async function readImageAsDataUrl(filePath, ctxDir) {
16
+ const abs = path.isAbsolute(filePath) ? filePath : path.resolve(ctxDir, filePath);
17
+ const buf = await fs.readFile(abs);
18
+ const detected = await fileTypeFromBuffer(buf);
19
+ if (!detected?.mime.startsWith("image/")) {
20
+ throw new Error(`unsupported image file type: ${abs}`);
21
+ }
22
+ return `data:${detected.mime};base64,${buf.toString("base64")}`;
23
+ }
24
+ async function pathExists(p) {
25
+ try {
26
+ await fs.access(p);
27
+ return true;
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }
33
+ async function pickNonOverwritePath(requested) {
34
+ if (!(await pathExists(requested)))
35
+ return requested;
36
+ const dir = path.dirname(requested);
37
+ const ext = path.extname(requested);
38
+ const stem = path.basename(requested, ext);
39
+ for (let n = 2; n <= MAX_OUTPUT_VERSION_SUFFIX; n++) {
40
+ const candidate = path.join(dir, `${stem}-v${n}${ext}`);
41
+ if (!(await pathExists(candidate)))
42
+ return candidate;
43
+ }
44
+ throw new Error(`could not find a non-conflicting filename under ${dir}/${stem}-vN${ext} (tried up to v${MAX_OUTPUT_VERSION_SUFFIX})`);
45
+ }
46
+ function buildSavedMessage(savedPath, requestedPath) {
47
+ const versionNote = savedPath !== requestedPath
48
+ ? ` (the requested path ${requestedPath} already existed; the new image was versioned to avoid overwriting it)`
49
+ : "";
50
+ return `Generated image saved to ${savedPath}${versionNote}.`;
51
+ }
52
+ // Mirrors OpenCode's auth resolution: OPENCODE_AUTH_CONTENT overrides $XDG_DATA_HOME/opencode/auth.json.
53
+ // The Auth service is not exposed to external plugins, so this reproduces the rules directly.
54
+ async function loadAuthData() {
55
+ if (process.env.OPENCODE_AUTH_CONTENT) {
56
+ return JSON.parse(process.env.OPENCODE_AUTH_CONTENT);
57
+ }
58
+ if (!xdgData) {
59
+ throw new Error("could not determine XDG data directory");
60
+ }
61
+ const raw = await fs.readFile(path.join(xdgData, "opencode", "auth.json"), "utf-8");
62
+ return JSON.parse(raw);
63
+ }
64
+ async function loadOpenAIAuth() {
65
+ try {
66
+ const data = await loadAuthData();
67
+ const entry = data.openai;
68
+ if (entry?.type === "oauth" && typeof entry.access === "string") {
69
+ return entry;
70
+ }
71
+ }
72
+ catch {
73
+ return undefined;
74
+ }
75
+ return undefined;
76
+ }
77
+ async function parseImageGenerationResultFromSSE(stream) {
78
+ const events = stream
79
+ .pipeThrough(new TextDecoderStream())
80
+ .pipeThrough(new EventSourceParserStream());
81
+ for await (const event of events) {
82
+ if (event.data === "[DONE]")
83
+ continue;
84
+ try {
85
+ const json = JSON.parse(event.data);
86
+ if (json.type === "response.output_item.done" &&
87
+ json.item?.type === "image_generation_call" &&
88
+ typeof json.item.result === "string") {
89
+ return json.item.result;
90
+ }
91
+ }
92
+ catch {
93
+ // SSE keepalive or non-JSON heartbeat
94
+ }
95
+ }
96
+ throw new Error("no image_generation result returned by codex backend");
97
+ }
98
+ async function callViaCodexResponses(auth, args, inputImageDataUrls) {
99
+ const userContent = [{ type: "input_text", text: args.prompt }];
100
+ for (const dataUrl of inputImageDataUrls) {
101
+ userContent.push({ type: "input_image", image_url: dataUrl });
102
+ }
103
+ // https://github.com/openai/codex/blob/fca81eeb5bab4cad997622a359d446e6489c445b/codex-rs/core/src/client.rs#L745-L763
104
+ const body = {
105
+ model: SUBSCRIPTION_MODEL,
106
+ instructions: "You are an image generation assistant running inside the Codex backend. " +
107
+ "Always satisfy the request by invoking the image_generation tool exactly once. " +
108
+ "Do not respond with text only.",
109
+ input: [{ role: "user", content: userContent }],
110
+ tools: [
111
+ {
112
+ type: "image_generation",
113
+ output_format: "png",
114
+ quality: args.quality,
115
+ ...(args.size ? { size: args.size } : {}),
116
+ },
117
+ ],
118
+ tool_choice: { type: "image_generation" },
119
+ stream: true,
120
+ store: false,
121
+ };
122
+ const res = await fetch(CODEX_RESPONSES_ENDPOINT, {
123
+ method: "POST",
124
+ headers: {
125
+ "Content-Type": "application/json",
126
+ Authorization: `Bearer ${auth.access}`,
127
+ ...(auth.accountId ? { "ChatGPT-Account-Id": auth.accountId } : {}),
128
+ originator: "opencode",
129
+ Accept: "text/event-stream",
130
+ },
131
+ body: JSON.stringify(body),
132
+ });
133
+ if (!res.ok || !res.body) {
134
+ const detail = await res.text().catch(() => "");
135
+ throw new Error(`codex responses request failed: ${res.status} ${detail.slice(0, 500)}`);
136
+ }
137
+ return parseImageGenerationResultFromSSE(res.body);
138
+ }
139
+ const GptImagePlugin = async (_input) => {
140
+ return {
141
+ tool: {
142
+ gpt_image_gen: tool({
143
+ description: [
144
+ "Generate raster images using OpenAI's hosted image_generation tool.",
145
+ "Use for AI-created bitmap visuals such as photos, illustrations, textures, sprites, and mockups.",
146
+ "Do not use when the task is better handled by editing existing SVG/vector/code-native assets, extending an established icon or logo system, or building the visual directly in HTML/CSS/canvas.",
147
+ "Reference images may be attached through `images`; label each image's role inline in `prompt`, for example: 'Image 1: reference image'.",
148
+ "For many distinct assets, invoke gpt_image_gen once per requested asset rather than relying on multi-image output; gpt_image_gen returns one image per call.",
149
+ "Requires OpenCode to be authenticated with ChatGPT OAuth. Returns the absolute path of the saved PNG.",
150
+ ].join(" "),
151
+ // https://developers.openai.com/api/docs/guides/image-generation
152
+ args: {
153
+ prompt: tool.schema.string().describe("Description of the image to generate."),
154
+ out: tool.schema
155
+ .string()
156
+ .describe("Output file path, relative to the project directory unless absolute. The plugin writes a PNG."),
157
+ quality: tool.schema
158
+ .enum(["low", "medium", "high", "auto"])
159
+ .describe("Generation quality passed to the hosted image_generation tool."),
160
+ size: tool.schema
161
+ .string()
162
+ .optional()
163
+ .describe("Optional image size passed to the hosted image_generation tool. Use `auto` or `WIDTHxHEIGHT`; width and height must be multiples of 16px, max edge <= 3840px, long-to-short ratio <= 3:1, and total pixels between 655,360 and 8,294,400."),
164
+ images: tool.schema
165
+ .array(tool.schema.string())
166
+ .optional()
167
+ .describe("Optional reference image paths, relative to the project directory unless absolute."),
168
+ },
169
+ async execute(args, ctx) {
170
+ const auth = await loadOpenAIAuth();
171
+ if (!auth) {
172
+ throw new Error("OpenAI ChatGPT OAuth credentials not configured.");
173
+ }
174
+ const inputPaths = args.images ?? [];
175
+ const inputImageDataUrls = await Promise.all(inputPaths.map((path) => readImageAsDataUrl(path, ctx.directory)));
176
+ const base64 = await callViaCodexResponses(auth, args, inputImageDataUrls);
177
+ const requestedPath = path.isAbsolute(args.out) ? args.out : path.resolve(ctx.directory, args.out);
178
+ await fs.mkdir(path.dirname(requestedPath), { recursive: true });
179
+ const savedPath = await pickNonOverwritePath(requestedPath);
180
+ await fs.writeFile(savedPath, Buffer.from(base64, "base64"));
181
+ const versioned = savedPath !== requestedPath;
182
+ return {
183
+ output: buildSavedMessage(savedPath, requestedPath),
184
+ metadata: {
185
+ out: savedPath,
186
+ versioned,
187
+ billing: "subscription",
188
+ },
189
+ };
190
+ },
191
+ }),
192
+ },
193
+ };
194
+ };
195
+ export default {
196
+ id: "opencode-gpt-imagegen",
197
+ server: GptImagePlugin,
198
+ };
199
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BA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AG,SAAS,KAAK,aAAa,CAAA;oBAE7C,OAAO;wBACL,MAAM,EAAE,iBAAiB,CAAC,SAAS,EAAE,aAAa,CAAC;wBACnD,QAAQ,EAAE;4BACR,GAAG,EAAE,SAAS;4BACd,SAAS;4BACT,OAAO,EAAE,cAAc;yBACxB;qBACF,CAAA;gBACH,CAAC;aACF,CAAC;SACH;KACF,CAAA;AACH,CAAC,CAAA;AAED,eAAe;IACb,EAAE,EAAE,uBAAuB;IAC3B,MAAM,EAAE,cAAc;CACA,CAAA"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "opencode-gpt-imagegen",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode plugin that exposes a gpt_image_gen tool backed by OpenAI's hosted image_generation tool through the ChatGPT subscription.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "typecheck": "tsc --noEmit",
21
+ "check": "biome check --write .",
22
+ "build": "tsc -p tsconfig.build.json",
23
+ "test": "bun test",
24
+ "test:e2e": "OPENCODE_MODEL=openai/gpt-5.5 RUN_E2E=1 bun test",
25
+ "prepublishOnly": "bun run build"
26
+ },
27
+ "keywords": [
28
+ "opencode",
29
+ "opencode-plugin",
30
+ "openai",
31
+ "gpt-image",
32
+ "image-generation",
33
+ "chatgpt",
34
+ "codex",
35
+ "plugin"
36
+ ],
37
+ "author": "Yuji Hatakeyama",
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/yuji-hatakeyama/opencode-gpt-imagegen.git"
42
+ },
43
+ "homepage": "https://github.com/yuji-hatakeyama/opencode-gpt-imagegen#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/yuji-hatakeyama/opencode-gpt-imagegen/issues"
46
+ },
47
+ "peerDependencies": {
48
+ "@opencode-ai/plugin": "^1.14.0"
49
+ },
50
+ "devDependencies": {
51
+ "@biomejs/biome": "2.4.15",
52
+ "@opencode-ai/plugin": "^1.14.41",
53
+ "@tsconfig/node22": "^22.0.2",
54
+ "@types/bun": "^1.3.14",
55
+ "typescript": "^6.0.3"
56
+ },
57
+ "dependencies": {
58
+ "eventsource-parser": "^3.0.8",
59
+ "file-type": "^22.0.1",
60
+ "xdg-basedir": "^5.1.0"
61
+ }
62
+ }