GitHub - ktkarchive/codex-imagegen-2-skill-for-kimi
Key Points
- 1This project offers a Kimi CLI skill that generates and transforms images using OpenAI Codex via a ChatGPT Plus/Pro subscription and an OAuth proxy.
- 2It supports text-to-image generation, image style transformation, and PNG validation, requiring Node.js and a Codex CLI login to manage authentication sessions.
- 3Users can configure output settings, save generated images locally, and benefit from features like automatic proxy management, parallel generation, and built-in error handling.
This project, codex-imagegen-2-skill-for-kimi, is a Node.js-based application designed to facilitate image generation and manipulation using the OpenAI Codex OAuth proxy, primarily integrated as a skill for the Kimi CLI, but also usable as standalone scripts. Its core functionality revolves around leveraging a ChatGPT Plus/Pro subscription to access OpenAI's image generation capabilities.
The methodology involves establishing an OAuth session with OpenAI's Codex API. This is achieved by executing npx @openai/codex login, which creates an authentication token in ~/.codex/auth.json. The skill then automatically manages a local OAuth proxy, launching it on port 10531 as needed to mediate requests to the OpenAI API. Upon process termination, the proxy is automatically cleaned up.
The system supports two primary image generation modalities:
- Text-to-Image Synthesis: Users provide a textual prompt (e.g., "cyberpunk city night"), and the system generates an image based on this description.
- Image-to-Image Transformation (Style Transfer/Editing): Users provide an existing image file and a textual prompt describing the desired modification or style transformation (e.g., "change to watercolor painting"), and the system returns a new image.
Key operational parameters configurable via config.json or command-line arguments include quality (low, medium, high), size (1024x1024, 1024x1536, 1536x1024), format (png, jpeg, webp), and n (number of parallel generations, 1-8). Generated images are stored in a specified output directory, defaulting to ~/Pictures/codex-images/.
The project offers two primary deployment methods:
- Kimi CLI Skill Integration: By cloning the repository into
~/.kimi/skills/, it becomes directly callable via natural language prompts within the Kimi CLI environment. - Standalone Script Execution: Dedicated Node.js scripts (
generate.js,edit.js,verify.js) allow for direct programmatic interaction.generate.jsperforms text-to-image synthesis,edit.jshandles image-to-image transformations, andverify.jsis a utility for validating PNG integrity (e.g., corruption, dimensions).
Robust features include automatic OAuth proxy management with retry logic for startup failures, parallel image generation capabilities (up to 8 images concurrently), post-generation PNG integrity validation, and comprehensive historical logging of all generation activities to history.jsonl. Troubleshooting mechanisms are provided for common issues like "No OAuth session" (requiring re-login), "Proxy failed to start" (suggesting port cleanup), and "401/403" authentication errors (implying OAuth token expiration). The project requires Node.js version 18 or greater and an active ChatGPT Plus/Pro subscription. It is distributed under the MIT License.