Skip to content

Pixel art editor with AI generation. Experiment testing LLMs for structured pixel output via WebGPU in the browser. Two models: OpenAI API (GPT-5.2) and local Ministral 3B via Transformers.js. Spoiler: small local models don't work great for this, but it was fun to build. Not for production use.

License

Notifications You must be signed in to change notification settings

mxmarchal/pixel-llm

Repository files navigation

Pixel LLM

A pixel art editor with AI-powered generation. An experiment to test LLM-based pixel art generation using WebGPU in the browser.

WARNING: This is an experimental project and should NOT be used in production.

The OpenAI API key handling is not secure - it's stored in localStorage and used directly from the browser with dangerouslyAllowBrowser: true. This is fine for local experimentation but absolutely not suitable for any production or public-facing deployment. If you need production API usage, implement a proper backend proxy.

Screenshot

Features

  • Full-featured pixel art editor with layers, tools (pencil, eraser, fill, color picker, move)
  • Undo/redo history
  • PNG export
  • Autosave to localStorage
  • AI Generation: Generate pixel art from text prompts

AI Models

Two generation options are available:

OpenAI API (GPT-5.2)

  • Requires an API key from OpenAI
  • Best quality results
  • API key is stored locally in your browser

Local Model (Ministral 3B)

Honest Assessment

I built this to experiment with running small LLMs locally via WebGPU for structured output generation. Let's be honest: the local model doesn't work great for this use case. The 3B model struggles to consistently produce valid pixel art grids in the expected format.

My prompt engineering and grid-to-pixel parsing could probably be improved, but fundamentally this might not be the best use case for a model of this size. Generating structured coordinate/color data requires precise output that small models tend to hallucinate or mess up.

Still, it was a fun experiment! The WebGPU inference via Transformers.js works surprisingly well, and the API-based generation with larger models produces decent results.

Getting Started

Prerequisites

  • Node.js 18+
  • pnpm

Installation

pnpm install

Development

pnpm dev

Open http://localhost:3000 in your browser.

Build

pnpm build

Testing

pnpm test        # Watch mode
pnpm test:run    # Run once

Tech Stack

  • Framework: Next.js 16 (App Router)
  • UI: React 19, Tailwind CSS 4
  • State: Zustand
  • Canvas: HTML5 Canvas API
  • AI: Transformers.js (WebGPU), OpenAI SDK
  • Testing: Vitest

Keyboard Shortcuts

Key Action
P Pencil tool
E Eraser tool
F Fill tool
I Color picker
M Move tool
X Swap colors
Ctrl+Z Undo
Ctrl+Shift+Z Redo
+/- Zoom in/out
0 Reset zoom
Space+Drag Pan canvas

License

MIT

About

Pixel art editor with AI generation. Experiment testing LLMs for structured pixel output via WebGPU in the browser. Two models: OpenAI API (GPT-5.2) and local Ministral 3B via Transformers.js. Spoiler: small local models don't work great for this, but it was fun to build. Not for production use.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages