{"_id":"@adaptive-ds/codex-imagen","_rev":"2-66c69665cb52dd3260bebea9952e7975","name":"@adaptive-ds/codex-imagen","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@adaptive-ds/codex-imagen","version":"0.1.0","keywords":["codex-lb","openai","images","image-generation","image-grid","typescript","valibot"],"license":"MIT","_id":"@adaptive-ds/codex-imagen@0.1.0","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"homepage":"https://github.com/david1gp/codex-imagen","bugs":{"url":"https://github.com/david1gp/codex-imagen/issues"},"dist":{"shasum":"7319faed2dac6cae9b0a27c78fdeb7803d12a8bf","tarball":"https://registry.npmjs.org/@adaptive-ds/codex-imagen/-/codex-imagen-0.1.0.tgz","fileCount":95,"integrity":"sha512-1DpUyz7TEmzLsCYTFWIhmE4CMofE9whM03rXoYbk6Biym34qZKVWEmX6mUD0eN7lFHYUDDuW/6kkjxjGXr76Fg==","signatures":[{"sig":"MEUCIEavLPjjN+i4TPxlG/TYi0hRblBQjk94i8U71OGSi/inAiEAzkY7gBuE9X2y8EQfgE491oRojrk3fU7OkzWHeIqdLWI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":95633},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./*.js":{"types":"./dist/*.d.ts","import":"./dist/*.js"}},"gitHead":"06803f2615037224002470652adc31af010321c6","imports":{"#result":"@adaptive-ds/result"},"private":false,"scripts":{"test":"bun test","build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json","format":"bunx biome check --write src","release":"bash ./ops/release.sh"},"_npmUser":{"name":"david1gp","email":"david1gruppenplan@gmail.com"},"repository":{"url":"git+https://github.com/david1gp/codex-imagen.git","type":"git"},"_npmVersion":"10.9.4","description":"Type-safe codex-lb/OpenAI-compatible image generation helpers for singles, edits, and packed image grids.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"@adaptive-ds/result":"^0.6.0"},"_hasShrinkwrap":false,"devDependencies":{"valibot":"^1.3.1","@types/bun":"latest","typescript":"^6.0.3","@types/node":"^25.6.0","@biomejs/biome":"^2.4.11"},"peerDependencies":{"valibot":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/codex-imagen_0.1.0_1783065209327_0.9870871060778001","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@adaptive-ds/codex-imagen","version":"0.2.0","main":"./dist/index.js","types":"./dist/index.d.ts","bin":{"codex-imagen":"dist/cli.js"},"exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"},"./*.js":{"types":"./dist/*.d.ts","import":"./dist/*.js"}},"imports":{"#result":"@adaptive-ds/result"},"scripts":{"build":"rm -rf ./dist && bun tsc -p ./tsconfig.lib.json && chmod +x ./dist/cli.js","format":"biome format --write src package.json tsconfig.json tsconfig.lib.json biome.json","release":"bash ./ops/release.sh","test":"bun test"},"peerDependencies":{"@adaptive-ds/result":"^0.6.0","valibot":"^1.2.0"},"devDependencies":{"@biomejs/biome":"^2.5.2","@types/bun":"latest","@types/node":"^25.6.0","typescript":"^6.0.3","valibot":"^1.3.1"},"description":"Type-safe codex-lb/OpenAI-compatible image generation helpers for singles, edits, and packed image grids.","homepage":"https://github.com/david1gp/codex-imagen","keywords":["codex-lb","openai","images","image-generation","image-grid","typescript","valibot"],"license":"MIT","private":false,"repository":{"type":"git","url":"git+https://github.com/david1gp/codex-imagen.git"},"type":"module","dependencies":{"@stricli/core":"^1.3.0","dotenv":"^17.4.2"},"gitHead":"7e67b533f18023db80114159265ef468e5c33d61","_id":"@adaptive-ds/codex-imagen@0.2.0","bugs":{"url":"https://github.com/david1gp/codex-imagen/issues"},"_nodeVersion":"24.19.0","_npmVersion":"12.0.2","dist":{"integrity":"sha512-kHRsxPCpG4MM5g3re1140yqu4sVrU3FkM40WUgA/sT72RJYKt5MydOpUwyR2gvyYrEDk9kiAXfTohTocsCmgKg==","shasum":"52744e60c34e40972a20939ba3e3747e52455090","tarball":"https://registry.npmjs.org/@adaptive-ds/codex-imagen/-/codex-imagen-0.2.0.tgz","fileCount":135,"unpackedSize":150538,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaptive-ds%2fcodex-imagen@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEhUvK7f0JdF6NAfj3SXYWTfytRMouXbur45bQUKa4YSAiEA4m3DjoiC2WCHuvr4eymLDpxDtXh1LmCXqsS0n7VZpJM="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:27ccf444-19d6-40e8-a71f-dbb695f3d551"}},"directories":{},"maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/codex-imagen_0.2.0_1787823280530_0.10208490829656869"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-03T07:53:29.122Z","modified":"2026-08-27T09:34:40.948Z","0.1.0":"2026-07-03T07:53:29.450Z","0.2.0":"2026-08-27T09:34:40.670Z"},"bugs":{"url":"https://github.com/david1gp/codex-imagen/issues"},"license":"MIT","homepage":"https://github.com/david1gp/codex-imagen","keywords":["codex-lb","openai","images","image-generation","image-grid","typescript","valibot"],"repository":{"type":"git","url":"git+https://github.com/david1gp/codex-imagen.git"},"description":"Type-safe codex-lb/OpenAI-compatible image generation helpers for singles, edits, and packed image grids.","maintainers":[{"name":"david1gp","email":"david1gruppenplan@gmail.com"}],"readme":"# @adaptive-ds/codex-imagen\n\nType-safe TypeScript helpers for codex-lb/OpenAI-compatible image generation.\n\n## Scope\n\n- Generate single images with caller-provided `baseUrl`, `apiKey`, timeout, and optional `fetch`.\n- Edit existing images with MIME-aware multipart uploads.\n- Validate image options at runtime with Valibot before network calls.\n- Plan efficient packed image grids with gpt-image-2 size constraints.\n- Slice generated grids into individual cell images with ImageMagick.\n- Return `Result<T>` values instead of throwing from fallible exported functions.\n\n## Source Layout\n\n- `src/edit`: image edit endpoint helpers.\n- `src/generate_single`: single image generation endpoint helpers.\n- `src/generate_grid_single`: single-request packed grid planning, generation, and slicing helpers.\n- `src/generate_grid_multiple`: multi-request grid planning/generation helpers that preserve minimum cell resolution.\n- `src/shared`: common schemas, request validation, response writing, and image option utilities.\n\n## Example\n\n```ts\nimport { codexImageGenerate, imageGridPlan } from \"@adaptive-ds/codex-imagen\"\n\nconst planResult = imageGridPlan({\n  cellAspect: 1,\n  desiredCellShortEdgePx: 256,\n  cellCount: 4,\n})\nif (!planResult.success) return planResult\n\nconst result = await codexImageGenerate({\n  client: {\n    baseUrl: process.env.CODEX_IMAGE_BASE_URL ?? \"\",\n    apiKey: process.env.CODEX_IMAGE_API_KEY ?? \"\",\n  },\n  prompt: \"four clear square app icons in a 2x2 grid\",\n  outputPath: \"./out/grid.png\",\n  size: planResult.data.requestSize,\n  background: \"opaque\",\n})\n```\n\nLibrary callers still supply client configuration directly; library workflows do not load environment variables or key files.\n\n## CLI\n\nInstall the package, then invoke the executable with `bunx` (or install it globally and use `codex-imagen` directly):\n\n```sh\nbun add @adaptive-ds/codex-imagen\nbunx codex-imagen --help\n```\n\nThe CLI exposes only `generate` and `edit`. It reads these credentials:\n\n```dotenv\nCODEX_IMAGE_BASE_URL=https://your-image-endpoint.example\nCODEX_IMAGE_API_KEY=your-api-key\n```\n\nBy default it loads `.env` from the current working directory. A missing default `.env` is allowed, and existing environment variables take precedence over values loaded from it. Use `--dotenv-path PATH` to require a specific dotenv file.\n\nCommon flags:\n\n| Flag | Values | Default |\n| --- | --- | --- |\n| `--dotenv-path` | Dotenv file path | `.env` in the current working directory; missing file allowed |\n| `--request-timeout-ms` | Positive integer milliseconds | `300000` |\n| `--help` | — | — |\n\n### `generate`\n\n```sh\nbunx codex-imagen generate \\\n  --prompt \"A clear glass orb on a blue background\" \\\n  --output-path ./out/orb.png\n```\n\nRequired flags: `--prompt`, `--output-path`.\n\n| Flag | Values | Default |\n| --- | --- | --- |\n| `--model` | `gpt-image-2`, `gpt-image-1.5`, `gpt-image-1`, `gpt-image-1-mini` | `gpt-image-2` |\n| `--size` | `auto` or `WxH` | `2048x1152` |\n| `--quality` | `low`, `medium`, `high`, `auto` | `auto` |\n| `--background` | `transparent`, `opaque`, `auto` | `auto` |\n| `--output-format` | `png`, `jpeg`, `webp` | `png` |\n| `--output-compression` | Integer `0`–`100` | `100` |\n| `--moderation` | `auto`, `low` | `auto` |\n| `--user` | String | — |\n| `--write-txt` | Boolean; use `--write-txt=false` to disable | `true` |\n\n### `edit`\n\n```sh\nbunx codex-imagen edit \\\n  --input-image-path ./in/source.png \\\n  --prompt \"Replace the background with a sunset\" \\\n  --output-path ./out/edited.png \\\n  --mask-path ./in/mask.png \\\n  --input-fidelity high\n```\n\nRequired flags: `--input-image-path`, `--prompt`, `--output-path`.\n\nEdit-only flags are `--mask-path` (optional path, omitted by default) and `--input-fidelity` (`low` or `high`, omitted by default). Edit also accepts the `generate` flags above, with these defaults: `--size 1536x1024`; all other shared image-option defaults are unchanged.\n\nSuccessful commands print the output image path to stdout; failures use a nonzero exit status and stderr.\n","readmeFilename":"README.md"}