A powerful, automated AI art generation system using the Runware API. Generate high-quality images automatically with various models, styles, and scheduling options.
- Multiple Generation Modes: Single image, batch processing, template-based, and style variations
- Automated Scheduling: Set up recurring generation jobs with customizable intervals
- Multiple Models: Support for various AI models including FLUX, Stable Diffusion, and custom CivitAI models
- Style Variations: Generate the same prompt in different artistic styles
- Template System: Pre-built templates for portraits, landscapes, fantasy, cyberpunk, and abstract art
- Concurrent Processing: Generate multiple images simultaneously for better performance
- Local Storage: Automatically download and organize generated images
- Metadata Tracking: Keep detailed records of all generations
- CLI Interface: Easy-to-use command-line interface
- Configuration Management: Flexible configuration via environment variables and JSON files
- Python 3.8 or higher
- Runware API key (get one at my.runware.ai)
- Internet connection for API access
-
Clone the repository:
git clone <your-repo-url> cd runware
-
Install dependencies:
pip install -r requirements.txt
-
Set up your API key:
cp config.env.example .env
Edit
.envand add your Runware API key:RUNWARE_API_KEY=your_api_key_here
-
Generate a single image:
python cli.py generate "A futuristic stealth jet streaking through a neon-lit cityscape" -
Generate multiple images:
python cli.py batch --prompts "A serene mountain landscape" "A cyberpunk city street" "A magical forest"
-
Use templates:
python cli.py template portrait "a young woman with blue hair" --style anime --count 3 -
Generate style variations:
python cli.py styles "A majestic dragon flying over mountains" --styles realistic anime cyberpunk
Create a file prompts.txt:
A serene mountain landscape at sunset
A cyberpunk city street at night
A magical forest with glowing mushrooms
A futuristic robot in a laboratory
Then run:
python cli.py batch --file prompts.txt --model runware:97@2-
Configure the scheduler:
python cli.py scheduler config --enabled true --interval-hours 6 --batch-size 2 -
Start the scheduler:
python cli.py scheduler start
-
Check status:
python cli.py scheduler status
Add custom prompts to the pool:
python cli.py add-prompt cyberpunk "A neon-lit street with holographic advertisements"
python cli.py add-prompt fantasy "A magical library with floating books and glowing orbs"The CLI provides several commands for different use cases:
python cli.py generate "Your prompt here" [options]Options:
--model: Specify the model to use--width,--height: Image dimensions--steps: Number of generation steps--cfg-scale: CFG scale parameter--negative-prompt: Negative prompt for unwanted elements
python cli.py batch --file prompts.txt [options]
# or
python cli.py batch --prompts "prompt1" "prompt2" "prompt3" [options]Options:
--file: File containing prompts (one per line)--prompts: List of prompts directly--sequential: Generate sequentially instead of concurrently- All other options from
generatecommand
python cli.py template <template_type> <subject> [options]Template types: portrait, landscape, fantasy, cyberpunk, abstract
Options:
--style: Artistic style to apply--location: Location for landscape templates--count: Number of images to generate
python cli.py styles "Base prompt" --styles realistic anime cyberpunk [options]# Configure scheduler
python cli.py scheduler config --enabled true --interval-hours 12 --batch-size 4
# Start scheduler
python cli.py scheduler start
# Check status
python cli.py scheduler status
# Show configuration
python cli.py scheduler config --showYou can also use the system programmatically:
import asyncio
from ai_art_generator import AIArtGenerator
async def main():
generator = AIArtGenerator()
await generator.connect()
# Generate a single image
result = await generator.generate_single_image(
prompt="A futuristic stealth jet streaking through a neon-lit cityscape",
model="runware:97@2",
width=1344,
height=768
)
print(f"Generated: {result['local_path']}")
await generator.disconnect()
asyncio.run(main())The system includes several pre-configured models:
- realistic:
runware:97@2- High-quality realistic images - anime:
civitai:102438@133677- Anime-style images - artistic:
runware:101@1- Artistic and creative styles - photorealistic:
runware:100@1- Photorealistic images - fantasy:
civitai:102438@133677- Fantasy and imaginative styles - cyberpunk:
runware:97@2- Cyberpunk and futuristic styles - portrait:
runware:100@1- Portrait-optimized - landscape:
runware:101@1- Landscape-optimized
You can also use any CivitAI model by copying its AIR ID and using it directly.
runware/
βββ ai_art_generator.py # Main generation engine
βββ automated_scheduler.py # Automated scheduling system
βββ cli.py # Command-line interface
βββ requirements.txt # Python dependencies
βββ config.env.example # Environment variables template
βββ .env # Your API key (create this)
βββ generated_images/ # Output directory for images
βββ scheduler_config.json # Scheduler configuration
βββ prompt_pool.json # Custom prompt pool
βββ generation_metadata.json # Generation history
βββ job_summaries.json # Scheduler job summaries
Create a .env file with your configuration:
# Required
RUNWARE_API_KEY=your_api_key_here
# Optional - Generation Settings
DEFAULT_MODEL=runware:97@2
DEFAULT_WIDTH=1024
DEFAULT_HEIGHT=1024
DEFAULT_STEPS=40
DEFAULT_CFG_SCALE=5
# Optional - Output Settings
OUTPUT_DIR=./generated_images
BATCH_SIZE=4The scheduler can be configured via the CLI or by editing scheduler_config.json:
{
"enabled": true,
"interval_hours": 24,
"batch_size": 4,
"models": ["runware:97@2", "runware:101@1"],
"styles": ["realistic", "artistic", "anime", "cyberpunk"],
"categories": ["landscape", "portrait", "fantasy", "abstract"],
"max_concurrent": 2,
"randomize_prompts": true,
"save_metadata": true
}You can use any model from CivitAI by copying its AIR ID:
python cli.py generate "Your prompt" --model civitai:123456@789012The system automatically processes multiple images concurrently for better performance. You can disable this with the --sequential flag:
python cli.py batch --file prompts.txt --sequentialAll generations are automatically tracked with metadata including:
- Generation parameters
- Model used
- Timestamps
- File paths
- Error information (if any)
The system includes robust error handling:
- Automatic retries for transient failures
- Detailed error logging
- Graceful degradation for partial batch failures
- Connection recovery for network issues
For development and testing:
python cli.py generate "Test prompt"For production use, consider:
- Process Management: Use
systemd,supervisord, orpm2to keep the scheduler running - Logging: Configure proper logging for monitoring
- Backup: Regularly backup your generated images and metadata
- Monitoring: Set up monitoring for API usage and costs
Example systemd service:
[Unit]
Description=AI Art Scheduler
After=network.target
[Service]
Type=simple
User=your-user
WorkingDirectory=/path/to/runware
ExecStart=/usr/bin/python3 cli.py scheduler start
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetRunware offers competitive pricing starting at $0.0006 per image. Monitor your usage:
- Check generation metadata: Review
generation_metadata.json - Monitor API usage: Check your Runware dashboard
- Set batch limits: Configure appropriate batch sizes
- Use efficient models: Choose models that balance quality and cost
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check this README and inline code comments
- Runware API: Visit docs.runware.ai
- Issues: Create an issue in this repository
- Community: Join the Runware community for support
python cli.py generate "A neon-lit cyberpunk city street with flying cars and holographic advertisements" --model runware:97@2 --width 1344 --height 768python cli.py template portrait "a confident business person" --style realistic --count 5python cli.py scheduler config --enabled true --interval-hours 24 --batch-size 3
python cli.py scheduler startpython cli.py styles "A majestic dragon flying over mountains" --styles realistic anime cyberpunk artisticHappy generating! π¨β¨