- A Remote Stable Diffusion Service
Purpose: OpenAI-compatible remote Stable Diffusion service
ALICE is a standalone Python service that provides OpenAI-compatible REST API endpoints for Stable Diffusion image generation. It enables SAM clients and other applications to offload GPU-intensive image generation to remote servers.
Key Features:
- 🤖 OpenAI-compatible API (
/v1/chat/completions) - 🖼️ Stable Diffusion image generation via
diffusers - 🔒 Image privacy controls with ownership tracking
- 🖼️ Gallery view for managing generated images
- 🌐 Web-based management interface
- 📥 Model download manager (CivitAI & HuggingFace)
- 🐧 Linux daemon deployment (systemd)
- 🍎 macOS support (launchd)
- 🚀 Model caching for fast subsequent generations
- 📊 Real-time metrics and monitoring
- 🔐 API key authentication with session management
- 🌐 Works completely offline (local fonts, no CDN dependencies)
Supported Hardware:
- NVIDIA GPUs (CUDA) - Recommended
- AMD GPUs (ROCm) - See
docs/AMD-DEPLOYMENT-GUIDE.md - Apple Silicon (MPS) - Full support
- CPU fallback (slower but works everywhere)
# Clone the repository
git clone https://github.com/fewtarius/alice.git
cd alice
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install PyTorch (platform-specific - see PYTORCH_INSTALL.md)
# For AMD/ROCm:
pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/rocm6.2
# For NVIDIA/CUDA:
pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
# For CPU only:
pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cpu
# For macOS (Apple Silicon):
pip install torch==2.6.0 torchvision==0.21.0
# Install remaining dependencies
pip install -r requirements.txt
# Create required directories
mkdir -p models images logs
# Add a Stable Diffusion model to ./models directory
# (Download from Hugging Face, CivitAI, etc.)
# Start the server
python -m src.main
# Open in browser
open http://localhost:8080/web/See PYTORCH_INSTALL.md for detailed PyTorch installation instructions.
For SteamOS (Steam Deck) or other Linux systems with user services:
# Run the automated installer
./scripts/install_steamos.sh
# The installer will:
# - Detect AMD GPU and configure ROCm (if available)
# - Install PyTorch 2.6.0 with correct backend
# - Install all dependencies matching SAM's versions
# - Create systemd user service
# - Start ALICE automatically
# Add models to ~/.local/share/alice/models
# Check status
systemctl --user status alice
# View logs
journalctl --user -u alice -f# Run the installation script
sudo ./scripts/install.sh
# Add models to /var/lib/alice/models
# Edit configuration if needed: /etc/alice/config.yaml
# Start the service
sudo systemctl start alice # Linux
sudo launchctl load /Library/LaunchDaemons/com.alice.plist # macOS
# Check status
sudo systemctl status alice # Linux
tail -f /var/log/alice/alice.log # Both┌─────────────────┐
│ Client App │
│ (SAM, etc.) │
└────────┬────────┘
│ HTTP POST /v1/chat/completions
│ {"model": "sd/...", "messages": [...]}
▼
┌─────────────────┐
│ ALICE Server │
│ (FastAPI) │
├─────────────────┤
│ • Model Registry│ ← Scans ./models for SD models
│ • Generator │ ← PyTorch + diffusers
│ • Web UI │ ← Management interface
│ • Image Storage │ ← Serves generated images
└────────┬────────┘
│
▼
┌─────────────────┐
│ GPU/CPU │
│ CUDA/ROCm/MPS │
└─────────────────┘
POST /v1/chat/completions
Content-Type: application/json
Authorization: Bearer <api-key> # Optional
{
"model": "sd/stable-diffusion-v1-5",
"messages": [
{"role": "user", "content": "a serene mountain landscape at sunset"}
],
"sam_config": {
"negative_prompt": "blurry, low quality",
"steps": 25,
"guidance_scale": 7.5,
"width": 512,
"height": 512,
"seed": 42,
"scheduler": "dpm++_sde_karras"
}
}Response (OpenAI-compatible):
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1234567890,
"model": "sd/stable-diffusion-v1-5",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Image generated successfully. URL: http://server:8080/images/abc.png",
"image_urls": ["http://server:8080/images/abc.png"]
},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0}
}GET /v1/models{
"object": "list",
"data": [
{"id": "sd/stable-diffusion-v1-5", "object": "model", "created": 1234567890, "owned_by": "alice"},
{"id": "sd/stable-diffusion-xl-base-1.0", "object": "model", "created": 1234567891, "owned_by": "alice"}
]
}GET /health{
"status": "ok",
"gpuAvailable": true,
"modelsLoaded": 1,
"version": "1.0.0"
}GET /metrics{
"queueDepth": 0,
"gpuUtilization": 0.45,
"gpuMemoryUsed": "4.2 GB",
"gpuMemoryTotal": "12.0 GB",
"modelsLoaded": 1,
"totalGenerations": 42,
"avgGenerationTime": 3.5
}POST /v1/models/refreshSearch CivitAI:
POST /v1/models/search/civitai
Content-Type: application/json
{
"query": "", # Empty = browse popular, non-empty = search
"types": ["Checkpoint"], # Checkpoint, LORA, TextualInversion
"limit": 100,
"page": 1
}Search HuggingFace:
POST /v1/models/search/huggingface
Content-Type: application/json
{
"query": "stable-diffusion",
"limit": 100
}Download from CivitAI:
POST /v1/models/download/civitai
Content-Type: application/json
{
"modelId": 4384,
"versionId": 128713 # Optional
}Download from HuggingFace:
POST /v1/models/download/huggingface
Content-Type: application/json
{
"repoId": "stabilityai/stable-diffusion-xl-base-1.0"
}List gallery images:
GET /v1/gallery?include_public=true&include_private=true&limit=100Returns all images accessible to the current user (own images + public images).
Update image privacy:
PATCH /v1/gallery/{image_id}/privacy
Content-Type: application/json
{
"isPublic": true,
"expiresInHours": 168 # Optional, 1-168 hours
}Delete image:
DELETE /v1/gallery/{image_id}Gallery statistics (admin only):
GET /v1/gallery/statsCleanup expired images (admin only):
POST /v1/gallery/cleanupPrivacy Features:
- All generated images are private by default
- Only the owner can view their private images
- Images can be made public with optional expiration (1-168 hours, default 7 days)
- Public images are accessible to all users until expiration
- Admins can view all images
- Expired public images are automatically deleted hourly
config.yaml:
server:
host: 0.0.0.0
port: 8080
api_key: null # Set to enable authentication
block_nsfw: true # Block NSFW content (enabled by default)
models:
directory: ./models
auto_unload_timeout: 300
default_model: stable-diffusion-v1-5
generation:
default_steps: 25
default_guidance_scale: 7.5
default_scheduler: dpm++_sde_karras
max_concurrent: 1
request_timeout: 300
default_width: 512
default_height: 512
storage:
images_directory: ./images
max_storage_gb: 100
retention_days: 7
logging:
level: INFO
file: ./logs/alice.logALICE includes comprehensive NSFW content filtering enabled by default:
Features:
- 100+ explicit keyword detection
- Obfuscation detection (leetspeak, spacing, symbols)
- Unicode character substitution detection
- Context-based pattern matching
- Checks both prompt and negative_prompt fields
Configuration:
server:
block_nsfw: true # Set to false to disable filteringWhen enabled, requests containing NSFW content return HTTP 400 with:
NSFW content detected and blocked. This server has NSFW generation disabled.
ALICE supports any Stable Diffusion model in:
- Diffusers format - Directory with
model_index.json - Single file -
.safetensorscheckpoint files
Supported architectures:
- SD 1.4/1.5 (512x512 native)
- SD 2.0/2.1 (768x768 native)
- SDXL (1024x1024 native)
- SD 3.x
- FLUX
Model naming:
- All models use
sd/prefix - Model ID matches the directory/file name
- Example:
models/stable-diffusion-v1-5/→sd/stable-diffusion-v1-5
Available schedulers:
dpm++_sde_karras(default, recommended)dpm++_karraseuler_aeulerddimpndmlms
alice/
├── src/
│ ├── __init__.py
│ ├── main.py # FastAPI application
│ ├── config.py # Configuration management
│ ├── model_registry.py # Model scanning/management
│ ├── generator.py # Image generation engine
│ ├── gallery.py # Image gallery & privacy
│ ├── auth.py # Authentication system
│ ├── downloader.py # Model download manager
│ └── schemas.py # Pydantic models
├── web/
│ ├── index.html # Dashboard
│ ├── models.html # Model management
│ ├── generate.html # Generation interface
│ ├── gallery.html # Image gallery
│ ├── download.html # Model downloads
│ ├── admin.html # Admin panel
│ ├── style.css # Styles
│ └── app.js # JavaScript client
├── scripts/
│ ├── install.sh # Installation script
│ └── user_collaboration.sh
├── tests/
│ └── test_api.py # API tests
├── docs/
│ ├── ARCHITECTURE.md
│ ├── IMPLEMENTATION_GUIDE.md
│ └── AMD-DEPLOYMENT-GUIDE.md
├── data/
│ ├── auth/ # API keys & sessions
│ └── gallery.json # Image metadata
├── config.yaml # Configuration
├── requirements.txt # Python dependencies
├── alice.service # systemd service
├── Makefile # Build commands
└── README.md # This file
- Python 3.10+
- 16GB+ RAM (32GB recommended for SDXL)
- 50GB+ disk space for models
- GPU with 8GB+ VRAM (recommended)
Core versions match SAM's bundled Python environment for compatibility.
See requirements.txt for full list and PYTORCH_INSTALL.md for PyTorch installation.
Key packages:
- PyTorch 2.6.0 (with ROCm 6.2, CUDA 12.4, or CPU backend)
- diffusers 0.35.2
- transformers 4.57.3
- accelerate 1.12.0
- compel 2.3.1 (prompt weighting)
- FastAPI 0.104.1
- Pydantic 2.12.5
Access at http://localhost:8080/web/
Dashboard:
- Real-time service status
- GPU memory visualization
- Quick generation form
- Recent generations gallery
Models:
- List available models
- Model type detection (SD1.5, SDXL, etc.)
- Refresh model registry
Download (Admin only):
- Browse popular CivitAI Checkpoints on page load
- Search filters loaded models locally (instant)
- Download models from CivitAI or HuggingFace
- Real-time download progress
- Automatic model type detection
Generate:
- Full parameter controls
- Size presets
- Scheduler selection
- Generation log
- Image preview and download
# Install dependencies
make install
# Run in development mode (auto-reload)
make dev
# Run tests
make test
# Lint code
make lint
# Clean build artifacts
make cleansudo ./scripts/install.sh --uninstall- Check logs:
tail -f /var/log/alice/alice.log - Verify Python path:
which python3 - Check port availability:
lsof -i:8080
- Verify model path exists
- Check model format (diffusers or safetensors)
- Ensure enough VRAM/RAM
- Check GPU memory usage
- Try smaller resolution
- Reduce batch size
- See
docs/AMD-DEPLOYMENT-GUIDE.md - Verify ROCm installation
- Check
HSA_OVERRIDE_GFX_VERSION
GNU General Public License v3.0 (GPL-3.0)