Add native support for Open WebUI's image generation API as a new
image provider option. Open WebUI exposes an OpenAI-like
/v1/images/generations endpoint but with key differences that
require special handling:
- Response is a bare JSON array instead of {"data": [...]}
- Image URLs are relative paths (e.g. /api/v1/files/.../content)
- File downloads require the same Bearer auth token
The implementation uses raw HTTP calls via aiohttp rather than the
OpenAI SDK to handle these differences. No model parameter is sent
since Open WebUI manages the image model in its own admin settings.
Backend changes:
- New OPEN_WEBUI enum value in ImageProvider
- generate_image_open_webui() method in ImageGenerationService
- Environment getters/setters for OPEN_WEBUI_IMAGE_URL and
OPEN_WEBUI_IMAGE_API_KEY
- UserConfig model and config loading/saving pipeline updated
Frontend changes:
- New "Open WebUI" option in image provider dropdown
- Settings UI with URL and optional API key fields
- Validation, field mappings, and config persistence
Docker:
- OPEN_WEBUI_IMAGE_URL and OPEN_WEBUI_IMAGE_API_KEY added to all
docker-compose service definitions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
from enums.image_provider import ImageProvider
|
|
from utils.get_env import (
|
|
get_disable_image_generation_env,
|
|
get_image_provider_env,
|
|
)
|
|
from utils.parsers import parse_bool_or_none
|
|
|
|
|
|
def is_image_generation_disabled() -> bool:
|
|
return parse_bool_or_none(get_disable_image_generation_env()) or False
|
|
|
|
|
|
def is_pixels_selected() -> bool:
|
|
return ImageProvider.PEXELS == get_selected_image_provider()
|
|
|
|
|
|
def is_pixabay_selected() -> bool:
|
|
return ImageProvider.PIXABAY == get_selected_image_provider()
|
|
|
|
|
|
def is_gemini_flash_selected() -> bool:
|
|
return ImageProvider.GEMINI_FLASH == get_selected_image_provider()
|
|
|
|
|
|
def is_nanobanana_pro_selected() -> bool:
|
|
return ImageProvider.NANOBANANA_PRO == get_selected_image_provider()
|
|
|
|
|
|
def is_dalle3_selected() -> bool:
|
|
return ImageProvider.DALLE3 == get_selected_image_provider()
|
|
|
|
|
|
def is_gpt_image_1_5_selected() -> bool:
|
|
return ImageProvider.GPT_IMAGE_1_5 == get_selected_image_provider()
|
|
|
|
|
|
def is_comfyui_selected() -> bool:
|
|
return ImageProvider.COMFYUI == get_selected_image_provider()
|
|
|
|
|
|
def is_open_webui_selected() -> bool:
|
|
return ImageProvider.OPEN_WEBUI == get_selected_image_provider()
|
|
|
|
|
|
def get_selected_image_provider() -> ImageProvider | None:
|
|
"""
|
|
Get the selected image provider from environment variables.
|
|
Returns:
|
|
ImageProvider: The selected image provider.
|
|
"""
|
|
image_provider_env = get_image_provider_env()
|
|
if image_provider_env:
|
|
return ImageProvider(image_provider_env)
|
|
return None
|