Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(external): register multiple Atlas Cloud image models

binyangzhu000-sudo81d2ffd3274c
diff --git a/invokeai/app/services/external_generation/providers/atlascloud.py b/invokeai/app/services/external_generation/providers/atlascloud.py
index 79dbca86a7..dd1dbc6980 100644
--- a/invokeai/app/services/external_generation/providers/atlascloud.py
+++ b/invokeai/app/services/external_generation/providers/atlascloud.py
@@ -2,7 +2,9 @@ from __future__ import annotations
import io
import time
-from typing import Any
+from dataclasses import dataclass
+from math import gcd
+from typing import Any, Literal
import requests
from PIL import Image
@@ -28,6 +30,78 @@ _DOWNLOAD_MAX_BYTES = 32 * 1024 * 1024
_SUCCESS_STATUSES = {"completed", "succeeded"}
_FAILURE_STATUSES = {"canceled", "cancelled", "failed"}
+# Atlas Cloud fronts many image models behind one endpoint, but their request schemas
+# differ: output dimensions arrive as an explicit "size" string, a named "image_size"
+# preset, or an "aspect_ratio", and batch size is spelled "num_images", "n", or is not
+# supported at all. Recording those differences per model keeps each starter model's
+# payload valid for the model it targets. Models absent from this table fall back to
+# the explicit-size schema used by most Atlas Cloud image models, so custom installs
+# via `external://atlascloud/<model_id>` keep working.
+_SizeStyle = Literal["size", "image_size", "aspect_ratio"]
+
+# Size presets spelled the way the upstream models spell them. Note that `portrait_3_4`
+# and `portrait_4_3` both describe a 3:4 portrait: the prefix fixes the orientation, not
+# the order of the digits.
+_STANDARD_SIZE_PRESETS = (
+ "square_hd",
+ "square",
+ "portrait_3_4",
+ "portrait_9_16",
+ "landscape_4_3",
+ "landscape_16_9",
+)
+_HIDREAM_SIZE_PRESETS = (
+ "square_hd",
+ "square",
+ "portrait_4_3",
+ "portrait_16_9",
+ "landscape_4_3",
+ "landscape_16_9",
+)
+
+
+@dataclass(frozen=True)
+class _AtlasModelSchema:
+ """Request fields accepted by a single Atlas Cloud image model."""
+
+ size_style: _SizeStyle = "size"
+ size_presets: tuple[str, ...] = ()
+ num_images_field: str | None = "num_images"
+ supports_seed: bool = True
+ resolution_field: str | None = None
+
+
+_DEFAULT_MODEL_SCHEMA = _AtlasModelSchema()
+
+_MODEL_SCHEMAS: dict[str, _AtlasModelSchema] = {
+ # Explicit "<width>*<height>" size string
+ "black-forest-labs/flux-schnell": _AtlasModelSchema(),
+ "black-forest-labs/flux-dev": _AtlasModelSchema(),
+ "black-forest-labs/flux-2-pro/text-to-image": _AtlasModelSchema(num_images_field=None),
+ "qwen-image-3.0/text-to-image": _AtlasModelSchema(num_images_field="n"),
+ "z-image/turbo": _AtlasModelSchema(num_images_field=None),
+ "microsoft/mai-image-2.5/text-to-image": _AtlasModelSchema(num_images_field=None, supports_seed=False),
+ # Named "image_size" preset
+ "ideogram/v4/turbo/text-to-image": _AtlasModelSchema(
+ size_style="image_size", size_presets=_STANDARD_SIZE_PRESETS, num_images_field=None
+ ),
+ "ideogram/v4/quality/text-to-image": _AtlasModelSchema(
+ size_style="image_size", size_presets=_STANDARD_SIZE_PRESETS, num_images_field=None
+ ),
+ "krea-2-turbo/text-to-image": _AtlasModelSchema(size_style="image_size", size_presets=_STANDARD_SIZE_PRESETS),
+ "hidream-o1-1.5/text-to-image": _AtlasModelSchema(
+ size_style="image_size",
+ size_presets=_HIDREAM_SIZE_PRESETS,
+ num_images_field=None,
+ supports_seed=False,
+ ),
+ # "aspect_ratio" string
+ "xai/grok-imagine-image-2.0/text-to-image": _AtlasModelSchema(size_style="aspect_ratio", supports_seed=False),
+ "google/nano-banana-2/text-to-image": _AtlasModelSchema(
+ size_style="aspect_ratio", num_images_field=None, resolution_field="resolution"
+ ),
+}
+
class AtlasCloudProvider(ExternalProvider):
provider_id = "atlascloud"
@@ -45,14 +119,7 @@ class AtlasCloudProvider(ExternalProvider):
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
}
- payload: dict[str, object] = {
- "model": request.model.provider_model_id,
- "prompt": request.prompt,
- "size": f"{request.width}*{request.height}",
- "num_images": request.num_images,
- }
- if request.seed is not None:
- payload["seed"] = request.seed
+ payload = self._build_payload(request)
submit_url = f"{base_url}/api/v1/model/generateImage"
try:
@@ -90,6 +157,35 @@ class AtlasCloudProvider(ExternalProvider):
},
)
+ def _build_payload(self, request: ExternalGenerationRequest) -> dict[str, object]:
+ """Build a submission payload using the request fields the target model accepts."""
+ model_id = request.model.provider_model_id
+ schema = _MODEL_SCHEMAS.get(model_id, _DEFAULT_MODEL_SCHEMA)
+ payload: dict[str, object] = {"model": model_id, "prompt": request.prompt}
+
+ if schema.size_style == "size":
+ payload["size"] = f"{request.width}*{request.height}"
+ elif schema.size_style == "image_size":
+ payload["image_size"] = _select_size_preset(request.width, request.height, schema.size_presets)
+ else:
+ aspect_ratio = _select_aspect_ratio(
+ request.width, request.height, request.model.capabilities.allowed_aspect_ratios
+ )
+ if aspect_ratio is not None:
+ payload["aspect_ratio"] = aspect_ratio
+
+ # Resolution presets are named "1K"/"2K"/"4K" in Invoke and lowercase upstream.
+ if schema.resolution_field is not None and request.image_size is not None:
+ payload[schema.resolution_field] = request.image_size.lower()
+
+ if schema.num_images_field is not None:
+ payload[schema.num_images_field] = request.num_images
+
+ if schema.supports_seed and request.seed is not None:
+ payload["seed"] = request.seed
+
+ return payload
+
def _poll_prediction(
self,
poll_url: str,
@@ -208,3 +304,53 @@ def _parse_retry_after(value: str | None) -> float | None:
return float(value)
except ValueError:
return None
+
+
+def _select_size_preset(width: int, height: int, presets: tuple[str, ...]) -> str:
+ """Pick the named size preset whose aspect ratio is closest to the requested one."""
+ if not presets:
+ presets = _STANDARD_SIZE_PRESETS
+ if height <= 0 or width <= 0:
+ return presets[0]
+ ratio = width / height
+ return min(presets, key=lambda preset: abs(_preset_ratio(preset) - ratio))
+
+
+def _preset_ratio(preset: str) -> float:
+ """Aspect ratio of a named size preset, e.g. `landscape_16_9` -> 16/9, `portrait_3_4` -> 3/4."""
+ parts = preset.split("_")
+ numbers = [int(part) for part in parts[1:] if part.isdigit()]
+ if len(numbers) != 2:
+ return 1.0 # `square` and `square_hd`
+ longer, shorter = max(numbers), min(numbers)
+ return longer / shorter if parts[0] == "landscape" else shorter / longer
+
+
+def _select_aspect_ratio(width: int, height: int, allowed: list[str] | None) -> str | None:
+ """Pick the closest allowed aspect ratio, falling back to the exact reduced ratio."""
+ if width <= 0 or height <= 0:
+ return None
+ divisor = gcd(width, height)
+ exact = f"{width // divisor}:{height // divisor}"
+ if not allowed:
+ return exact
+ ratio = width / height
+ candidates = [(value, _parse_ratio(value)) for value in allowed]
+ parsed = [(value, parsed_ratio) for value, parsed_ratio in candidates if parsed_ratio is not None]
+ if not parsed:
+ return exact
+ return min(parsed, key=lambda item: abs(item[1] - ratio))[0]
+
+
+def _parse_ratio(value: str) -> float | None:
+ if ":" not in value:
+ return None
+ left, right = value.split(":", 1)
+ try:
+ numerator = float(left)
+ denominator = float(right)
+ except ValueError:
+ return None
+ if denominator == 0:
+ return None
+ return numerator / denominator
diff --git a/invokeai/backend/model_manager/starter_models.py b/invokeai/backend/model_manager/starter_models.py
index 71bff35940..b666ed3af2 100644
--- a/invokeai/backend/model_manager/starter_models.py
+++ b/invokeai/backend/model_manager/starter_models.py
@@ -1985,6 +1985,67 @@ OPENAI_GPT_IMAGE_PANEL_SCHEMA = ExternalModelPanelSchema(
prompts=[{"name": "reference_images"}], image=[{"name": "dimensions"}]
)
+# Atlas Cloud exposes these models through one endpoint, but each model only accepts a
+# subset of shapes. Models that take a named size preset or an aspect ratio are limited
+# to the ratios listed here; the rest accept explicit pixel sizes. Only ratios already
+# in lowest terms are listed, because a capability check reduces the requested
+# dimensions before comparing them against these entries.
+ATLASCLOUD_PRESET_ASPECT_RATIOS = ["1:1", "3:4", "4:3", "9:16", "16:9"]
+ATLASCLOUD_GROK_ASPECT_RATIOS = ["1:1", "1:2", "2:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9"]
+ATLASCLOUD_NANO_BANANA_ASPECT_RATIOS = [
+ "1:1",
+ "2:3",
+ "3:2",
+ "3:4",
+ "4:3",
+ "4:5",
+ "5:4",
+ "9:16",
+ "16:9",
+]
+
+
+def _atlascloud_aspect_ratio_sizes(aspect_ratios: list[str], base: int = 1024) -> dict[str, ExternalImageSize]:
+ """Pixel dimensions for each aspect ratio, with the long edge at or just below `base` px.
+
+ Both sides are exact multiples of the ratio, so a capability check reduces the
+ dimensions back to the same ratio string, and multiples of 16, so they stay valid
+ generation dimensions.
+ """
+ sizes: dict[str, ExternalImageSize] = {}
+ for ratio_str in aspect_ratios:
+ w_part, h_part = (int(part) for part in ratio_str.split(":"))
+ step = 16 * max(1, base // (max(w_part, h_part) * 16))
+ sizes[ratio_str] = ExternalImageSize(width=w_part * step, height=h_part * step)
+ return sizes
+
+
+def _atlascloud_resolution_presets(
+ image_sizes: list[str],
+ aspect_ratios: list[str],
+) -> list[ExternalResolutionPreset]:
+ """Build resolution presets pairing each aspect ratio with a resolution preset name."""
+ base_pixels = {"1K": 1024, "2K": 2048, "4K": 4096}
+ presets: list[ExternalResolutionPreset] = []
+ for image_size in image_sizes:
+ base = base_pixels[image_size]
+ for ratio_str, size in _atlascloud_aspect_ratio_sizes(aspect_ratios, base=base).items():
+ presets.append(
+ ExternalResolutionPreset(
+ label=f"{ratio_str} ({image_size}) \u2014 {size.width}\u00d7{size.height}",
+ aspect_ratio=ratio_str,
+ image_size=image_size,
+ width=size.width,
+ height=size.height,
+ )
+ )
+ return presets
+
+
+ATLASCLOUD_NANO_BANANA_RESOLUTION_PRESETS = _atlascloud_resolution_presets(
+ ["1K", "2K", "4K"], ATLASCLOUD_NANO_BANANA_ASPECT_RATIOS
+)
+
atlascloud_flux_schnell = StarterModel(
name="Atlas Cloud FLUX.1 Schnell",
base=BaseModelType.External,
@@ -2002,6 +2063,209 @@ atlascloud_flux_schnell = StarterModel(
panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
)
+atlascloud_flux_dev = StarterModel(
+ name="Atlas Cloud FLUX.1 Dev",
+ base=BaseModelType.External,
+ source="external://atlascloud/black-forest-labs/flux-dev",
+ description="FLUX.1 Dev text-to-image generation through the Atlas Cloud asynchronous media API. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=4,
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_flux_2_pro = StarterModel(
+ name="Atlas Cloud FLUX.2 Pro",
+ base=BaseModelType.External,
+ source="external://atlascloud/black-forest-labs/flux-2-pro/text-to-image",
+ description="FLUX.2 Pro text-to-image generation through the Atlas Cloud asynchronous media API. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=1,
+ max_image_size=ExternalImageSize(width=2048, height=2048),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_qwen_image_3 = StarterModel(
+ name="Atlas Cloud Qwen Image 3.0",
+ base=BaseModelType.External,
+ source="external://atlascloud/qwen-image-3.0/text-to-image",
+ description="Qwen Image 3.0 text-to-image generation through the Atlas Cloud asynchronous media API. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=4,
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_z_image_turbo = StarterModel(
+ name="Atlas Cloud Z-Image Turbo",
+ base=BaseModelType.External,
+ source="external://atlascloud/z-image/turbo",
+ description="Z-Image Turbo text-to-image generation through the Atlas Cloud asynchronous media API. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=1,
+ max_image_size=ExternalImageSize(width=2048, height=2048),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_mai_image_2_5 = StarterModel(
+ name="Atlas Cloud MAI-Image-2.5",
+ base=BaseModelType.External,
+ source="external://atlascloud/microsoft/mai-image-2.5/text-to-image",
+ description="Microsoft MAI-Image-2.5 text-to-image generation through the Atlas Cloud asynchronous media API. Supports sizes from 768 to 1360 pixels per side. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=False,
+ max_images_per_request=1,
+ max_image_size=ExternalImageSize(width=1360, height=1360),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_ideogram_v4_turbo = StarterModel(
+ name="Atlas Cloud Ideogram V4 Turbo",
+ base=BaseModelType.External,
+ source="external://atlascloud/ideogram/v4/turbo/text-to-image",
+ description="Ideogram V4 Turbo text-to-image generation through the Atlas Cloud asynchronous media API. Dimensions are mapped to the closest supported size preset. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=1,
+ allowed_aspect_ratios=ATLASCLOUD_PRESET_ASPECT_RATIOS,
+ aspect_ratio_sizes=_atlascloud_aspect_ratio_sizes(ATLASCLOUD_PRESET_ASPECT_RATIOS),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_ideogram_v4_quality = StarterModel(
+ name="Atlas Cloud Ideogram V4 Quality",
+ base=BaseModelType.External,
+ source="external://atlascloud/ideogram/v4/quality/text-to-image",
+ description="Ideogram V4 Quality text-to-image generation through the Atlas Cloud asynchronous media API. Dimensions are mapped to the closest supported size preset. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=1,
+ allowed_aspect_ratios=ATLASCLOUD_PRESET_ASPECT_RATIOS,
+ aspect_ratio_sizes=_atlascloud_aspect_ratio_sizes(ATLASCLOUD_PRESET_ASPECT_RATIOS),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_krea_2_turbo = StarterModel(
+ name="Atlas Cloud Krea 2 Turbo",
+ base=BaseModelType.External,
+ source="external://atlascloud/krea-2-turbo/text-to-image",
+ description="Krea 2 Turbo text-to-image generation through the Atlas Cloud asynchronous media API. Dimensions are mapped to the closest supported size preset. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=4,
+ allowed_aspect_ratios=ATLASCLOUD_PRESET_ASPECT_RATIOS,
+ aspect_ratio_sizes=_atlascloud_aspect_ratio_sizes(ATLASCLOUD_PRESET_ASPECT_RATIOS),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_hidream_o1_1_5 = StarterModel(
+ name="Atlas Cloud HiDream O1 1.5",
+ base=BaseModelType.External,
+ source="external://atlascloud/hidream-o1-1.5/text-to-image",
+ description="HiDream O1 1.5 text-to-image generation through the Atlas Cloud asynchronous media API. Dimensions are mapped to the closest supported size preset. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=False,
+ max_images_per_request=1,
+ allowed_aspect_ratios=ATLASCLOUD_PRESET_ASPECT_RATIOS,
+ aspect_ratio_sizes=_atlascloud_aspect_ratio_sizes(ATLASCLOUD_PRESET_ASPECT_RATIOS),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_grok_imagine_image_2 = StarterModel(
+ name="Atlas Cloud Grok Imagine Image 2.0",
+ base=BaseModelType.External,
+ source="external://atlascloud/xai/grok-imagine-image-2.0/text-to-image",
+ description="xAI Grok Imagine Image 2.0 text-to-image generation through the Atlas Cloud asynchronous media API. Dimensions are mapped to the closest supported aspect ratio. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=False,
+ max_images_per_request=4,
+ allowed_aspect_ratios=ATLASCLOUD_GROK_ASPECT_RATIOS,
+ aspect_ratio_sizes=_atlascloud_aspect_ratio_sizes(ATLASCLOUD_GROK_ASPECT_RATIOS),
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
+atlascloud_nano_banana_2 = StarterModel(
+ name="Atlas Cloud Nano Banana 2",
+ base=BaseModelType.External,
+ source="external://atlascloud/google/nano-banana-2/text-to-image",
+ description="Google Nano Banana 2 text-to-image generation through the Atlas Cloud asynchronous media API. Supports 1K/2K/4K resolution presets. Requires a configured Atlas Cloud API key and may incur provider usage costs.",
+ type=ModelType.ExternalImageGenerator,
+ format=ModelFormat.ExternalApi,
+ capabilities=ExternalModelCapabilities(
+ modes=["txt2img"],
+ supports_negative_prompt=False,
+ supports_seed=True,
+ max_images_per_request=1,
+ allowed_aspect_ratios=ATLASCLOUD_NANO_BANANA_ASPECT_RATIOS,
+ aspect_ratio_sizes=_atlascloud_aspect_ratio_sizes(ATLASCLOUD_NANO_BANANA_ASPECT_RATIOS),
+ resolution_presets=ATLASCLOUD_NANO_BANANA_RESOLUTION_PRESETS,
+ ),
+ default_settings=ExternalApiModelDefaultSettings(width=1024, height=1024, num_images=1),
+ panel_schema=ExternalModelPanelSchema(image=[{"name": "dimensions"}]),
+)
+
openai_gpt_image_2 = StarterModel(
name="GPT Image 2",
base=BaseModelType.External,
@@ -2463,6 +2727,17 @@ STARTER_MODELS: list[StarterModel] = [
gemini_pro_image_preview,
gemini_3_1_flash_image_preview,
atlascloud_flux_schnell,
+ atlascloud_flux_dev,
+ atlascloud_flux_2_pro,
+ atlascloud_qwen_image_3,
+ atlascloud_z_image_turbo,
+ atlascloud_mai_image_2_5,
+ atlascloud_ideogram_v4_turbo,
+ atlascloud_ideogram_v4_quality,
+ atlascloud_krea_2_turbo,
+ atlascloud_hidream_o1_1_5,
+ atlascloud_grok_imagine_image_2,
+ atlascloud_nano_banana_2,
openai_gpt_image_2,
openai_gpt_image_1_5,
openai_gpt_image_1,
diff --git a/tests/app/services/external_generation/test_atlascloud_provider.py b/tests/app/services/external_generation/test_atlascloud_provider.py
index 056d3384bc..e3fb1039ca 100644
--- a/tests/app/services/external_generation/test_atlascloud_provider.py
+++ b/tests/app/services/external_generation/test_atlascloud_provider.py
@@ -14,6 +14,7 @@ from invokeai.app.services.external_generation.external_generation_common import
from invokeai.app.services.external_generation.providers.atlascloud import AtlasCloudProvider
from invokeai.backend.model_manager.configs.external_api import ExternalApiModelConfig, ExternalModelCapabilities
from invokeai.backend.model_manager.starter_models import STARTER_MODELS
+from invokeai.backend.model_manager.taxonomy import BaseModelType, ModelFormat, ModelType
class DummyResponse:
@@ -69,6 +70,21 @@ def _model() -> ExternalApiModelConfig:
)
+def _starter_config(provider_model_id: str) -> ExternalApiModelConfig:
+ """Build a model config from the registered starter model, so payloads are checked
+ against the capabilities the app actually ships."""
+ source = f"external://atlascloud/{provider_model_id}"
+ starter = next(model for model in STARTER_MODELS if model.source == source)
+ assert starter.capabilities is not None
+ return ExternalApiModelConfig(
+ key=provider_model_id,
+ name=starter.name,
+ provider_id="atlascloud",
+ provider_model_id=provider_model_id,
+ capabilities=starter.capabilities,
+ )
+
+
def _request() -> ExternalGenerationRequest:
return ExternalGenerationRequest(
model=_model(),
@@ -231,3 +247,159 @@ def test_atlascloud_requires_api_key() -> None:
with pytest.raises(ExternalProviderRequestError, match="API key is not configured"):
provider.generate(_request())
+
+
+def test_atlascloud_starter_models_cover_multiple_models() -> None:
+ atlas_models = [model for model in STARTER_MODELS if model.source.startswith("external://atlascloud/")]
+ assert len(atlas_models) > 1
+ sources = [model.source for model in atlas_models]
+ assert len(sources) == len(set(sources))
+ for model in atlas_models:
+ assert model.base is BaseModelType.External
+ assert model.type is ModelType.ExternalImageGenerator
+ assert model.format is ModelFormat.ExternalApi
+ assert model.capabilities is not None
+ assert model.capabilities.modes == ["txt2img"]
+
+
+ "provider_model_id, num_images, expected_extra",
+ [
+ # Explicit "<width>*<height>" size string
+ ("black-forest-labs/flux-schnell", 2, {"size": "1024*768", "num_images": 2, "seed": 42}),
+ ("black-forest-labs/flux-dev", 2, {"size": "1024*768", "num_images": 2, "seed": 42}),
+ ("black-forest-labs/flux-2-pro/text-to-image", 1, {"size": "1024*768", "seed": 42}),
+ # Batch size is spelled "n" here
+ ("qwen-image-3.0/text-to-image", 2, {"size": "1024*768", "n": 2, "seed": 42}),
+ ("z-image/turbo", 1, {"size": "1024*768", "seed": 42}),
+ # No seed support upstream
+ ("microsoft/mai-image-2.5/text-to-image", 1, {"size": "1024*768"}),
+ # Named "image_size" preset
+ ("ideogram/v4/turbo/text-to-image", 1, {"image_size": "landscape_4_3", "seed": 42}),
+ ("ideogram/v4/quality/text-to-image", 1, {"image_size": "landscape_4_3", "seed": 42}),
+ ("krea-2-turbo/text-to-image", 2, {"image_size": "landscape_4_3", "num_images": 2, "seed": 42}),
+ ("hidream-o1-1.5/text-to-image", 1, {"image_size": "landscape_4_3"}),
+ # "aspect_ratio" string
+ ("xai/grok-imagine-image-2.0/text-to-image", 2, {"aspect_ratio": "4:3", "num_images": 2}),
+ ("google/nano-banana-2/text-to-image", 1, {"aspect_ratio": "4:3", "seed": 42}),
+ ],
+)
+def test_atlascloud_payload_matches_model_request_schema(
+ provider_model_id: str,
+ num_images: int,
+ expected_extra: dict[str, object],
+) -> None:
+ """Each model only receives the request fields its upstream schema accepts."""
+ provider = AtlasCloudProvider(InvokeAIAppConfig(external_atlascloud_api_key="atlas-key"), logging.getLogger("test"))
+ request = ExternalGenerationRequest(
+ model=_starter_config(provider_model_id),
+ mode="txt2img",
+ prompt="a blue square",
+ seed=42,
+ num_images=num_images,
+ width=1024,
+ height=768,
+ image_size=None,
+ init_image=None,
+ mask_image=None,
+ reference_images=[],
+ metadata=None,
+ )
+
+ payload = provider._build_payload(request)
+
+ assert payload == {"model": provider_model_id, "prompt": "a blue square", **expected_extra}
+
+
+def test_atlascloud_resolution_preset_is_forwarded_lowercase() -> None:
+ provider = AtlasCloudProvider(InvokeAIAppConfig(external_atlascloud_api_key="atlas-key"), logging.getLogger("test"))
+ request = ExternalGenerationRequest(
+ model=_starter_config("google/nano-banana-2/text-to-image"),
+ mode="txt2img",
+ prompt="a blue square",
+ seed=None,
+ num_images=1,
+ width=1024,
+ height=1024,
+ image_size="2K",
+ init_image=None,
+ mask_image=None,
+ reference_images=[],
+ metadata=None,
+ )
+
+ payload = provider._build_payload(request)
+
+ assert payload["aspect_ratio"] == "1:1"
+ assert payload["resolution"] == "2k"
+
+
+ "provider_model_id, width, height, expected_preset",
+ [
+ ("ideogram/v4/turbo/text-to-image", 1024, 1024, "square_hd"),
+ ("ideogram/v4/turbo/text-to-image", 1920, 1080, "landscape_16_9"),
+ # `portrait_9_16` and `portrait_16_9` both mean a 9:16 portrait, so the digit
+ # order in the preset name must not flip the orientation.
+ ("ideogram/v4/turbo/text-to-image", 1080, 1920, "portrait_9_16"),
+ ("hidream-o1-1.5/text-to-image", 1080, 1920, "portrait_16_9"),
+ ("hidream-o1-1.5/text-to-image", 1920, 1080, "landscape_16_9"),
+ ],
+)
+def test_atlascloud_selects_closest_size_preset(
+ provider_model_id: str,
+ width: int,
+ height: int,
+ expected_preset: str,
+) -> None:
+ provider = AtlasCloudProvider(InvokeAIAppConfig(external_atlascloud_api_key="atlas-key"), logging.getLogger("test"))
+ request = ExternalGenerationRequest(
+ model=_starter_config(provider_model_id),
+ mode="txt2img",
+ prompt="a blue square",
+ seed=None,
+ num_images=1,
+ width=width,
+ height=height,
+ image_size=None,
+ init_image=None,
+ mask_image=None,
+ reference_images=[],
+ metadata=None,
+ )
+
+ assert provider._build_payload(request)["image_size"] == expected_preset
+
+
+def test_atlascloud_unknown_model_uses_explicit_size_schema() -> None:
+ """Custom installs via `external://atlascloud/<model_id>` keep working."""
+ provider = AtlasCloudProvider(InvokeAIAppConfig(external_atlascloud_api_key="atlas-key"), logging.getLogger("test"))
+ model = ExternalApiModelConfig(
+ key="custom",
+ name="Custom Atlas Cloud Model",
+ provider_id="atlascloud",
+ provider_model_id="vendor/some-unlisted-model",
+ capabilities=ExternalModelCapabilities(modes=["txt2img"], supports_seed=True),
+ )
+ request = ExternalGenerationRequest(
+ model=model,
+ mode="txt2img",
+ prompt="a blue square",
+ seed=7,
+ num_images=1,
+ width=512,
+ height=512,
+ image_size=None,
+ init_image=None,
+ mask_image=None,
+ reference_images=[],
+ metadata=None,
+ )
+
+ assert provider._build_payload(request) == {
+ "model": "vendor/some-unlisted-model",
+ "prompt": "a blue square",
+ "size": "512*512",
+ "num_images": 1,
+ "seed": 7,
+ }