Node.js library and CLI for sending image-generation requests to Codex's private ChatGPT-authenticated backend path.
WARNING: This is not a supported public API integration. It depends on private Codex request behavior that may change without notice.
- Reuses local Codex ChatGPT auth from
~/.codex/auth.json - Reads
~/.codex/installation_idwhen available - Sends a
POSTrequest tohttps://chatgpt.com/backend-api/codex/responses - Requests the built-in
image_generationtool withoutput_format: png - Parses streamed SSE output and saves the resulting PNG
- Supports dry-run and sanitized debug dumps with request/response metadata minimization
- Also supports a
codex execfallback provider that verifies real PNG output from~/.codex/generated_images/
- Node.js 20+
- Existing local Codex ChatGPT login state
- A Codex/ChatGPT account that is entitled to image generation on the private backend
- Node.js 20+ (for CLI and Node.js library)
- Python 3.10+ (for Python SDK)
- Existing local Codex ChatGPT login state (
~/.codex/auth.json) - A Codex/ChatGPT account entitled to image generation on the private backend
npm install -g god-tibo-imagenAfter installation, the gti command is available globally:
gti --version
gti --helpnpm install god-tibo-imagenimport { createProvider, resolveConfig } from 'god-tibo-imagen';pip install god-tibo-imagenfrom gti import Clientnpm test
npm run check
gti --prompt "flat blue square icon" --output ./out/blue-square.pngYou can provide existing images as additional context alongside your text prompt. Images are embedded as base64 data URLs and sent with the request. Use --image multiple times for multiple images.
# single image
gti --prompt "Make this cat wear a hat" --image ./cat.png --output ./cat-hat.png
# multiple images
gti --prompt "Combine these two styles" --image ./style-a.png --image ./style-b.png --output ./combined.pngSupported formats: png, jpg/jpeg, gif, webp.
Pass --size <value> to control the output image dimensions. Supported values match the gpt-image-2 spec:
gti --prompt "a sunset over mountains" --size 1536x1024 --output ./sunset.pngSupported sizes:
auto(model decides)1024x1024,2048x2048(square)1536x1024,2048x1152,3840x2160(landscape)1024x1536,2160x3840(portrait)
The --size flag is forwarded to the image_generation tool config and is honored by the private Codex backend. The codex-cli provider does not support --size; direct codex-cli use and auto fallback fail fast rather than silently ignoring requested dimensions.
# direct private HTTP path
gti --provider private-codex --prompt "flat blue square icon" --output ./out.png
# borrow the Hermes-style codex exec workaround
gti --provider codex-cli --prompt "flat blue square icon" --output ./out.png
# try private HTTP first, then fall back to codex-cli
gti --provider auto --prompt "flat blue square icon" --output ./out.pnggti --prompt "flat blue square icon" --dry-runnpm run smoke:live -- "Generate a tiny flat blue square icon." ./smoke-output.pngimport { createProvider, resolveConfig, loadCodexSession, validateCodexSession } from 'god-tibo-imagen';
const config = resolveConfig({ provider: 'private-codex' });
const provider = createProvider(config);
const result = await provider.generateImage({
prompt: 'flat blue square icon',
model: 'gpt-5.4',
outputPath: './out.png',
dryRun: false,
debug: false
});
console.log(result.savedPath);You can also pass existing images as input:
// single image
const result = await provider.generateImage({
prompt: 'Make this cat wear a hat',
model: 'gpt-5.4',
outputPath: './cat-hat.png',
images: ['data:image/png;base64,iVBORw0KGgo...']
});
// with output size
const result = await provider.generateImage({
prompt: 'a sunset over mountains',
model: 'gpt-5.4',
outputPath: './sunset.png',
size: '1536x1024'
});
// multiple images
const result = await provider.generateImage({
prompt: 'Combine these two styles',
model: 'gpt-5.4',
outputPath: './combined.png',
images: [
'data:image/png;base64,abc...',
'data:image/png;base64,def...'
]
});from gti import Client
client = Client(provider="private-codex")
result = client.generate_image(
prompt="flat blue square icon",
model="gpt-5.4",
output_path="./out.png"
)
print(result.saved_path)
# with output size
result = client.generate_image(
prompt="a sunset over mountains",
model="gpt-5.4",
output_path="./sunset.png",
size="1536x1024"
)
print(result.saved_path)You can also pass existing images as input:
# single image
result = client.generate_image(
prompt="Make this cat wear a hat",
model="gpt-5.4",
output_path="./cat-hat.png",
image_paths="./cat.png"
)
# multiple images
result = client.generate_image(
prompt="Combine these two styles",
model="gpt-5.4",
output_path="./combined.png",
image_paths=["./style-a.png", "./style-b.png"]
)gti --prompt "flat blue square icon" --output ./out.pngimport { createProvider, resolveConfig } from 'god-tibo-imagen';
const config = resolveConfig({ provider: 'private-codex' });
const provider = createProvider(config);
const result = await provider.generateImage({
prompt: 'flat blue square icon',
model: 'gpt-5.4',
outputPath: './out.png',
});
console.log(result.savedPath);from gti import Client
client = Client(provider="private-codex")
result = client.generate_image(
prompt="flat blue square icon",
model="gpt-5.4",
output_path="./out.png"
)
print(result.saved_path)With image inputs:
result = client.generate_image(
prompt="Make this cat wear a hat",
model="gpt-5.4",
output_path="./cat-hat.png",
image_paths="./cat.png"
)
print(result.saved_path)For users who want to invoke god-tibo-imagen from within any coding agent that supports the Agent Skills format (Claude Code, Codex, Cursor, OpenCode, Continue, Gemini CLI, etc.), a portable skill is provided in skills/god-tibo-imagen/.
- Python 3.10+
pip install god-tibo-imagen(the import name isgti, notgod_tibo_imagen)- Local Codex auth in
~/.codex/auth.jsonwithauth_mode = chatgpt
# Dry run
python skills/god-tibo-imagen/scripts/wrapper.py --prompt "flat blue square icon" --output ./test.png --dry-run
# Live generation
python skills/god-tibo-imagen/scripts/wrapper.py --prompt "flat blue square icon" --output ./out.png
# With image inputs
python skills/god-tibo-imagen/scripts/wrapper.py --prompt "Make this cat wear a hat" --image ./cat.png --output ./cat-hat.pngThe skill definition is at skills/god-tibo-imagen/SKILL.md. Install it by copying or symlinking the skills/god-tibo-imagen/ directory into your agent's skills path:
- Claude Code:
~/.claude/skills/god-tibo-imagen/ - Codex:
~/.codex/skills/god-tibo-imagen/(or project-local.agents/skills/god-tibo-imagen/) - OpenCode:
~/.config/opencode/skills/god-tibo-imagen/ - Cursor / Continue / Gemini CLI / Kiro:
.agents/skills/god-tibo-imagen/(project)
Or use the Vercel skills CLI:
npx skills add NomaDamas/god-tibo-imagen --skill god-tibo-imagenSee skills/god-tibo-imagen/README.md for detailed installation per agent.
src/auth/loadCodexSession.js— reads Codex auth statesrc/auth/validateSession.js— validates required private-backend fieldssrc/codex/buildResponsesRequest.js— builds the/responsesrequestsrc/codex/streamResponsesSse.js— parses SSE eventssrc/codex/extractImageGeneration.js— findsimage_generation_callsrc/providers/privateCodexProvider.js— live request/response orchestrationsrc/providers/codexCliProvider.js— Hermes-stylecodex execfallback with file verificationsrc/providers/createProvider.js— provider selection and auto fallbacksrc/cli/generate.js— CLI entry point
- This MVP supports the file-backed
~/.codex/auth.jsonpath. - If your Codex install stores auth only in a keyring and does not materialize
auth.json, this MVP will not discover it yet. - Debug dumps redact bearer tokens, account/session identifiers, installation IDs, cookies, and image payload base64, and store a minimized response summary instead of the raw response body.
- The architecture now supports both the direct private HTTP client and a Hermes-style
codex execfallback, while keeping the provider seam open for futureapp-serverintegration.