A powerful Python tool combining Gemini 1.5 Flash (for AI-powered prompt enhancement) and Gemini 2.0 Flash (for fast, high-quality image generation). Enter a prompt, let AI enhance it, and generate stunning images instantly — outputted directly as Base64 and saved locally.
- 📝 Prompt Enhancement: Gemini 1.5 Flash enriches your text prompts for rich image details
- 🖼️ AI Image Generation: Gemini 2.0 Flash creates high-quality images
- 🧵 Base64 Encoding: Automatically encodes generated images
- 🗂️ Local Storage: Saves output in the
static/folder - ⚡ Fast & Developer-Friendly: Ideal for AI creators, developers, and hobbyists
| Prompted Output | Folder Path | Terminal Run |
|---|---|---|
git clone https://github.com/ajmal-uk/image-generation-using-python-google-gemini-image-studio.git
cd image-generation-using-python-google-gemini-image-studiopip install -r requirements.txtCreate a .env file in the root directory:
GEMINI_TEXT_API_KEY=your_text_api_key_here
GEMINI_IMAGE_API_KEY=your_image_api_key_herepython main.pyEnter your prompt and the AI-enhanced image will be saved in /static and encoded in Base64.
- Python 3 – Core programming language
- Google Generative AI –
google-generativeaiSDK for text & image generation - dotenv – API key management
- Base64 – Encoding images for API/web use
- Prompt Enhancement –
Gemini 1.5 Flashenriches the user input text. - Image Generation – Enhanced prompt is passed to
Gemini 2.0 Flashfor creating images. - Base64 Encoding & Storage – Images are saved locally and encoded for flexible usage.
google-generativeai
python-dotenvAjmal UK – Passionate about AI, Python, and creative development.