Skip to content
Back to Templates

Gemini 2.0 Flash Image Generation and Editing

Generate AI images with the Google Gemini model.

This template is unavailable
Gemini

Gemini 2.0 Flash Image Generation and Editing

Nextjs quickstart for to generating and editing images with Google Gemini 2.0 Flash. It allows users to generate images from text prompts or edit existing images through natural language instructions, maintaining conversation context for iterative refinements. Try out the hosted demo at Hugging Face Spaces.

https://github.com/user-attachments/assets/8ffa5ee3-1b06-46a9-8b5e-761edb0e00c3

Get your GEMINI_API_KEY key here and start building.

How It Works:

  1. Create Images: Generate images from text prompts using Gemini 2.0 Flash
  2. Edit Images: Upload an image and provide instructions to modify it
  3. Conversation History: Maintain context through a conversation with the AI for iterative refinements
  4. Download Results: Save your generated or edited images

Basic request

For developers who want to call the Gemini API directly, you can use the Google Generative AI JavaScript SDK:

Features

  • 🎨 Text-to-image generation with Gemini 2.0 Flash
  • 🖌️ Image editing through natural language instructions
  • 💬 Conversation history for context-aware image refinements
  • 📱 Responsive UI built with Next.js and shadcn/ui
  • 🔄 Seamless workflow between creation and editing modes
  • ⚡ Uses Gemini 2.0 Flash Javascript SDK

Getting Started

Local Development

First, set up your environment variables:

Add your Google AI Studio API key to the .env file:

Get your GEMINI_API_KEY key here.

Then, install dependencies and run the development server:

Open http://localhost:3000 with your browser to see the application.

Deployment

Vercel

Docker

  1. Build the Docker image:
  1. Run the container with your Google API key:

Or using an environment file:

Open http://localhost:3000 with your browser to see the application.

Technologies Used

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Gemini 2.0 Flash Image Generation and Editing