Skip to content

A modern web application that transforms text prompts into AI-generated images using the Pollinations GPT‑Image 1.5 model (gen.pollinations.ai).

Notifications You must be signed in to change notification settings

divyanshu12-fullstack/Img-Real

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AI Image Generator - Deployed at ImgReal

A modern web application that transforms text prompts into AI-generated images using the Pollinations GPT‑Image 1.5 model (gen.pollinations.ai).

AI Image Generator React Node.js

Features

  • 🎨 AI Image Generation - Powered by Pollinations GPT‑Image 1.5
  • Modern UI - Glassmorphism design with smooth animations
  • ⌨️ Keyboard Shortcuts - Press Ctrl+Enter to generate
  • 📱 Responsive - Works on desktop and mobile
  • 💾 Download - Save generated images instantly
  • 🛡️ Rate Limiting - Protects the API from abuse (10 req/15 min)

Tech Stack

Frontend: React 19, Vite, Tailwind CSS v4

Backend: Node.js, Express, Axios, express-rate-limit, CORS, morgan

AI Model: Pollinations GPT‑Image 1.5


Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm
  • Pollinations API key (POLLEN_API_KEY)

Installation

  1. Clone the repository

    git clone https://github.com/divyanshu12-fullstack/Img-Real.git
    cd Img-Real
  2. Setup Backend

    cd backend
    npm install
  3. Create backend .env file

    # Create a file named .env in the backend folder with:
    PORT=3000
    POLLEN_API_KEY=your_pollen_api_key_here
    POLLEN_TIMEOUT=90000
    # Comma-separated allowed origins for CORS
    CLIENT_URL=http://localhost:5173,https://imgreal.netlify.app
  4. Setup Frontend

    cd ../frontend
    npm install
  5. Create frontend .env file

    # Create a file named .env in the frontend folder with:
    VITE_API_BASE_URL=http://localhost:3000/api/generate-image

Running the Application

Start Backend Server

cd backend
npm run dev

The backend will start at http://localhost:3000

Start Frontend Server

Open a new terminal:

cd frontend
npm run dev

The frontend will start at http://localhost:5173


Environment Variables

Backend (backend/.env)

Variable Description Example
PORT Server port 3000
POLLEN_API_KEY Pollinations API token (required) pollen_xxxxx
POLLEN_TIMEOUT API timeout in ms 90000
CLIENT_URL Allowed origins for CORS (comma-separated) http://localhost:5173,https://imgreal.netlify.app

Frontend (frontend/.env)

Variable Description Example
VITE_API_BASE_URL Backend API endpoint http://localhost:3000/api/generate-image

API

Generate Image

  • Method: POST
  • Endpoint: /api/generate-image
  • Body: { "prompt": "A sunset over mountains" }
  • Success Response:
    {
       "success": true,
       "image": "data:image/png;base64,...",
       "meta": { "mime": "image/png", "size": 123456 }
    }
  • Error Response:
    { "success": false, "error": "<message>", "details": "<optional>" }

Rate limit: 10 requests per 15 minutes per IP.


Usage

  1. Open http://localhost:5173 in your browser
  2. Enter a descriptive prompt (e.g., "A sunset over mountains")
  3. Click Generate Image or press Ctrl+Enter
  4. Wait for the image to be generated (may take up to 60 seconds)
  5. Download or view the generated image

Project Structure

Text-to-Image/
├── backend/
│   ├── routes/
│   │   └── generateImage.js
│   ├── index.js
│   ├── package.json
│   └── .env
├── frontend/
│   ├── src/
│   │   ├── api/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── App.jsx
│   │   └── index.css
│   ├── package.json
│   └── .env
└── README.md

License

MIT License

Author

Made with ❤️ by Divyanshu

About

A modern web application that transforms text prompts into AI-generated images using the Pollinations GPT‑Image 1.5 model (gen.pollinations.ai).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published