Skip to content

cf12436/z-img

Repository files navigation

Z-Image - Free AI Image Generator 🎨

License: MIT Next.js Cloudflare Pages

中文文档 | English

A free AI image generator powered by Pollinations AI. No login required, generate high-quality images instantly.

🌐 Live Demo: https://z-img.pics
🎬 Video Generation: VideoDance.cc - Bring your images to life!


✨ Features

  • 🚀 Lightning Fast - Powered by Pollinations AI, sub-second response
  • 🔓 No Login Required - Start creating immediately
  • 🎨 High Quality - Multiple resolutions and enhancement modes
  • 🌍 Multi-language - 12 language interfaces
  • 💾 Local Cache - Auto-save history (7 days)
  • 📱 Responsive Design - Perfect mobile experience
  • 🔒 Request Signature - Anti-abuse protection
  • Rate Limiting - Built-in protection via Cloudflare Pages Function

🛠️ Tech Stack


🚀 Quick Start

Local Development

  1. Clone the repository
git clone https://github.com/your-username/z-img.git
cd z-img
  1. Install dependencies

Using npm:

npm install

Or using pnpm (recommended, this project uses pnpm):

pnpm install
  1. Configure environment variables

Copy the example environment file:

cp .env.example .env.local

Then edit .env.local and fill in your Pollinations AI Token:

# Pollinations AI Token
# Get yours at: https://pollinations.ai/
POLLINATIONS_TOKEN=sk_your_actual_token_here

💡 How to get Token: Visit https://pollinations.ai/, register an account, and get the server-side key starting with sk_ from your dashboard.

  1. Start development server

Using npm:

npm run dev

Or using pnpm:

pnpm dev
  1. Open http://localhost:3000 in your browser 🎉

📦 Deployment

Cloudflare Pages (Recommended)

  1. Fork this repository to your GitHub

  2. Connect to Cloudflare Pages

    • Login to Cloudflare Dashboard
    • Go to Workers & PagesCreate applicationPages
    • Connect your GitHub repository
  3. Build Configuration

    Framework preset: Next.js (Static HTML Export)
    Build command: npm run build
    Build output directory: out
    
  4. Set Environment Variables

    Add in Cloudflare Pages project settings:

    POLLINATIONS_TOKEN=sk_your_token_here
    
  5. Deploy! 🎉

Vercel Deployment

vercel deploy

Remember to add POLLINATIONS_TOKEN environment variable in Vercel project settings.

Netlify Deployment

netlify deploy --prod

Also add POLLINATIONS_TOKEN in Netlify environment variables.


🔑 API Documentation

This project uses the free Pollinations AI image generation API:

Endpoint: GET https://gen.pollinations.ai/image/{prompt}

Supported Parameters:

  • width, height - Image dimensions
  • seed - Random seed (reproducible)
  • enhance - AI enhancement mode
  • model - Model to use (default zimage)
  • negative_prompt - Negative prompts

Authentication: Add Authorization: Bearer sk_xxx header

Get your API Token: https://pollinations.ai/


📂 Project Structure

z-img/
├── src/
│   ├── app/
│   │   ├── api/
│   │   │   └── generate/
│   │   │       └── route.ts          # Next.js API route (local dev)
│   │   ├── globals.css
│   │   ├── layout.tsx
│   │   ├── page.tsx
│   │   ├── sitemap.ts
│   │   └── robots.ts
│   ├── components/
│   │   ├── Header.tsx                # Top navigation
│   │   ├── Hero.tsx                  # Image generator UI
│   │   ├── Gallery.tsx               # Sample gallery
│   │   ├── Features.tsx              # Features showcase
│   │   ├── About.tsx                 # About page
│   │   ├── FAQ.tsx                   # FAQ accordion
│   │   ├── Footer.tsx                # Footer
│   │   └── LanguageSelector.tsx      # Language switcher
│   ├── i18n/
│   │   ├── locales.ts
│   │   └── translations.ts           # 12 language translations
│   └── utils/
│       └── imageCache.ts             # Local image cache
├── functions/
│   └── api/
│       └── generate.js               # Cloudflare Pages Function
├── public/
│   └── images/                       # Static images
├── .env.example                      # Environment variables example
└── next.config.mjs

🔒 Security Features

  • Request Signature Verification - Timestamp + hash signature prevents replay attacks
  • Referer/Origin Check - Restrict allowed request sources
  • Rate Limiting - Prevent API abuse (Cloudflare Function)
  • Environment Variables - API tokens stored server-side, not exposed to frontend

🌐 Links


📝 Roadmap

  • Image editing features
  • Batch generation
  • More AI model options
  • Community sharing
  • API usage statistics

🤝 Contributing

Issues and Pull Requests are welcome!

  1. Fork this repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License.


💬 Contact

Questions or suggestions? Welcome to:


⭐ If this project helps you, please give it a Star!

About

Z-Image - Free AI Image Generator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors