This is a Python-based toolset for downloading, archiving, and browsing images generated via ChatGPT (4o Image Generator). It stores all images in versioned folders and generates static HTML galleries for easy viewing.
gallery/
├── v1/
│ ├── images/
│ ├── metadata_v1.json
│ ├── page_1.html, page_2.html, ...
├── v2/
│ └── ...
├── index.html ← main entry point
auth.txt ← credentials for API access
- Python 3.7+
- Internet connection
- Your browser access to chat.openai.com
None required beyond standard requests, concurrent.futures, tqdm and json.
This file is required for authenticated API access. Here's what it must contain:
url=https://chat.openai.com/backend-api/my/recent/image_gen?limit=100
authorization=Bearer <your_token_here>
cookie=__Secure-next-auth.session-token=<your_cookie_here>
referer=https://chat.openai.com/library
user_agent=Mozilla/5.0 (...)
oai_client_version=...
oai_device_id=...
oai_language=...
- Log into https://chat.openai.com/library
- Open Developer Tools (in Chrome, by pressing F12) → Network tab → Fetch/XHR
- Scroll down the page to load new images in the library
- Find any request to
image_gen: they should look likeimage_gen?limit=6&after.... Click on one of them - Scroll down the Headers section until you find the required Headers, as in the
auth.txt - Copy the headers exactly as they are; note that for the cookie key, you only need the part starting with
__Secure-next-auth.session-token=... - Paste values into
auth.txt
- run main.py
python main.py- Downloads only new images, creates
gallery/vN/,images/,metadata_vN.json,page_1.htmletc., creates/updatesgallery/index.htmlwith links to all pages
- Download New Images
python incremental_downloader.py- Scans all existing
v*/metadata_v*.json - Downloads only new images
- Creates
gallery/vN/,images/, andmetadata_vN.json
- Generate HTML Gallery
python generate_gallery_batch.py- Detects the latest batch (e.g.
v3) - Generates
page_1.html,page_2.html, etc. insidev3
- Update the Main Index Page
python generate_index.py- Scans all
gallery/v*folders - Creates/updates
gallery/index.htmlwith links to all pages
- No old data is overwritten. Every batch is saved in its own versioned folder (
v1,v2, etc.). - Each gallery version is fully static and self-contained.
- The
index.htmlprovides a quick navigation hub.
- If you get a
403or401, your token or cookie may have expired. Refreshauth.txtby copying headers again from your browser. - If a version is created with no new images, it will be cleaned up automatically.
Once configured, just rerun the three scripts above any time you generate new images in ChatGPT.
Happy archiving!