{"id":51419687,"url":"https://github.com/tolo/image_gen_cli","last_synced_at":"2026-07-04T23:01:28.194Z","repository":{"id":366621053,"uuid":"1271547624","full_name":"tolo/image_gen_cli","owner":"tolo","description":"A simple CLI for image generation","archived":false,"fork":false,"pushed_at":"2026-06-22T15:04:03.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-22T17:05:42.714Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tolo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-06-16T19:18:06.000Z","updated_at":"2026-06-22T15:04:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tolo/image_gen_cli","commit_stats":null,"previous_names":["tolo/image_gen_cli"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tolo/image_gen_cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolo%2Fimage_gen_cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolo%2Fimage_gen_cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolo%2Fimage_gen_cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolo%2Fimage_gen_cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tolo","download_url":"https://codeload.github.com/tolo/image_gen_cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolo%2Fimage_gen_cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35138079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-04T23:01:27.489Z","updated_at":"2026-07-04T23:01:28.189Z","avatar_url":"https://github.com/tolo.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# image-gen\n\nA Dart CLI that generates images with OpenAI's **`gpt-image-2`** model using\nyour **ChatGPT-subscription** credentials — reusing the OAuth tokens the Codex\nCLI stores in `~/.codex/auth.json`. No billed API key required (though an\n`sk-` key is supported as an alternate route).\n\n## How it works (ChatGPT-subscription route)\n\nImage generation is **not** a standalone endpoint on the ChatGPT backend\n(`/codex/images/generations` returns 404). Instead it runs through the Codex\nResponses endpoint using the built-in `image_generation` tool:\n\n```\nPOST https://chatgpt.com/backend-api/codex/responses\n  Authorization: Bearer \u003caccess_token\u003e        # from ~/.codex/auth.json\n  chatgpt-account-id: \u003caccount_id\u003e\n  originator: codex_cli_rs                     # required to clear Cloudflare\n  OpenAI-Beta: responses=experimental\n  Accept: text/event-stream\n\n  { \"model\": \"gpt-5.5\",                         # a Codex-allowed *chat* model (carrier)\n    \"instructions\": \"You are an image generation assistant.\",\n    \"input\": [{ \"role\":\"user\", \"content\":[{\"type\":\"input_text\",\"text\": \u003cprompt\u003e}] }],\n    \"tools\": [{ \"type\":\"image_generation\",      # the image model lives HERE\n                \"model\":\"gpt-image-2\", \"size\":\"1024x1024\", \"quality\":\"medium\",\n                \"output_format\":\"png\", \"background\":\"opaque\" }],\n    \"tool_choice\": { \"type\":\"image_generation\" }, \"stream\": true }\n```\n\nThe response is an SSE stream; the final PNG arrives base64-encoded in the\n`image_generation_call` item's `result`.\n\n\u003e **Carrier model drifts.** The top-level chat model accepted by the Codex\n\u003e backend for ChatGPT accounts changes over time (e.g. `gpt-5.5`). If you see\n\u003e *\"model is not supported when using Codex\"*, set a newer one via\n\u003e `--chat-model` or `$GPT_IMAGE_CHAT_MODEL`. This does **not** change the image\n\u003e model (`--model`, default `gpt-image-2`).\n\nRequires a paid ChatGPT plan (Plus/Pro). Run `codex login` first so the\ncredentials exist. Tokens are refreshed automatically against\n`https://auth.openai.com/oauth/token` when expired.\n\n## Install\n\nPrebuilt binaries are published for **macOS** (arm64/x64), **Linux** (arm64/x64),\nand **Windows** (x64) on each [GitHub release](https://github.com/tolo/image_gen_cli/releases).\n\n**Homebrew** (macOS / Linux):\n\n```bash\nbrew install tolo/image-gen/image-gen\n```\n\n**Scoop** (Windows):\n\n```powershell\nscoop bucket add image-gen https://github.com/tolo/scoop-image-gen\nscoop install image-gen\n```\n\n**Manual download:** grab the archive for your platform from the release page,\nverify it against `SHA256SUMS.txt`, extract, and put `image-gen` on your `PATH`:\n\n```bash\ntar xzf image-gen-v\u003cversion\u003e-\u003cos\u003e-\u003carch\u003e.tar.gz     # .zip on Windows\nsudo mv image-gen /usr/local/bin/\nimage-gen --version\n```\n\n**Build from source** (needs the Dart SDK `^3.6.0`):\n\n```bash\ncd ~/Repos/Tools/image_gen_cli\n./build.sh                                           # compiles build/image-gen (native AOT)\nln -sf \"$PWD/image-gen\" /usr/local/bin/image-gen     # optional: put on PATH\n```\n\nThe `image-gen` launcher runs the compiled binary if present, else `dart run`.\nSee [docs/RELEASING.md](docs/RELEASING.md) for how releases are cut.\n\n## Usage\n\n```bash\nimage-gen \"a cute origami fox, flat vector, soft pastel colors\" -a landscape -q medium -o fox.png\n\n# Probe that generation is reachable with current credentials:\nimage-gen --check\n\n# Force the official API-key route instead of the subscription:\nimage-gen \"a logo\" --api-key sk-... -m gpt-image-1\n```\n\n### Options\n\n| Flag | Description | Values / default |\n|------|-------------|------------------|\n| `-p, --prompt` | Prompt (or pass positionally / via stdin) | |\n| `-m, --model` | Image model | `gpt-image-2` (or `$GPT_IMAGE_MODEL`) |\n| `--chat-model` | Carrier chat model (OAuth route; drifts) | `gpt-5.5` (or `$GPT_IMAGE_CHAT_MODEL`) |\n| `-q, --quality` | Render quality | `low` `medium` `high` `auto` (default) |\n| `-a, --aspect` | Aspect preset → fixed size | `square` `portrait` `landscape` `auto` |\n| `-s, --size` | Explicit size (overrides `--aspect`) | `1024x1024` `1024x1536` `1536x1024` `auto` |\n| `-b, --background` | Background handling | `transparent` `opaque` `auto` |\n| `-f, --format` | Output format | `png` `jpeg` `webp` |\n| `--n` | Number of images | `1` |\n| `-o, --out` | Output file or base name | `image-\u003ctimestamp\u003e` |\n| `--auth-file` | Path to Codex `auth.json` | `~/.codex/auth.json` |\n| `--api-key` | Use this API key (forces official API route) | |\n| `--use-key` | Use the API key found in `auth.json`/env instead of OAuth | |\n| `--check` | Probe reachability, then exit | |\n| `-v, --verbose` | Verbose output | |\n| `--version` | Print version, then exit | |\n\n**Aspect → size mapping** (GPT-Image supports only fixed sizes, not free-form\naspect ratios): `square→1024x1024`, `portrait→1024x1536`,\n`landscape→1536x1024`.\n\n## Credential selection order\n\n1. `--api-key sk-...`\n2. `OPENAI_API_KEY` environment variable (only if `--use-key`, else OAuth wins)\n3. `--use-key`: API key stored inside `auth.json`\n4. **ChatGPT OAuth tokens in `auth.json`** (the default, working route)\n\n## Two backends\n\n| Route | Endpoint | Auth | Model param |\n|-------|----------|------|-------------|\n| **ChatGPT subscription** (default) | `…/codex/responses` + `image_generation` tool | Codex OAuth token | carrier `--chat-model` + image `--model` |\n| OpenAI API key | `/v1/images/generations` | `sk-` key | single `--model` (use `gpt-image-1`) |\n\n## Development\n\n```bash\ndart pub get\ndart analyze\ndart test\ndart format --line-length=120 .\n```\n\n## Notes\n\nThis relies on the same first-party Codex transport the `codex` CLI uses\n(including spoofing the `codex_cli_rs` originator to pass Cloudflare). The\nCodex backend's accepted chat-model allow-list is undocumented and drifts;\n`--chat-model` exists so you can track it without rebuilding.\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftolo%2Fimage_gen_cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftolo%2Fimage_gen_cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftolo%2Fimage_gen_cli/lists"}