AI-powered mock data generator with advanced image processing capabilities. Generate realistic mock data from existing JSON examples using state-of-the-art language models, with optional AI-generated images.
- π€ AI-Powered Generation: Uses OpenRouter API with JSON mode for reliable output
- π Smart Pattern Analysis: Automatically detects and analyzes JSON structures
- β‘ Dynamic Batch Processing: Optimizes generation based on data complexity
- π¨ Custom Preferences: Guide generation with custom instructions
- πΌοΈ AI Image Processing: Replace placeholder images with contextual AI-generated images
- βοΈ Cloud Storage Integration: Upload images to AWS S3 or DigitalOcean Spaces
- π§ Smart Optimization: Intelligent duplication detection and image reuse (up to 30% savings)
- π Italian Locale Support: Default Italian names, addresses, and formatting
- π Multiple Model Support: Works with OpenAI, Anthropic Claude, Google Gemini, and more
npm install @bramato/openrouter-mock-generatorRun the interactive configuration wizard:
npx ai-initThis will guide you through:
- OpenRouter API Key: Required for text generation
- Model Selection: Choose the best models for your needs
- AI Image Processing (Optional):
- Hugging Face API key for AI image generation
- Cloud storage (AWS S3 or DigitalOcean Spaces) for image hosting
# Basic usage (uses placeholder images)
npx ai-generate-mock products.json --count 50
# With AI image processing (if configured)
npx ai-generate-mock products.json --images --count 20
# Force disable AI images
npx ai-generate-mock products.json --no-images --count 50# Generate mock data with auto-detection
npx ai-generate-mock <input.json> --count <number>
# With custom preferences
npx ai-generate-mock products.json --preferences "Generate luxury Italian fashion items" --count 25
# Specify output file and array path
npx ai-generate-mock data.json --output generated_data.json --array-path "products" --count 100
# Analyze file structure first
npx ai-generate-mock input.json --analyze# Enable AI image processing (replaces Picsum URLs with AI-generated images)
npx ai-generate-mock products.json --images --count 50
# Disable AI image processing (keeps placeholder images)
npx ai-generate-mock products.json --no-images --count 50
# Auto-detection (enabled if configured, disabled otherwise)
npx ai-generate-mock products.json --count 50-c, --count <number>: Number of items to generate (default: 10)-o, --output <file>: Output file path (default: input_mock.json)-p, --array-path <path>: Specific array path to use (e.g. 'data.items')--preferences, --pref <text>: Custom preferences for data generation--images, --enable-images: Force enable AI image processing--no-images, --disable-images: Force disable AI image processing-a, --analyze: Analyze input file structure without generating-h, --help: Show help message
import { MockGeneratorService } from '@bramato/openrouter-mock-generator';
// Auto-detect image processing configuration
const generator = new MockGeneratorService();
const result = await generator.generateMockData({
inputFile: 'products.json',
outputFile: 'generated_products.json',
count: 50,
preferences: 'Generate Italian fashion brands with prices in euros'
});
if (result.success) {
console.log(`Generated ${result.generatedCount} items`);
} else {
console.error(`Error: ${result.error}`);
}import { MockGeneratorService } from '@bramato/openrouter-mock-generator';
// Explicitly control image processing
const generator = new MockGeneratorService(
undefined, // Use default OpenRouter config
true // Force enable image processing
);
const result = await generator.generateMockData({
inputFile: 'products.json',
outputFile: 'generated_products.json',
count: 50,
preferences: 'Generate luxury Italian fashion items',
enableImageProcessing: true // Enable for this specific request
});import { PostProcessingOrchestrator } from '@bramato/openrouter-mock-generator';
// Process existing mock data with AI images
const processor = new PostProcessingOrchestrator('your-hf-api-key', {
verbose: true,
enableOptimization: true,
uploadToCloud: true
});
const data = JSON.parse(fs.readFileSync('existing-mock-data.json', 'utf8'));
const result = await processor.processData(data);
if (result.success) {
fs.writeFileSync('processed-data.json', JSON.stringify(result.processedData, null, 2));
}OPENROUTER_API_KEY: Your OpenRouter API key
OPENROUTER_DEFAULT_MODEL: Default model to useOPENROUTER_MOCK_GENERATOR_MODEL: Specific model for mock generation
HUGGINGFACE_API_KEY: Hugging Face API token for image generationSTORAGE_PROVIDER:awsordigitalocean
AWS_ACCESS_KEY_ID: AWS access keyAWS_SECRET_ACCESS_KEY: AWS secret keyAWS_REGION: AWS region (e.g.,us-east-1)AWS_S3_BUCKET_NAME: S3 bucket nameAWS_S3_ENDPOINT: Custom S3 endpoint (optional)
DO_SPACES_ACCESS_KEY: Spaces access keyDO_SPACES_SECRET_KEY: Spaces secret keyDO_SPACES_REGION: Spaces region (e.g.,fra1)DO_SPACES_NAME: Space nameDO_API_TOKEN: DigitalOcean API token (optional)
The package automatically filters and uses only JSON-mode compatible models:
- OpenAI: GPT-4.1 Nano, GPT-4o Mini, GPT-4 Turbo, GPT-3.5 Turbo
- Anthropic: Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku
- Google: Gemini Pro, Gemini Flash
- And many more via OpenRouter
# Input: products.json with Picsum placeholder images
npx ai-generate-mock products.json --images --preferences "Generate luxury Italian fashion items from Milano" --count 25
# Output: Real product images uploaded to cloud storage
# - Product photos with Italian fashion context
# - Thumbnails and gallery images
# - Banner images for promotional contentnpx ai-generate-mock menu.json --images --preferences "Traditional Italian cuisine from different regions" --count 15
# Generates:
# - Professional food photography for dishes
# - Restaurant interior images
# - Chef portrait photosnpx ai-generate-mock users.json --images --preferences "Italian professionals from major cities" --count 50
# Creates:
# - Professional headshot portraits
# - Contextual background images
# - Company logos for businesses- Generate realistic test data for frontend applications
- Create demo content for presentations and prototypes
- Populate databases with meaningful sample data
- Generate product catalogs with real imagery
- Create user interfaces with contextual content
- Build complete application mockups
- Generate sample content for marketing campaigns
- Create diverse product showcases
- Build realistic user testimonials and reviews
# E-commerce products
--preferences "Generate luxury Italian fashion items with designer brands and premium pricing"
# Restaurant menu
--preferences "Create traditional Italian dishes with regional specialties and wine pairings"
# User data
--preferences "Generate Italian professionals from Milano, Roma, and Napoli with realistic demographics"
# Events
--preferences "Create cultural events and festivals typical of Italian regions with local traditions"
# Real estate
--preferences "Generate Italian properties in historic city centers with authentic architectural details"The generator analyzes data complexity and automatically adjusts batch sizes:
- Simple items: Up to 10 per batch
- Complex nested structures: 1-3 per batch
- Prevents API timeouts and ensures quality
The system can automatically replace placeholder images (Picsum URLs) with contextually appropriate AI-generated images:
- Detection: Scans JSON data for Picsum URLs (
https://picsum.photos/...) - Context Analysis: Analyzes surrounding data to understand image context
- Smart Optimization: Groups similar images to reduce generation costs
- AI Generation: Creates images using Hugging Face models (FLUX.1-dev, Qwen-Image)
- Cloud Upload: Uploads to AWS S3 or DigitalOcean Spaces with CDN URLs
- URL Replacement: Replaces original URLs with new cloud URLs
- Product Images: Professional product photography
- Avatars & Profiles: Portrait photography
- Banners & Headers: Wide format promotional images
- Thumbnails: Small preview images
- Logos & Icons: Brand identity elements
- Backgrounds: Texture and pattern images
- Smart Duplication Detection: Reuses similar images (up to 30% cost savings)
- Contextual Descriptions: Generated in Italian with local context
- Batch Processing: Concurrent generation with rate limiting
- Fallback Support: Graceful degradation if generation fails
- Realistic Italian names and surnames
- Italian addresses and cities
- Euro currency formatting
- Italian business names and contexts
Problem: AI image processing not working
# Check configuration
npx ai-init
# Test with explicit flag
npx ai-generate-mock data.json --images --count 1Problem: Images not uploading to cloud storage
# Verify storage configuration
cat .env | grep -E "(STORAGE_PROVIDER|AWS_|DO_)"
# Test cloud connectivity
npx spaces-manager test # For DigitalOceanProblem: Hugging Face API errors
# Verify API key permissions at https://huggingface.co/settings/tokens
# Ensure "Make calls to the serverless Inference API" is enabledProblem: JSON parsing errors
- Check input file format with
npx ai-generate-mock input.json --analyze - Ensure input contains valid JSON arrays
Problem: Rate limiting
- Reduce batch size with smaller
--countvalues - Check OpenRouter/Hugging Face usage limits
Problem: Environment variables not loading
# Check .env file format (no spaces around =)
OPENROUTER_API_KEY=your-key-here
# Not: OPENROUTER_API_KEY = your-key-hereQ: Do I need both OpenRouter and Hugging Face API keys? A: OpenRouter is required for text generation. Hugging Face is optional for AI image processing.
Q: Can I use AWS S3 and DigitalOcean Spaces simultaneously? A: No, choose one storage provider in the configuration.
Q: How much does image generation cost? A: Hugging Face Inference API has free tier with rate limits. Cloud storage costs depend on usage.
Q: Can I process existing mock data with AI images?
A: Yes, use the PostProcessingOrchestrator programmatically or re-run generation with --images.
Q: What image formats are supported? A: The system generates PNG images and supports various dimensions based on context.
Q: How does the optimization work? A: The system detects similar images by content and context, reusing generated images to reduce costs.
The image processing system uses a modular microservices approach:
- ImageUrlExtractor: Finds and categorizes image URLs
- DescriptionGenerator: Creates contextual AI prompts
- ImageProcessingAnalyzer: Optimizes generation strategy
- UrlReplacer: Updates JSON with new image URLs
- PostProcessingOrchestrator: Coordinates all services
- CDN Integration: Automatic CDN URL generation
- Public Access: Images configured for public viewing
- Organized Structure: Date-based folder organization
- Fallback Support: Graceful handling of upload failures
- Optimization: Up to 30% cost savings through smart image reuse
- Concurrency: Configurable concurrent image generation
- Batch Processing: Automatic batching based on data complexity
- Rate Limiting: Built-in protection against API limits
MIT
bramato
π If this project helps you, please consider starring it on GitHub!