Pierre Roy

AyfriGPT-Images

A modern application for creating images or videos with GPT Images/Sora models.

Svelte 5 stars 0 forks updated 07/11/2026

GPT Image Generator ✨

SvelteKit Tailwind CSS OpenAI TypeScript

A modern web application built with SvelteKit 3 and Tailwind CSS that allows users to generate stunning images using OpenAI's image generation models.

Website: https://gpt-images.ayfri.com

Screenshot of the image history gallery next to the prompt form, API key card and usage statistics

Features

  • AI Image Generation: Creates images from text prompts with gpt-image-2, GPT Image 2.5 Flare and Sunburst, and GPT Image 2.6 Flare and Sunburst (default: 2.6 Flare). Quality goes up to xhigh and max on 2.5 and 2.6, and 2.6 adds a complexity setting.
  • Output Formats: PNG, JPEG and WebP, plus animated GIF (2 to 16 frames, 512 or 768 squares) and SVG (a vector image authored by a text model) on GPT Image 2.6.
  • Image Editing: Edits with up to 16 reference images and an optional mask.
  • Any Reference Format: Add reference images by browsing, dragging, or pasting an image or its URL. Anything the browser can decode (GIF, AVIF, BMP...) is converted to PNG on the fly.
  • SVG as Prompt Text: A dropped, pasted or browsed SVG file is appended to the prompt as text instead of being attached as an image.
  • Markup Edits: Draw on the first reference image (brush color and size, undo, clear) to guide the edit with GPT Image 2.5 and 2.6. Can't be combined with a mask.
  • API Key Management: Stores your OpenAI API key in the browser's localStorage (key openai-api-key). The key never leaves your browser except in requests to OpenAI.
  • Image Gallery: Displays previously generated images, with libraries (an image can sit in several, and new generations go into the open one), grouping by date, prompt, model, library, format, quality and size with collapsible groups showing their image count and total cost, and sorting by date, prompt, model, price, quality, size or format with a prompt search. The view is remembered in localStorage (key gallery-view).
  • Regenerate Option: Easily regenerate an image with the same prompt.
  • Usage Statistics: Shows the total spent, using the real cost computed from the API usage for each image (estimate for older images), plus a table of estimated prices.
  • Responsive Design: Adapts beautifully to different screen sizes thanks to Tailwind CSS.
  • Modern UI: Clean and intuitive user interface built with Svelte.
  • Installable (PWA) with an offline app shell: A web app manifest and a service worker (src/service-worker/index.ts) let you install the app and open it without a connection. The worker caches the build files, the static assets and the prerendered page, and never touches cross-origin requests such as the OpenAI API.
  • Link Previews and SEO: Includes a description, a canonical URL, Open Graph and Twitter card tags with a preview image, schema.org WebApplication data, a robots.txt and a sitemap for search engines and social sharing.

Tech Stack

  • Framework: SvelteKit 3 (Svelte 5)
  • Styling: Tailwind CSS
  • Language: TypeScript
  • AI: OpenAI API
  • Icons: Lucide Svelte
  • Client-side Storage: IndexedDB via idb for image metadata and the libraries store, OPFS (Origin Private File System, src/lib/db/opfsStore.ts) for the image files
  • Package Manager: Bun
  • Build Tool: Vite
  • Hosting: Cloudflare Workers (@sveltejs/adapter-cloudflare, deployed with Wrangler)

Getting Started

Prerequisites

Installation & Setup

  1. Clone the repository:

    git clone https://github.com/Ayfri/gpt-images.git
    cd gpt-images
    
  2. Install dependencies:

    bun install
    

The application reads no environment variables. The API key is entered in the UI and stored in the browser's localStorage. Be mindful of security implications when handling API keys.

Running the Development Server

bun run dev

This command starts a local development server. Open your browser and navigate to http://localhost:5173 (or the port specified in the output).

Enter your OpenAI API key in the application's UI to start generating images.

Building for Production

bun run build

This command creates an optimized production build in the .svelte-kit/cloudflare directory, which wrangler.jsonc points to for the Worker and its static assets. Deploy it with bunx wrangler deploy. The page is prerendered into .svelte-kit/cloudflare/index.html and served as a static asset: the Worker only handles other paths. API calls go straight from the browser to OpenAI with fetch, so no SDK ships at runtime.

Previewing the Production Build

bun run preview

This command starts a local server to preview the production build.

Type Checking

bun run check

Project Structure

gpt-images/
├── .svelte-kit/      # SvelteKit build artifacts (generated)
├── node_modules/     # Project dependencies (managed by Bun)
├── src/
│   ├── app.css       # Global CSS styles and Tailwind CSS 4 configuration
│   ├── app.html      # HTML template shell
│   ├── lib/          # Application library, imported as `#lib/...`
│   │   ├── components/ # Reusable Svelte components
│   │   ├── db/         # Image metadata (IndexedDB), image files (OPFS) and storage migrations
│   │   ├── services/   # API interactions (OpenAI)
│   │   ├── stores/     # Runes state classes (gallery, API key)
│   │   ├── types/      # Shared types and model definitions
│   │   └── utils/      # Utility functions
│   ├── routes/       # Application pages
│   │   ├── +layout.svelte # Root layout component
│   │   ├── +layout.ts     # Prerenders the page to a static index.html
│   │   └── +page.svelte   # Main page component
│   └── service-worker/ # Offline app shell (own tsconfig.json, excluded from the app one)
├── static/           # Static assets served as-is (logo, icons, manifest.webmanifest, robots.txt, sitemap.xml, screenshots, social preview image)
├── .gitignore        # Files/folders ignored by Git
├── bun.lock          # Exact dependency versions
├── package.json      # Project metadata, dependencies and `#lib` import map
├── README.md         # This file
├── tsconfig.json     # TypeScript configuration
├── vite.config.ts    # Vite and SvelteKit configuration (adapter included)
└── wrangler.jsonc    # Cloudflare Workers configuration

Contributing

Contributions are welcome! Please follow standard fork-and-pull-request workflows.

License

This project is licensed under the MIT License - see the LICENSE file for details (if applicable).