god-tibo-imagen
v0.2.0
Published
Node.js library and CLI for Codex private ChatGPT-authenticated image generation
Maintainers
Readme
god-tibo-imagen
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.
What it does
- 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/
Requirements
- Node.js 20+
- Existing local Codex ChatGPT login state
- A Codex/ChatGPT account that is entitled to image generation on the private backend
Installation Guide
Prerequisites
- 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
CLI (global)
npm install -g god-tibo-imagenAfter installation, the gti command is available globally:
gti --version
gti --helpNode.js Library
npm install god-tibo-imagenimport { createProvider, resolveConfig } from 'god-tibo-imagen';Python SDK
pip install god-tibo-imagenfrom gti import ClientCLI Usage
npm test
npm run check
gti --prompt "flat blue square icon" --output ./out/blue-square.pngImage input
You 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.
Provider modes
# 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.pngDry run
gti --prompt "flat blue square icon" --dry-runLive smoke test
npm run smoke:live -- "Generate a tiny flat blue square icon." ./smoke-output.pngProgrammatic API (Node.js)
import { 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...']
});
// 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...'
]
});Python SDK
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)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"]
)Quick Start
1. Generate an image via CLI
gti --prompt "flat blue square icon" --output ./out.png2. Use in a Node.js script
import { 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);3. Use in a Python script
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)Key files
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
Notes
- 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.
