跪拜 Guibai
← All articles
Frontend · Agent · Claude

Drawing a Cat in Pi Took a Separate Image Login — Then a 1254×1254 Surprise

By jerrywus ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Anyone wiring image generation into a Pi or Codex workflow will hit the same wall: chat auth and image auth are separate, so a missing `/login codex-images` turns a one-line setup into a confusing failure. The same setup shows that model output ignores requested pixel dimensions, so fixed-size assets need an explicit post-generation resize.

Summary

Pi's terminal chat gains image generation through the `pi-codex-image-gen` plugin, which also accepts local or conversation images for editing and supports PNG, JPEG, and WebP. It rides on ChatGPT subscription image credits, so no OpenAI API key or Codex app is needed. The setup prerequisites are Pi 1.1.0+, Node.js 22.19.0+, and a ChatGPT account with image quota; installation is one `pi-bolt install npm:pi-codex-image-gen` command, followed by `/reload` inside the session.

First gotcha: Pi treats chat login and image login as separate credentials. A normal ChatGPT login authorizes chat only, so the first generation fails with `Missing image OAuth credentials` until you run `/login codex-images` in the session and complete browser authorization. Credentials are stored and refreshed by Pi, and re-running that command handles rejection or expiry.

After login, a simple prompt produced a cat, but the requested 200×200 came back as a 1254×1254 backend image. The output reports `Status: completed` and `Saved image to:` a path under `~/.pi/agent/generated-images/<session-id>/`. Exact dimensions need an explicit local resize and a check of the final file. Editing reuses up to five referenced images and consumes more quota; on 429, timeout, or connection errors, the remote side may already have billed the request, so don't resubmit immediately. A separate CLI path exists with `OPENAI_API_KEY` and its own billing, but it only runs when explicitly chosen.

Takeaways
— `pi-codex-image-gen` adds image generation to Pi conversations and supports editing from local or in-chat images in PNG, JPEG, and WebP.
— It uses ChatGPT subscription image credits; no OpenAI API key or Codex app install is required, and every generation counts against the account's image quota.
— Requirements: Pi 1.1.0+ and Node.js 22.19.0+.
— Install with `pi-bolt install npm:pi-codex-image-gen` (or `pi install` on vanilla Pi), then run `/reload` inside a session to load the plugin.
— Pi keeps chat login and image login separate: `/login` with a ChatGPT account enables chat only, and image generation needs `/login codex-images`.
— After login, generation runs through `codex_generate_image`; success shows `Status: completed` and a `Saved image to:` local path.
— The output's `gpt-6-astra` is a router label; the backend picks the actual image model.
— A 200×200 prompt returned a 1254×1254 image; exact sizes require a follow-up local resize and a final dimension check.
— Default save location is `~/.pi/agent/generated-images/<session-id>/`; the `Saved image to:` path tells you the exact file.
— Up to five local or recent conversation images can be referenced in one edit request; edits start new generation requests and consume more quota.
— On 401/403 re-run `/login codex-images`; on 429, quota exhaustion, timeout, or connection failure, don't resubmit immediately because the remote may have already used quota.
— A separate CLI path needs `OPENAI_API_KEY` and bills by API usage; it never auto-falls back from subscription login.
Conclusions

Pi's split between chat and image credentials has a real onboarding cost: the first generation always fails until the user learns a second login exists.

A 200×200 request reaches the backend, but the backend reported 1254×1254, so the tool alone cannot produce fixed-size assets.

The error message names the exact fix (`Run /login codex-images`), but only after a failed call; nothing in the install flow warns that image auth is separate.

Because `gpt-6-astra` is only a router name, users cannot tell which image model actually rendered the output.

Concepts & terms
Pi
A terminal-based AI assistant that runs agentic chat sessions and supports installable plugins; commands are typed in a session input box, not a shell.
Pi-Bolt
A community build of Pi that supports `pi-bolt install`; the same plugin commands work with the vanilla `pi` binary.
Codex Images login
A separate OAuth scope in Pi that authorizes ChatGPT-subscription image generation; it is independent of the normal chat login.
Image quota
The cap on image generations attached to a ChatGPT subscription; each plugin call consumes it, and edits restart generation requests.
gpt-6-astra
The router model name Pi reports for the image tool; it doesn't identify the actual image model, which the backend selects.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗