This repo contains a simple photobooth demo built with Next.js that lets you capture or upload a portrait and create multiple image styles using the OpenAI Image API in edit mode with the GPT Image 2 model.
Learn more about image generation and see examples in our dedicated guide.
- Image capture or upload
- Built-in style presets
- Integration with the OpenAI Image API
- Streaming partial image generations
- Next.js (App Router)
- TypeScript
- Tailwind CSS + shadcn/ui primitives
- OpenAI Image API (
/images/edits)
-
Clone the repository
-
Copy
.env.exampleto.env.local
cp .env.example .env.local- Add your OpenAI API key
OPENAI_API_KEY=""Optionally, you can set your OpenAI API key as an environment variable. Read our quickstart to learn more.
- Install dependencies
npm install- Start the dev server.
npm run devThe app should now be running at http://localhost:3000.
- Start camera and capture an image of yourself, or upload an image with people on the home screen.
- Select up to 4 styles from the style panel.
- Click
Generate Styles. - Wait for the images to be fully generated on the results screen.
- Click a result to preview it fullscreen.
- Download any generated style.
- Click
Create another setto restart the flow.
- Edit style labels/descriptions/prompts in
lib/photobooth-styles.ts. - Change default selected styles and limits in
lib/constants.ts. - Adjust generation model/size/quality defaults in
lib/constants.ts. - Tune layout and component styling in
components/photobooth/*.
app/page.tsx: home flow composition (capture + style selection).app/results/page.tsx: results flow composition (grid + modal).app/api/photobooth/route.ts: streaming image generation route.components/photobooth/*: reusable photobooth UI components.hooks/use-photobooth-capture.ts: capture/upload/drag logic.hooks/use-photobooth-results.ts: session + streaming results state.lib/constants.ts: centralized app constants.lib/photobooth-styles.ts: style catalog and prompts.lib/sse.ts: shared SSE parser/formatter.services/imagegen-api.ts: client-side streaming API integration.
You are welcome to open an issue or submit a pull request if you notice any bugs or have any suggestions for improvements. However, we are not committing to accepting any changes at this time and will only periodically review and merge changes if they are deemed to be valuable.
This project is licensed under the MIT License. See LICENSE for more details. You are free to use, modify, and distribute this project for any purpose, including commercial purposes.
Third-party notices, including Geist font attribution, are listed in THIRD_PARTY_NOTICES.md.
