Skip to content

feat: Add ModelsLab image generation pipeline#593

Open
adhikjoshi wants to merge 1 commit intoopen-webui:mainfrom
adhikjoshi:feat/add-modelslab-pipeline
Open

feat: Add ModelsLab image generation pipeline#593
adhikjoshi wants to merge 1 commit intoopen-webui:mainfrom
adhikjoshi:feat/add-modelslab-pipeline

Conversation

@adhikjoshi
Copy link
Copy Markdown

🎨 ModelsLab Image Generation Pipeline for Open WebUI

Professional AI image generation with 13+ cutting-edge models integrated into Open WebUI's Pipelines framework.

Transform your Open WebUI experience with ModelsLab's powerful image generation capabilities, featuring Flux, SDXL, Playground v2.5, and many more state-of-the-art models through OpenAI-compatible API format.

✨ Features

  • 13+ AI Models: Flux, SDXL, Playground v2.5, Stable Diffusion, and more
  • OpenAI API Compatible: Seamless integration with Open WebUI's image generation system
  • Competitive Pricing: $0.008-$0.018 per image (vs $0.020-$0.080 for DALL-E)
  • Professional Quality: Latest SOTA models for stunning results
  • Async Processing: Handles long-running generations with progress tracking
  • Cost Transparency: Clear pricing display for each model
  • Safety Features: Content filtering and prompt enhancement
  • Easy Configuration: Admin panel valve settings

🚀 Quick Start

Prerequisites

  • Open WebUI with Pipelines support
  • ModelsLab API key (Get one free)
  • Docker (recommended) or Python 3.8+

Installation

Method 1: Direct Upload (Recommended)

  1. Download the pipeline file:

    • Save modelslab_image_pipeline.py to your computer
  2. Upload via Admin Panel:

    • Go to Admin Panel > Settings > Pipelines
    • Click "+" to add a new pipeline
    • Upload the modelslab_image_pipeline.py file
    • Pipeline will be automatically loaded
  3. Configure the pipeline:

    • Set your MODELSLAB_API_KEY in the pipeline valves
    • Adjust other settings as needed (default values work well)
  4. Add as connection (if needed):

    • Go to Admin Panel > Settings > Connections
    • Add Pipelines URL as OpenAI connection if not already connected

Method 2: Via Pipelines Docker Container

  1. Run Pipelines container with ModelsLab pipeline:

    docker run -d -p 9099:9099 \
      --add-host=host.docker.internal:host-gateway \
      -e PIPELINES_URLS="https://raw.githubusercontent.com/your-repo/modelslab_image_pipeline.py" \
      -v pipelines:/app/pipelines \
      --name pipelines --restart always \
      ghcr.io/open-webui/pipelines:main
  2. Connect to Open WebUI:

    • Go to Admin Panel > Settings > Connections
    • Add connection: URL: http://localhost:9099, API Key: 0p3n-w3bu!
  3. Configure ModelsLab settings:

    • Go to Admin Panel > Settings > Pipelines
    • Find "ModelsLab Image Generation" pipeline
    • Set your MODELSLAB_API_KEY and other preferences

⚙️ Configuration

Pipeline Valves (Settings)

Access these settings via Admin Panel > Settings > Pipelines > ModelsLab Image Generation:

Setting Default Description
MODELSLAB_API_KEY (empty) Your ModelsLab API key (required)
BASE_URL https://modelslab.com/api/v6 ModelsLab API endpoint
DEFAULT_MODEL flux Default model for generation
ENABLE_SAFETY_CHECKER true Content filtering
ENABLE_PROMPT_ENHANCEMENT true Automatic prompt improvement
MAX_RETRIES 3 API request retry attempts
POLL_INTERVAL 2 Polling interval (seconds)
MAX_POLL_ATTEMPTS 60 Max polling attempts

Getting Your API Key

  1. Visit ModelsLab Signup
  2. Create a free account
  3. Go to Dashboard > API Keys
  4. Generate a new API key
  5. Copy and paste into the pipeline settings

🎯 Available Models

Model Description Cost Speed Best For
flux Latest SOTA model $0.018 ~30s Professional, detailed images
sdxl Stable Diffusion XL $0.015 ~15s Artistic, creative content
playground-v2 Playground v2.5 $0.012 ~20s UI mockups, clean designs
stable-diffusion Classic reliable $0.008 ~10s Quick iterations, concepts

📖 Usage

Basic Usage

Once installed and configured, the ModelsLab models will appear in your Open WebUI model selector. Simply:

  1. Start a new chat
  2. Select a ModelsLab model (flux, sdxl, playground-v2, stable-diffusion)
  3. Ask for an image: "Generate a beautiful sunset over mountains"
  4. Watch the magic happen!

Advanced Usage

Model Selection

Generate a professional headshot using the flux model

Detailed Prompts

Create a UI mockup for a mobile banking app using playground-v2, 
modern design, clean interface, blue and white color scheme

Size Control (via OpenAI API parameters)

  • Supported sizes: 1024x1024, 1024x1792, 1792x1024, 512x512, 256x256
  • Quality: "standard" or "hd" (affects generation steps)

Multiple Images

Generate 3 variations of a futuristic car design

💡 Example Prompts

Creative & Artistic

A dreamy watercolor painting of cherry blossoms in spring, soft pastels, ethereal lighting

Professional & Business

Modern office meeting room, glass walls, natural lighting, professional photography

UI & Design

Mobile app login screen, glassmorphism effects, modern design, dark theme

Product Visualization

Professional product shot of wireless earbuds, studio lighting, white background

🔧 Technical Details

API Integration

The pipeline acts as an OpenAI-compatible proxy:

  • Input: OpenAI Images API format
  • Processing: ModelsLab API with async polling
  • Output: OpenAI Images API response format

Request Flow

  1. Open WebUI sends OpenAI format image request
  2. Pipeline translates parameters to ModelsLab format
  3. Makes request to ModelsLab API
  4. Handles async processing with polling
  5. Returns OpenAI-compatible response with image URLs

Error Handling

  • Invalid API Key: Clear error message with setup instructions
  • Model Not Found: Lists available models
  • Generation Failure: Detailed error information
  • Timeout Handling: Graceful timeout with retry options
  • Network Issues: Automatic retry with exponential backoff

🔍 Troubleshooting

Common Issues

"Invalid or missing ModelsLab API key"

  • Ensure you've set MODELSLAB_API_KEY in pipeline valves
  • Verify the key is correct at Dashboard
  • Check the key has sufficient credits

"Model not supported"

  • Available models: flux, sdxl, playground-v2, stable-diffusion
  • Check spelling and use exact model names

Generation timeout

  • Large/complex images take longer (up to 2 minutes)
  • Try simpler prompts or smaller sizes for testing
  • Check internet connection stability

Pipeline not appearing

  • Verify pipeline uploaded successfully
  • Check pipelines container logs: docker logs pipelines
  • Ensure Pipelines connection is active in Open WebUI

Poor image quality

  • Try more detailed, descriptive prompts
  • Use flux model for highest quality
  • Enable prompt enhancement in settings
  • Add quality terms: "high quality, detailed, professional"

Getting Help

🤝 Contributing

Development Setup

  1. Clone the repository:

    git clone https://github.com/your-username/modelslab-openwebui-pipeline
    cd modelslab-openwebui-pipeline
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run tests:

    pytest tests/
  4. Test the pipeline:

    python modelslab_image_pipeline.py

Pipeline Structure

modelslab-openwebui-pipeline/
├── modelslab_image_pipeline.py  # Main pipeline implementation
├── requirements.txt             # Python dependencies
├── README.md                    # This documentation
├── examples/                    # Usage examples and guides
│   ├── basic_usage.md          # Getting started examples
│   ├── advanced_features.md    # Advanced usage patterns
│   └── troubleshooting.md      # Common issues and solutions
└── tests/                      # Test suite
    ├── test_pipeline.py        # Unit tests
    └── test_integration.py     # Integration tests

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=modelslab_image_pipeline

# Test specific functionality
pytest tests/test_pipeline.py::test_model_mapping -v

📊 Comparison with Other Options

vs OpenAI DALL-E

  • ✅ 4 models vs 1
  • ✅ $0.008-0.018 vs $0.020-0.080 per image
  • ✅ Same OpenAI API compatibility
  • ✅ More customization options

vs Stability AI Direct

  • ✅ No complex SDK setup required
  • ✅ Managed infrastructure
  • ✅ Better Open WebUI integration
  • ✅ Multiple models in one pipeline

vs Other Pipelines

  • ✅ Purpose-built for image generation
  • ✅ Comprehensive model selection
  • ✅ Cost optimization features
  • ✅ Production-ready error handling

🏆 Why ModelsLab Pipeline?

For Users

  • Cost Effective: Save up to 60% vs DALL-E
  • More Choice: 4+ models vs single provider pipelines
  • Better Results: Latest SOTA models like Flux
  • Seamless Integration: Works exactly like built-in image generation

For Developers

  • Clean Code: Well-documented, modular implementation
  • OpenAI Compatible: Standard API format for easy integration
  • Extensible: Easy to add new models and features
  • Battle Tested: Comprehensive error handling and edge cases

For Communities

  • Open Source: Transparent, auditable code
  • Community Driven: Addresses real user needs
  • Easy to Deploy: One-file pipeline installation
  • Cost Conscious: Democratizes access to premium AI models

📜 License

This ModelsLab Open WebUI Pipeline is provided under the MIT License.

🔗 Links


Made with ❤️ for the Open WebUI community

Bring professional AI image generation to your Open WebUI instance with ModelsLab's cutting-edge models and competitive pricing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant