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>
135 lines
2.7 KiB
Python
135 lines
2.7 KiB
Python
import os
|
|
|
|
|
|
def set_temp_directory_env(value):
|
|
os.environ["TEMP_DIRECTORY"] = value
|
|
|
|
|
|
def set_user_config_path_env(value):
|
|
os.environ["USER_CONFIG_PATH"] = value
|
|
|
|
|
|
def set_llm_provider_env(value):
|
|
os.environ["LLM"] = value
|
|
|
|
|
|
def set_ollama_url_env(value):
|
|
os.environ["OLLAMA_URL"] = value
|
|
|
|
|
|
def set_custom_llm_url_env(value):
|
|
os.environ["CUSTOM_LLM_URL"] = value
|
|
|
|
|
|
def set_openai_api_key_env(value):
|
|
os.environ["OPENAI_API_KEY"] = value
|
|
|
|
|
|
def set_openai_model_env(value):
|
|
os.environ["OPENAI_MODEL"] = value
|
|
|
|
|
|
def set_google_api_key_env(value):
|
|
os.environ["GOOGLE_API_KEY"] = value
|
|
|
|
|
|
def set_google_model_env(value):
|
|
os.environ["GOOGLE_MODEL"] = value
|
|
|
|
|
|
def set_anthropic_api_key_env(value):
|
|
os.environ["ANTHROPIC_API_KEY"] = value
|
|
|
|
|
|
def set_anthropic_model_env(value):
|
|
os.environ["ANTHROPIC_MODEL"] = value
|
|
|
|
|
|
def set_custom_llm_api_key_env(value):
|
|
os.environ["CUSTOM_LLM_API_KEY"] = value
|
|
|
|
|
|
def set_ollama_model_env(value):
|
|
os.environ["OLLAMA_MODEL"] = value
|
|
|
|
|
|
def set_custom_model_env(value):
|
|
os.environ["CUSTOM_MODEL"] = value
|
|
|
|
|
|
def set_pexels_api_key_env(value):
|
|
os.environ["PEXELS_API_KEY"] = value
|
|
|
|
|
|
def set_image_provider_env(value):
|
|
os.environ["IMAGE_PROVIDER"] = value
|
|
|
|
|
|
def set_pixabay_api_key_env(value):
|
|
os.environ["PIXABAY_API_KEY"] = value
|
|
|
|
|
|
def set_disable_image_generation_env(value):
|
|
os.environ["DISABLE_IMAGE_GENERATION"] = value
|
|
|
|
|
|
def set_tool_calls_env(value):
|
|
os.environ["TOOL_CALLS"] = value
|
|
|
|
|
|
def set_disable_thinking_env(value):
|
|
os.environ["DISABLE_THINKING"] = value
|
|
|
|
|
|
def set_extended_reasoning_env(value):
|
|
os.environ["EXTENDED_REASONING"] = value
|
|
|
|
|
|
def set_web_grounding_env(value):
|
|
os.environ["WEB_GROUNDING"] = value
|
|
|
|
|
|
def set_comfyui_url_env(value):
|
|
os.environ["COMFYUI_URL"] = value
|
|
|
|
|
|
def set_comfyui_workflow_env(value):
|
|
os.environ["COMFYUI_WORKFLOW"] = value
|
|
|
|
|
|
def set_dall_e_3_quality_env(value):
|
|
os.environ["DALL_E_3_QUALITY"] = value
|
|
|
|
|
|
def set_gpt_image_1_5_quality_env(value):
|
|
os.environ["GPT_IMAGE_1_5_QUALITY"] = value
|
|
|
|
|
|
# Codex OAuth
|
|
def set_codex_access_token_env(value: str):
|
|
os.environ["CODEX_ACCESS_TOKEN"] = value
|
|
|
|
|
|
def set_codex_refresh_token_env(value: str):
|
|
os.environ["CODEX_REFRESH_TOKEN"] = value
|
|
|
|
|
|
def set_codex_token_expires_env(value: str):
|
|
os.environ["CODEX_TOKEN_EXPIRES"] = value
|
|
|
|
|
|
def set_codex_account_id_env(value: str):
|
|
os.environ["CODEX_ACCOUNT_ID"] = value
|
|
|
|
|
|
def set_codex_model_env(value: str):
|
|
os.environ["CODEX_MODEL"] = value
|
|
|
|
|
|
# Open WebUI Image Provider
|
|
def set_open_webui_image_url_env(value: str):
|
|
os.environ["OPEN_WEBUI_IMAGE_URL"] = value
|
|
|
|
|
|
def set_open_webui_image_api_key_env(value: str):
|
|
os.environ["OPEN_WEBUI_IMAGE_API_KEY"] = value
|