Production-ready AI image generator built with n8n, featuring advanced rate limiting, content filtering, and multiple AI providers
- π€ Multiple AI Models: Flux, Turbo, and fallback providers for maximum reliability
- π‘οΈ Advanced Security: Content filtering, rate limiting, and input validation
- β‘ High Performance: 45-second timeout with intelligent fallback system
- π― Customizable Styles: 7+ built-in styles (photorealistic, artistic, cartoon, cyberpunk, etc.)
- π± React Frontend: Beautiful, responsive web interface included
- π§ Production Ready: Enterprise-grade error handling and monitoring
- ποΈ Flexible API: Support for custom dimensions, seeds, quality levels
- π¦ Rate Limiting: 10 requests per minute per IP with automatic cleanup
- Quick Start
- Installation
- API Documentation
- Frontend Setup
- Configuration
- Deployment
- Contributing
- License
# Import the workflow JSON into your n8n instance
# File: n8n/image_generate_3.json
# Navigate to the React app directory
cd n8n-image-generator
# Install dependencies
npm install
# Start development server
npm start
curl -X POST "https://your-n8n-instance.com/webhook/generate-image" \
-H "Content-Type: application/json" \
-d '{
"message": "A beautiful sunset over mountains",
"style": "photorealistic",
"size": "1024x1024",
"quality": "high"
}'
- n8n instance (cloud or self-hosted)
- Node.js 16+ (for React frontend)
- Domain with SSL certificate (recommended)
-
Clone the Repository
git clone https://github.com/YatharthSanghavi/n8n-image-generator.git cd n8n-image-generator
-
Import n8n Workflow
- Open your n8n instance
- Go to Workflows β Import from File
- Select
image_generate_3.json
- Activate the workflow
-
Configure Webhook
- Copy the webhook URL from n8n
- Update the endpoint in your frontend configuration
-
Configure Environment Variables
# Go to src/ImageGenerator.tsx paste your n8n url here under try section webhookUrl=https://your-n8n-webhook-url.com
{
"message": "Your image description",
"style": "photorealistic",
"size": "1024x1024",
"quality": "high",
"seed": 123456,
"model": "flux"
}
Parameter | Type | Default | Description |
---|---|---|---|
message |
string | required | Image description (3-500 characters) |
style |
string | photorealistic |
Style preset (see styles below) |
size |
string | 1024x1024 |
Image dimensions (256x256 to 2048x2048) |
quality |
string | high |
Quality level: low , medium , high |
seed |
number | random | Seed for reproducible results |
model |
string | flux |
AI model: flux , turbo by pollinations.ai |
Style | Description |
---|---|
photorealistic |
High-quality, photo-like images |
artistic |
Oil painting, masterpiece style |
cartoon |
Animated, Disney-like illustrations |
cyberpunk |
Futuristic, neon-lit sci-fi |
fantasy |
Magical, mystical artwork |
minimalist |
Clean, simple, modern design |
vintage |
Retro, classic, aged aesthetic |
Success (200)
Content-Type: image/png
[Binary image data]
Error (400/429)
{
"error": "Error type",
"message": "Detailed error message",
"code": "ERROR_CODE"
}
- Limit: 10 requests per minute per IP
- Window: 60 seconds
- Response: 429 Too Many Requests
The included React frontend provides a beautiful, user-friendly interface for your image generation API.
- Responsive Design: Works on all devices
- Real-time Preview: See parameters as you adjust them
- Gallery View: Browse generated images
- Download Support: Save images locally
- Style Presets: Quick style selection
- Advanced Options: Seed, model, quality controls
-
Rate Limiting
const maxRequestsPerWindow = 10; // Adjust as needed const rateLimitWindow = 60000; // 1 minute
-
Content Filtering
const inappropriateTerms = ['nude', 'naked', 'nsfw', 'explicit']; // Add custom terms to filter
-
API Providers
const apiConfigs = [ { name: 'Pollinations AI - Flux', url: `https://image.pollinations.ai/prompt/${prompt}?model=flux`, priority: 1 } // Add custom providers ];
- Cloud Deployment
- Use n8n Cloud for easiest setup
- Configure webhook URL in your domain
-
Netlify/Vercel
# Build for production npm run build # Deploy to Netlify netlify deploy --prod --dir=build
-
Traditional Hosting
npm run build # Upload build/ folder to your web server
- Request counting and rate limiting
- Error tracking and logging
- Performance metrics
- Content filter statistics
Add your own AI image generation APIs:
const customProvider = {
name: 'Custom AI Provider',
url: 'https://your-api.com/generate',
headers: {
'Authorization': 'Bearer your-token',
'Content-Type': 'application/json'
},
transform: (prompt, options) => ({
prompt: prompt,
style: options.style,
dimensions: options.size
})
};
# Fork the repository
git clone https://github.com/YatharthSanghavi/n8n-image-generator.git
cd n8n-image-generator
# Install dependencies
npm install
# Start development server
npm run dev
- π Bug fixes and improvements
- π New AI provider integrations
- π¨ Frontend enhancements
- π Documentation improvements
- π§ͺ Test coverage expansion
- v2.0: Multi-model support visit here:- fluxgen
- v2.1: Batch processing capabilities
- v2.2: Advanced content filtering with AI
- v2.3: User authentication and quotas
- v2.4: Image editing and variations
- v2.5: Mobile app (Flutter)
This project is licensed under the MIT License - see the LICENSE file for details.
- n8n Team: For the amazing automation platform
- Pollinations AI: For providing free AI image generation
- React Community: For the excellent frontend framework