Implementation:ALwrity ALwrity CreateStudioService
| Knowledge Sources | |
|---|---|
| Domains | Image_Studio, Image_Generation, LLM |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Concrete tool for smart provider/model selection and image generation orchestration across Stability AI, WaveSpeed, HuggingFace, and Gemini, provided by the ALwrity Image Studio subsystem.
Description
The CreateStudioService class is stage 1 of the Image Studio workflow. It selects the best image-generation provider and model based on three precedence levels: (1) explicit user selection (request.provider != "auto"), (2) template recommendation (template.recommended_provider), (3) quality-based defaults (QUALITY_PROVIDERS mapping draft→WaveSpeed Qwen, standard→WaveSpeed/Stability Core, premium→Ideogram V3 Turbo/Stability Ultra). The selected provider and model are passed to the unified generate_image entry point in main_image_generation. The service also manages platform templates via TemplateManager.
Usage
Import this service when:
- A user requests image generation with a text prompt and optional template/quality.
- Provider auto-selection is needed based on quality tier (draft/standard/premium).
- Template-based recommendations should override quality defaults.
Code Reference
Source Location
- Repository: ALwrity
- File: backend/services/image_studio/create_service.py (L37-120)
Signature
class CreateStudioRequest:
prompt: str
provider: Optional[str] = "auto" # auto/stability/wavespeed/huggingface/gemini
model: Optional[str] = None
quality: Literal["draft", "standard", "premium"] = "standard"
width: int = 1024
height: int = 1024
aspect_ratio: str = "1:1"
num_variations: int = 1
negative_prompt: Optional[str] = None
seed: Optional[int] = None
enhance_prompt: bool = True
use_persona: bool = False
persona_id: Optional[str] = None
class CreateStudioService:
PROVIDER_MODELS = {
"stability": {"ultra": "stability-ultra", "core": "stability-core", "sd3": "sd3.5-large"},
"wavespeed": {"ideogram-v3-turbo": "ideogram-v3-turbo", "qwen-image": "qwen-image"},
"huggingface": {"flux": "black-forest-labs/FLUX.1-Krea-dev"},
"gemini": {"imagen": "imagen-3.0-generate-001"},
}
QUALITY_PROVIDERS = {
"draft": ["wavespeed:qwen-image", "huggingface"],
"standard": ["wavespeed:qwen-image", "stability:core"],
"premium": ["wavespeed:ideogram-v3-turbo", "stability:ultra"],
}
def __init__(self):
self.template_manager = TemplateManager()
def _select_provider_and_model(
self,
request: CreateStudioRequest,
template: Optional[ImageTemplate] = None,
) -> tuple[str, Optional[str]]:
"""Smart provider and model selection (explicit > template > quality)."""
Import
from services.image_studio.create_service import CreateStudioService, CreateStudioRequest
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| request | CreateStudioRequest | Yes | prompt, provider, model, quality, dimensions, negative_prompt, seed |
| template | Optional[ImageTemplate] | No | Template with recommended_provider |
Outputs
| Name | Type | Description |
|---|---|---|
| return | tuple[str, Optional[str]] | (provider_name, model_name) for the unified generate_image entry point |
Usage Examples
Auto-selecting a provider by quality
from services.image_studio.create_service import CreateStudioService, CreateStudioRequest
service = CreateStudioService()
request = CreateStudioRequest(
prompt="A futuristic city at sunset, cyberpunk style",
quality="premium",
aspect_ratio="16:9",
)
provider, model = service._select_provider_and_model(request)
print(f"Selected: {provider}/{model}") # e.g. wavespeed/ideogram-v3-turbo
# Delegate to unified generation entry point
from services.llm_providers.main_image_generation import generate_image
result = generate_image(prompt=request.prompt, provider=provider, model=model, ...)
Explicit provider selection
request = CreateStudioRequest(
prompt="A watercolor landscape",
provider="stability",
model="stability-core",
)
provider, model = service._select_provider_and_model(request)
# Respects user choice: ("stability", "stability-core")