Skip to content

object_models

DEFAULT_BASELINE_RESOLUTION module-attribute

DEFAULT_BASELINE_RESOLUTION: int = 512

The default assumed (single side) trained resolution for image generation models if unspecified.

HIRES_FIX_DENOISE_STRENGTH_DEFAULT module-attribute

HIRES_FIX_DENOISE_STRENGTH_DEFAULT: float = 0.65

The default second-pass denoise strength for hires-fix generations.

default_basic_image_generation_parameters module-attribute

default_basic_image_generation_parameters = (
    BasicImageGenerationParameters(
        prompt="EXAMPLE_PROMPT",
        model="EXAMPLE_MODEL",
        model_baseline="infer",
        seed="1",
        height=DEFAULT_BASELINE_RESOLUTION,
        width=DEFAULT_BASELINE_RESOLUTION,
        steps=20,
        cfg_scale=7.0,
        sampler_name=k_lms,
        scheduler=normal,
        clip_skip=1,
        denoising_strength=0.75,
    )
)

ControlnetFeatureFlags

Bases: GenerationParameterBaseModel

Feature flags for controlnet.

Source code in horde_sdk/generation_parameters/image/object_models.py
class ControlnetFeatureFlags(GenerationParameterBaseModel):
    """Feature flags for controlnet."""

    model_config = get_default_frozen_model_config_dict()

    controlnets: list[KNOWN_IMAGE_CONTROLNETS | str] = Field(
        examples=[
            [KNOWN_IMAGE_CONTROLNETS.canny],
            [KNOWN_IMAGE_CONTROLNETS.canny, KNOWN_IMAGE_CONTROLNETS.depth],
        ],
    )
    """The controlnets supported by the worker."""

    image_is_control: bool = Field(default=False)
    """Whether there is support for passing a pre-parsed control image."""

    return_control_map: bool = Field(default=False)
    """Whether there is support returning the control map."""

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

controlnets class-attribute instance-attribute

controlnets: list[KNOWN_IMAGE_CONTROLNETS | str] = Field(
    examples=[[canny], [canny, depth]]
)

The controlnets supported by the worker.

image_is_control class-attribute instance-attribute

image_is_control: bool = Field(default=False)

Whether there is support for passing a pre-parsed control image.

return_control_map class-attribute instance-attribute

return_control_map: bool = Field(default=False)

Whether there is support returning the control map.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

ImageGenerationFeatureFlags

Bases: GenerationFeatureFlags

Feature flags for an image worker.

Source code in horde_sdk/generation_parameters/image/object_models.py
class ImageGenerationFeatureFlags(GenerationFeatureFlags):
    """Feature flags for an image worker."""

    baselines: list[KNOWN_IMAGE_GENERATION_BASELINE | str] = Field(
        examples=[
            [KNOWN_IMAGE_GENERATION_BASELINE.infer],
            [KNOWN_IMAGE_GENERATION_BASELINE.infer, KNOWN_IMAGE_GENERATION_BASELINE.stable_diffusion_1],
        ],
    )
    """The baselines supported for standard image generation.

    If `infer`, the worker will attempt to infer the model type from the model name.
    """

    clip_skip: bool = Field(default=False)
    """Whether there is support for clip skipping."""

    hires_fix: bool = Field(default=False)
    """Whether there is support for hires fix."""

    tiling: bool = Field(default=False)
    """Whether there is support for seamless tiling."""

    schedulers: list[KNOWN_IMAGE_SCHEDULERS | str] = Field(
        examples=[
            [KNOWN_IMAGE_SCHEDULERS.normal],
            [KNOWN_IMAGE_SCHEDULERS.normal, KNOWN_IMAGE_SCHEDULERS.simple],
        ],
    )
    """The schedulers supported."""

    samplers: list[KNOWN_IMAGE_SAMPLERS | str] = Field(
        examples=[
            [KNOWN_IMAGE_SAMPLERS.k_euler],
            [KNOWN_IMAGE_SAMPLERS.k_lms, KNOWN_IMAGE_SAMPLERS.k_euler],
        ],
    )
    """The samplers supported."""

    controlnets_feature_flags: ControlnetFeatureFlags | None = Field(
        default=None,
        examples=[
            ControlnetFeatureFlags(
                controlnets=[KNOWN_IMAGE_CONTROLNETS.canny],
                image_is_control=False,
                return_control_map=False,
            ),
            ControlnetFeatureFlags(
                controlnets=[KNOWN_IMAGE_CONTROLNETS.canny, KNOWN_IMAGE_CONTROLNETS.depth],
                image_is_control=True,
                return_control_map=True,
            ),
        ],
    )
    """The controlnet feature flags for the worker."""

    post_processing: list[KNOWN_ALCHEMY_TYPES | str] | None = Field(
        default=None,
        examples=[
            [KNOWN_ALCHEMY_TYPES.RealESRGAN_x4plus],
            [KNOWN_ALCHEMY_TYPES.RealESRGAN_x4plus, KNOWN_ALCHEMY_TYPES.GFPGAN],
        ],
    )
    """The post processing methods."""

    source_processing: list[KNOWN_IMAGE_SOURCE_PROCESSING | str] = Field(
        examples=[
            [KNOWN_IMAGE_SOURCE_PROCESSING.txt2img],
            [KNOWN_IMAGE_SOURCE_PROCESSING.txt2img, KNOWN_IMAGE_SOURCE_PROCESSING.img2img],
            [
                KNOWN_IMAGE_SOURCE_PROCESSING.txt2img,
                KNOWN_IMAGE_SOURCE_PROCESSING.img2img,
                KNOWN_IMAGE_SOURCE_PROCESSING.inpainting,
            ],
        ],
    )
    """The source processing methods."""

    workflows: list[KNOWN_IMAGE_WORKFLOWS | str] | None = Field(
        default=None,
        examples=[
            [KNOWN_IMAGE_WORKFLOWS.qr_code],
        ],
    )
    """The workflows supported."""

    tis: list[KNOWN_AUX_MODEL_SOURCE | str] | None = Field(
        default=None,
        examples=[
            [KNOWN_AUX_MODEL_SOURCE.HORDELING],
            [KNOWN_AUX_MODEL_SOURCE.LOCAL],
        ],
    )
    """If textual inversions are supported, the sources of the textual inversions supported."""

    loras: list[KNOWN_AUX_MODEL_SOURCE | str] | None = Field(
        default=None,
        examples=[
            [KNOWN_AUX_MODEL_SOURCE.CIVITAI],
            [KNOWN_AUX_MODEL_SOURCE.LOCAL],
        ],
    )

    """If loras are supported, the sources of the loras supported."""

    @field_validator("baselines")
    @classmethod
    def ensure_baseline_non_empty(
        cls,
        v: list[KNOWN_IMAGE_GENERATION_BASELINE | str],
    ) -> list[KNOWN_IMAGE_GENERATION_BASELINE | str]:
        """Ensure that the baselines are not empty."""
        if not v:
            raise ValueError("Baselines cannot be empty.")
        return v

baselines class-attribute instance-attribute

baselines: list[KNOWN_IMAGE_GENERATION_BASELINE | str] = (
    Field(examples=[[infer], [infer, stable_diffusion_1]])
)

The baselines supported for standard image generation.

If infer, the worker will attempt to infer the model type from the model name.

clip_skip class-attribute instance-attribute

clip_skip: bool = Field(default=False)

Whether there is support for clip skipping.

hires_fix class-attribute instance-attribute

hires_fix: bool = Field(default=False)

Whether there is support for hires fix.

tiling class-attribute instance-attribute

tiling: bool = Field(default=False)

Whether there is support for seamless tiling.

schedulers class-attribute instance-attribute

schedulers: list[KNOWN_IMAGE_SCHEDULERS | str] = Field(
    examples=[[normal], [normal, simple]]
)

The schedulers supported.

samplers class-attribute instance-attribute

samplers: list[KNOWN_IMAGE_SAMPLERS | str] = Field(
    examples=[[k_euler], [k_lms, k_euler]]
)

The samplers supported.

controlnets_feature_flags class-attribute instance-attribute

controlnets_feature_flags: ControlnetFeatureFlags | None = (
    Field(
        default=None,
        examples=[
            ControlnetFeatureFlags(
                controlnets=[canny],
                image_is_control=False,
                return_control_map=False,
            ),
            ControlnetFeatureFlags(
                controlnets=[canny, depth],
                image_is_control=True,
                return_control_map=True,
            ),
        ],
    )
)

The controlnet feature flags for the worker.

post_processing class-attribute instance-attribute

post_processing: list[KNOWN_ALCHEMY_TYPES | str] | None = (
    Field(
        default=None,
        examples=[
            [RealESRGAN_x4plus],
            [RealESRGAN_x4plus, GFPGAN],
        ],
    )
)

The post processing methods.

source_processing class-attribute instance-attribute

source_processing: list[
    KNOWN_IMAGE_SOURCE_PROCESSING | str
] = Field(
    examples=[
        [txt2img],
        [txt2img, img2img],
        [txt2img, img2img, inpainting],
    ]
)

The source processing methods.

workflows class-attribute instance-attribute

workflows: list[KNOWN_IMAGE_WORKFLOWS | str] | None = Field(
    default=None, examples=[[qr_code]]
)

The workflows supported.

tis class-attribute instance-attribute

tis: list[KNOWN_AUX_MODEL_SOURCE | str] | None = Field(
    default=None, examples=[[HORDELING], [LOCAL]]
)

If textual inversions are supported, the sources of the textual inversions supported.

loras class-attribute instance-attribute

loras: list[KNOWN_AUX_MODEL_SOURCE | str] | None = Field(
    default=None, examples=[[CIVITAI], [LOCAL]]
)

If loras are supported, the sources of the loras supported.

model_config class-attribute instance-attribute

model_config = ConfigDict(use_attribute_docstrings=True)

extra_texts class-attribute instance-attribute

extra_texts: bool = Field(default=False)

Whether there is support for extra texts.

extra_source_images class-attribute instance-attribute

extra_source_images: bool = Field(default=False)

Whether there is support for extra source images.

ensure_baseline_non_empty classmethod

ensure_baseline_non_empty(
    v: list[KNOWN_IMAGE_GENERATION_BASELINE | str],
) -> list[KNOWN_IMAGE_GENERATION_BASELINE | str]

Ensure that the baselines are not empty.

Source code in horde_sdk/generation_parameters/image/object_models.py
@field_validator("baselines")
@classmethod
def ensure_baseline_non_empty(
    cls,
    v: list[KNOWN_IMAGE_GENERATION_BASELINE | str],
) -> list[KNOWN_IMAGE_GENERATION_BASELINE | str]:
    """Ensure that the baselines are not empty."""
    if not v:
        raise ValueError("Baselines cannot be empty.")
    return v

BasicImageGenerationParametersTemplate

Bases: GenerationWithModelParameters

Represents the common parameters for an image generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class BasicImageGenerationParametersTemplate(GenerationWithModelParameters):
    """Represents the common parameters for an image generation."""

    prompt: str | None = None
    """The prompt to use for the generation."""
    seed: str | None = None
    """The seed to use for the generation."""

    height: int | None = Field(
        default=None,
        multiple_of=64,
        ge=64,
        examples=[512, 768],
    )
    """The height to use for the generation."""
    width: int | None = Field(
        default=None,
        multiple_of=64,
        ge=64,
        examples=[512, 768],
    )
    """The width to use for the generation."""

    steps: int | None = Field(
        default=None,
        ge=1,
        examples=[4, 20, 50],
    )
    """The number of steps to use for the generation."""

    cfg_scale: float | None = Field(
        default=None,
        ge=0,
        examples=[0.0, 1.0, 7.0],
    )
    """The scale to use for the generation."""

    sampler_name: KNOWN_IMAGE_SAMPLERS | str | None = Field(
        default=None,
        examples=[KNOWN_IMAGE_SAMPLERS.k_lms],
    )
    """The sampler to use for the generation."""

    scheduler: KNOWN_IMAGE_SCHEDULERS | str | None = Field(
        default=None,
        examples=[KNOWN_IMAGE_SCHEDULERS.normal],
    )
    """The scheduler to use for the generation."""

    clip_skip: int | None = Field(
        default=None,
        examples=[-3, -2, -1, 1, 2, 3],
    )
    """The offset of layer numbers to skip. Be sure to check `clip_skip_representation` for the representation."""

    clip_skip_representation: CLIP_SKIP_REPRESENTATION | None = Field(
        default=None,
    )
    """The representation of the clip skip. See `CLIP_SKIP_REPRESENTATION` for more information.

    Typically front-ends use positive values, while comfyui used the same value but negative.
    """

    denoising_strength: float | None = Field(
        default=None,
        ge=0,
        le=1,
        examples=[0.0, 0.5, 1.0],
    )
    """The denoising strength to use for the generation."""

    tiling: bool | None = None
    """If true, the generation will be generated with seamless tiling."""

prompt class-attribute instance-attribute

prompt: str | None = None

The prompt to use for the generation.

seed class-attribute instance-attribute

seed: str | None = None

The seed to use for the generation.

height class-attribute instance-attribute

height: int | None = Field(
    default=None, multiple_of=64, ge=64, examples=[512, 768]
)

The height to use for the generation.

width class-attribute instance-attribute

width: int | None = Field(
    default=None, multiple_of=64, ge=64, examples=[512, 768]
)

The width to use for the generation.

steps class-attribute instance-attribute

steps: int | None = Field(
    default=None, ge=1, examples=[4, 20, 50]
)

The number of steps to use for the generation.

cfg_scale class-attribute instance-attribute

cfg_scale: float | None = Field(
    default=None, ge=0, examples=[0.0, 1.0, 7.0]
)

The scale to use for the generation.

sampler_name class-attribute instance-attribute

sampler_name: KNOWN_IMAGE_SAMPLERS | str | None = Field(
    default=None, examples=[k_lms]
)

The sampler to use for the generation.

scheduler class-attribute instance-attribute

scheduler: KNOWN_IMAGE_SCHEDULERS | str | None = Field(
    default=None, examples=[normal]
)

The scheduler to use for the generation.

clip_skip class-attribute instance-attribute

clip_skip: int | None = Field(
    default=None, examples=[-3, -2, -1, 1, 2, 3]
)

The offset of layer numbers to skip. Be sure to check clip_skip_representation for the representation.

clip_skip_representation class-attribute instance-attribute

clip_skip_representation: (
    CLIP_SKIP_REPRESENTATION | None
) = Field(default=None)

The representation of the clip skip. See CLIP_SKIP_REPRESENTATION for more information.

Typically front-ends use positive values, while comfyui used the same value but negative.

denoising_strength class-attribute instance-attribute

denoising_strength: float | None = Field(
    default=None, ge=0, le=1, examples=[0.0, 0.5, 1.0]
)

The denoising strength to use for the generation.

tiling class-attribute instance-attribute

tiling: bool | None = None

If true, the generation will be generated with seamless tiling.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME
) = MODEL

See :attr:ComposedParameterSetBase.underlying_generation_scheme for more information.

model class-attribute instance-attribute

model: str | None = None

model_baseline class-attribute instance-attribute

model_baseline: str | None = None

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

BasicImageGenerationParameters

Bases: BasicImageGenerationParametersTemplate

Represents the common bare minimum parameters for an image generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class BasicImageGenerationParameters(BasicImageGenerationParametersTemplate):
    """Represents the common bare minimum parameters for an image generation."""

    model_config = ConfigDict(
        frozen=True,
        from_attributes=True,
    )

    model: str
    """The model to use for the generation."""

    prompt: str
    """The prompt to use for the generation."""

    height: int | None = Field(
        default=DEFAULT_BASELINE_RESOLUTION,
        multiple_of=64,
        ge=64,
        examples=[512, 768],
    )
    """The height to use for the generation."""
    width: int | None = Field(
        default=DEFAULT_BASELINE_RESOLUTION,
        multiple_of=64,
        ge=64,
        examples=[512, 768],
    )
    """The width to use for the generation."""

    clip_skip_representation: CLIP_SKIP_REPRESENTATION | None = Field(
        default=CLIP_SKIP_REPRESENTATION.NEGATIVE_OFFSET,
    )
    """The representation of the clip skip. See `CLIP_SKIP_REPRESENTATION` for more information.

    Typically front-ends use positive values, while comfyui used the same value but negative.
    """

model_config class-attribute instance-attribute

model_config = ConfigDict(frozen=True, from_attributes=True)

model instance-attribute

model: str

The model to use for the generation.

prompt instance-attribute

prompt: str

The prompt to use for the generation.

height class-attribute instance-attribute

height: int | None = Field(
    default=DEFAULT_BASELINE_RESOLUTION,
    multiple_of=64,
    ge=64,
    examples=[512, 768],
)

The height to use for the generation.

width class-attribute instance-attribute

width: int | None = Field(
    default=DEFAULT_BASELINE_RESOLUTION,
    multiple_of=64,
    ge=64,
    examples=[512, 768],
)

The width to use for the generation.

clip_skip_representation class-attribute instance-attribute

clip_skip_representation: (
    CLIP_SKIP_REPRESENTATION | None
) = Field(default=NEGATIVE_OFFSET)

The representation of the clip skip. See CLIP_SKIP_REPRESENTATION for more information.

Typically front-ends use positive values, while comfyui used the same value but negative.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME
) = MODEL

See :attr:ComposedParameterSetBase.underlying_generation_scheme for more information.

model_baseline class-attribute instance-attribute

model_baseline: str | None = None

seed class-attribute instance-attribute

seed: str | None = None

The seed to use for the generation.

steps class-attribute instance-attribute

steps: int | None = Field(
    default=None, ge=1, examples=[4, 20, 50]
)

The number of steps to use for the generation.

cfg_scale class-attribute instance-attribute

cfg_scale: float | None = Field(
    default=None, ge=0, examples=[0.0, 1.0, 7.0]
)

The scale to use for the generation.

sampler_name class-attribute instance-attribute

sampler_name: KNOWN_IMAGE_SAMPLERS | str | None = Field(
    default=None, examples=[k_lms]
)

The sampler to use for the generation.

scheduler class-attribute instance-attribute

scheduler: KNOWN_IMAGE_SCHEDULERS | str | None = Field(
    default=None, examples=[normal]
)

The scheduler to use for the generation.

clip_skip class-attribute instance-attribute

clip_skip: int | None = Field(
    default=None, examples=[-3, -2, -1, 1, 2, 3]
)

The offset of layer numbers to skip. Be sure to check clip_skip_representation for the representation.

denoising_strength class-attribute instance-attribute

denoising_strength: float | None = Field(
    default=None, ge=0, le=1, examples=[0.0, 0.5, 1.0]
)

The denoising strength to use for the generation.

tiling class-attribute instance-attribute

tiling: bool | None = None

If true, the generation will be generated with seamless tiling.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

Image2ImageGenerationParameters

Bases: GenerationParameterBaseModel

Represents the parameters for an image-to-image generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class Image2ImageGenerationParameters(GenerationParameterBaseModel):
    """Represents the parameters for an image-to-image generation."""

    source_image: bytes | str | None
    """The source image to use for the generation."""
    source_mask: bytes | str | None
    """The source mask to use for the generation."""

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation.

source_mask instance-attribute

source_mask: bytes | str | None

The source mask to use for the generation.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

RemixImageEntry

Bases: GenerationParameterBaseModel

Represents a special image entry for a generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class RemixImageEntry(GenerationParameterBaseModel):
    """Represents a special image entry for a generation."""

    image: bytes | str
    """The image data."""

    strength: float = 1.0
    """The weight to apply this image to the remix generation."""

image instance-attribute

image: bytes | str

The image data.

strength class-attribute instance-attribute

strength: float = 1.0

The weight to apply this image to the remix generation.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

RemixGenerationParameters

Bases: GenerationParameterBaseModel

Represents the parameters for a stable cascade remix generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class RemixGenerationParameters(GenerationParameterBaseModel):
    """Represents the parameters for a stable cascade remix generation."""

    source_image: bytes | str
    """The source image to use for the generation."""

    remix_images: list[RemixImageEntry]
    """The images to remix the source image with."""

source_image instance-attribute

source_image: bytes | str

The source image to use for the generation.

remix_images instance-attribute

remix_images: list[RemixImageEntry]

The images to remix the source image with.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

ControlnetGenerationParameters

Bases: GenerationParameterBaseModel

Represents the parameters for a controlnet generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class ControlnetGenerationParameters(GenerationParameterBaseModel):
    """Represents the parameters for a controlnet generation."""

    controlnet_type: KNOWN_IMAGE_CONTROLNETS | str
    """The type of controlnet to use for the generation."""

    source_image: bytes | str | None
    """The source image to use for the generation, if img2img."""
    control_map: bytes | str | None
    """The control map to use for the generation, if img2img."""

    return_control_map: bool = False
    """If true, return the control map created by the controlnet pre-processor."""

controlnet_type instance-attribute

controlnet_type: KNOWN_IMAGE_CONTROLNETS | str

The type of controlnet to use for the generation.

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation, if img2img.

control_map instance-attribute

control_map: bytes | str | None

The control map to use for the generation, if img2img.

return_control_map class-attribute instance-attribute

return_control_map: bool = False

If true, return the control map created by the controlnet pre-processor.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

HiresFixGenerationParameters

Bases: GenerationParameterBaseModel

Represents the parameters for a high-resolution fix generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class HiresFixGenerationParameters(GenerationParameterBaseModel):
    """Represents the parameters for a high-resolution fix generation."""

    first_pass: BasicImageGenerationParameters
    second_pass: BasicImageGenerationParameters

first_pass instance-attribute

first_pass: BasicImageGenerationParameters

second_pass instance-attribute

second_pass: BasicImageGenerationParameters

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

AuxModelEntry

Bases: GenerationParameterBaseModel

Represents a single entry of an aux model, (LoRas, TIs, etc).

Source code in horde_sdk/generation_parameters/image/object_models.py
class AuxModelEntry(GenerationParameterBaseModel):
    """Represents a single entry of an aux model, (LoRas, TIs, etc)."""

    name: str | None
    """The name of the aux model. If this is a hosted aux model, the name to search for. See `remote_version_id` if
    targeting a specific version of a hosted aux model."""
    release_version: str | None = None
    """The version of the aux model. This is v1, v2, etc. If this is a hosted aux model, you should instead use
    `remote_version_id` and reference the platform-specific file identifier."""
    remote_version_id: str | None
    """If this aux model is sourced from a website/API, the version ID specific to that website/API
    to identify the specific version of the aux model. This is *not* v1, v2, but a numeric ID that the
    service assigns and is typically in the URL of the download link."""

    source: KNOWN_AUX_MODEL_SOURCE | str
    """The source of the aux model. This can be a known source or a custom source."""

    remote_url: str | None = None
    """The remote URL to download the aux model from."""
    local_filename: Path | None = None
    """The local filename to load the aux model from."""
    file_hash: str | None = None
    """The hash of the aux model file."""

    model_strength: float = 1
    """The strength of the aux model on the generation model. 1 is the default strength."""

    @model_validator(mode="after")
    def verify_identifier_set(self: AuxModelEntry) -> AuxModelEntry:
        """Ensure that at least one of name, version, or remote_version_id is provided."""
        if self.name is None and self.release_version is None and self.remote_version_id is None:
            raise ValueError("At least one of name, version, or remote_version_id must be provided.")

        return self

name instance-attribute

name: str | None

The name of the aux model. If this is a hosted aux model, the name to search for. See remote_version_id if targeting a specific version of a hosted aux model.

release_version class-attribute instance-attribute

release_version: str | None = None

The version of the aux model. This is v1, v2, etc. If this is a hosted aux model, you should instead use remote_version_id and reference the platform-specific file identifier.

remote_version_id instance-attribute

remote_version_id: str | None

If this aux model is sourced from a website/API, the version ID specific to that website/API to identify the specific version of the aux model. This is not v1, v2, but a numeric ID that the service assigns and is typically in the URL of the download link.

source instance-attribute

source: KNOWN_AUX_MODEL_SOURCE | str

The source of the aux model. This can be a known source or a custom source.

remote_url class-attribute instance-attribute

remote_url: str | None = None

The remote URL to download the aux model from.

local_filename class-attribute instance-attribute

local_filename: Path | None = None

The local filename to load the aux model from.

file_hash class-attribute instance-attribute

file_hash: str | None = None

The hash of the aux model file.

model_strength class-attribute instance-attribute

model_strength: float = 1

The strength of the aux model on the generation model. 1 is the default strength.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

verify_identifier_set

verify_identifier_set() -> AuxModelEntry

Ensure that at least one of name, version, or remote_version_id is provided.

Source code in horde_sdk/generation_parameters/image/object_models.py
@model_validator(mode="after")
def verify_identifier_set(self: AuxModelEntry) -> AuxModelEntry:
    """Ensure that at least one of name, version, or remote_version_id is provided."""
    if self.name is None and self.release_version is None and self.remote_version_id is None:
        raise ValueError("At least one of name, version, or remote_version_id must be provided.")

    return self

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

LoRaEntry

Bases: AuxModelEntry

Represents a single entry of a LoRa.

Source code in horde_sdk/generation_parameters/image/object_models.py
class LoRaEntry(AuxModelEntry):
    """Represents a single entry of a LoRa."""

    clip_strength: float = 1
    """The strength of the LoRa on the clip model. 1 is the default strength."""

    lora_triggers: list[str] | None = None
    """The triggers to use for the LoRa. Specify the behavior with `lora_inject_trigger_choice`."""

    lora_inject_trigger_choice: LORA_TRIGGER_INJECT_CHOICE = LORA_TRIGGER_INJECT_CHOICE.NO_INJECT
    """If true and if supported by the backend, inject a trigger term into the prompt."""

clip_strength class-attribute instance-attribute

clip_strength: float = 1

The strength of the LoRa on the clip model. 1 is the default strength.

lora_triggers class-attribute instance-attribute

lora_triggers: list[str] | None = None

The triggers to use for the LoRa. Specify the behavior with lora_inject_trigger_choice.

lora_inject_trigger_choice class-attribute instance-attribute

lora_inject_trigger_choice: LORA_TRIGGER_INJECT_CHOICE = (
    NO_INJECT
)

If true and if supported by the backend, inject a trigger term into the prompt.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

name instance-attribute

name: str | None

The name of the aux model. If this is a hosted aux model, the name to search for. See remote_version_id if targeting a specific version of a hosted aux model.

release_version class-attribute instance-attribute

release_version: str | None = None

The version of the aux model. This is v1, v2, etc. If this is a hosted aux model, you should instead use remote_version_id and reference the platform-specific file identifier.

remote_version_id instance-attribute

remote_version_id: str | None

If this aux model is sourced from a website/API, the version ID specific to that website/API to identify the specific version of the aux model. This is not v1, v2, but a numeric ID that the service assigns and is typically in the URL of the download link.

source instance-attribute

source: KNOWN_AUX_MODEL_SOURCE | str

The source of the aux model. This can be a known source or a custom source.

remote_url class-attribute instance-attribute

remote_url: str | None = None

The remote URL to download the aux model from.

local_filename class-attribute instance-attribute

local_filename: Path | None = None

The local filename to load the aux model from.

file_hash class-attribute instance-attribute

file_hash: str | None = None

The hash of the aux model file.

model_strength class-attribute instance-attribute

model_strength: float = 1

The strength of the aux model on the generation model. 1 is the default strength.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

verify_identifier_set

verify_identifier_set() -> AuxModelEntry

Ensure that at least one of name, version, or remote_version_id is provided.

Source code in horde_sdk/generation_parameters/image/object_models.py
@model_validator(mode="after")
def verify_identifier_set(self: AuxModelEntry) -> AuxModelEntry:
    """Ensure that at least one of name, version, or remote_version_id is provided."""
    if self.name is None and self.release_version is None and self.remote_version_id is None:
        raise ValueError("At least one of name, version, or remote_version_id must be provided.")

    return self

TIEntry

Bases: AuxModelEntry

Represents a single entry of a Textual Inversion.

Source code in horde_sdk/generation_parameters/image/object_models.py
class TIEntry(AuxModelEntry):
    """Represents a single entry of a Textual Inversion."""

    ti_inject_trigger_choice: TI_TRIGGER_INJECT_CHOICE = TI_TRIGGER_INJECT_CHOICE.NO_INJECT
    """If true and if supported by the backend, inject a trigger term into the prompt."""

ti_inject_trigger_choice class-attribute instance-attribute

ti_inject_trigger_choice: TI_TRIGGER_INJECT_CHOICE = (
    NO_INJECT
)

If true and if supported by the backend, inject a trigger term into the prompt.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

name instance-attribute

name: str | None

The name of the aux model. If this is a hosted aux model, the name to search for. See remote_version_id if targeting a specific version of a hosted aux model.

release_version class-attribute instance-attribute

release_version: str | None = None

The version of the aux model. This is v1, v2, etc. If this is a hosted aux model, you should instead use remote_version_id and reference the platform-specific file identifier.

remote_version_id instance-attribute

remote_version_id: str | None

If this aux model is sourced from a website/API, the version ID specific to that website/API to identify the specific version of the aux model. This is not v1, v2, but a numeric ID that the service assigns and is typically in the URL of the download link.

source instance-attribute

source: KNOWN_AUX_MODEL_SOURCE | str

The source of the aux model. This can be a known source or a custom source.

remote_url class-attribute instance-attribute

remote_url: str | None = None

The remote URL to download the aux model from.

local_filename class-attribute instance-attribute

local_filename: Path | None = None

The local filename to load the aux model from.

file_hash class-attribute instance-attribute

file_hash: str | None = None

The hash of the aux model file.

model_strength class-attribute instance-attribute

model_strength: float = 1

The strength of the aux model on the generation model. 1 is the default strength.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

verify_identifier_set

verify_identifier_set() -> AuxModelEntry

Ensure that at least one of name, version, or remote_version_id is provided.

Source code in horde_sdk/generation_parameters/image/object_models.py
@model_validator(mode="after")
def verify_identifier_set(self: AuxModelEntry) -> AuxModelEntry:
    """Ensure that at least one of name, version, or remote_version_id is provided."""
    if self.name is None and self.release_version is None and self.remote_version_id is None:
        raise ValueError("At least one of name, version, or remote_version_id must be provided.")

    return self

CustomWorkflowGenerationParameters

Bases: GenerationParameterBaseModel

Represents the parameters for a custom workflow generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class CustomWorkflowGenerationParameters(GenerationParameterBaseModel):
    """Represents the parameters for a custom workflow generation."""

    custom_workflow_name: KNOWN_IMAGE_WORKFLOWS | str
    """The name of the custom workflow to use for the generation."""
    custom_workflow_version: str | None = None
    """The version of the custom workflow to use for the generation. \
        If None, the latest version will be used. Defaults to None."""

    custom_parameters: dict[ID_TYPES, str] | None = None
    """The custom parameters to use for the generation. Defaults to None."""

custom_workflow_name instance-attribute

custom_workflow_name: KNOWN_IMAGE_WORKFLOWS | str

The name of the custom workflow to use for the generation.

custom_workflow_version class-attribute instance-attribute

custom_workflow_version: str | None = None

The version of the custom workflow to use for the generation. If None, the latest version will be used. Defaults to None.

custom_parameters class-attribute instance-attribute

custom_parameters: dict[ID_TYPES, str] | None = None

The custom parameters to use for the generation. Defaults to None.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

ImageGenerationComponentContainer

Bases: GenerationParameterBaseModel

Container for optional image generation components.

This container holds auxiliary components for image generation such as LoRa entries, Textual Inversion entries, ControlNet parameters, and more. It uses a simple list that naturally supports multiple instances of the same component type.

Source code in horde_sdk/generation_parameters/image/object_models.py
class ImageGenerationComponentContainer(GenerationParameterBaseModel):
    """Container for optional image generation components.

    This container holds auxiliary components for image generation such as LoRa entries,
    Textual Inversion entries, ControlNet parameters, and more. It uses a simple list
    that naturally supports multiple instances of the same component type.
    """

    model_config = ConfigDict(
        use_attribute_docstrings=True,
        from_attributes=True,
    )

    components: list[
        Image2ImageGenerationParameters
        | RemixGenerationParameters
        | ControlnetGenerationParameters
        | HiresFixGenerationParameters
        | LoRaEntry
        | TIEntry
        | CustomWorkflowGenerationParameters
    ] = Field(default_factory=list)
    """The list of generation components."""

    def add(
        self,
        component: (
            Image2ImageGenerationParameters
            | RemixGenerationParameters
            | ControlnetGenerationParameters
            | HiresFixGenerationParameters
            | LoRaEntry
            | TIEntry
            | CustomWorkflowGenerationParameters
        ),
    ) -> None:
        """Add a component to the container.

        Args:
            component: The component to add.
        """
        self.components.append(component)

    def add_all(
        self,
        components: list[
            Image2ImageGenerationParameters
            | RemixGenerationParameters
            | ControlnetGenerationParameters
            | HiresFixGenerationParameters
            | LoRaEntry
            | TIEntry
            | CustomWorkflowGenerationParameters
        ],
    ) -> None:
        """Add multiple components to the container.

        Args:
            components: The list of components to add.
        """
        self.components.extend(components)

    @property
    def image2image_params(self) -> Image2ImageGenerationParameters | None:
        """Get the image-to-image parameters if they exist."""
        for component in self.components:
            if isinstance(component, Image2ImageGenerationParameters):
                return component
        return None

    @property
    def remix_params(self) -> RemixGenerationParameters | None:
        """Get the remix parameters if they exist."""
        for component in self.components:
            if isinstance(component, RemixGenerationParameters):
                return component
        return None

    @property
    def controlnet_params(self) -> ControlnetGenerationParameters | None:
        """Get the controlnet parameters if they exist."""
        for component in self.components:
            if isinstance(component, ControlnetGenerationParameters):
                return component
        return None

    @property
    def hires_fix_params(self) -> HiresFixGenerationParameters | None:
        """Get the hires fix parameters if they exist."""
        for component in self.components:
            if isinstance(component, HiresFixGenerationParameters):
                return component
        return None

    @property
    def lora_entries(self) -> list[LoRaEntry]:
        """Get all LoRa entries."""
        return [c for c in self.components if isinstance(c, LoRaEntry)]

    @property
    def ti_entries(self) -> list[TIEntry]:
        """Get all Textual Inversion entries."""
        return [c for c in self.components if isinstance(c, TIEntry)]

    @property
    def custom_workflow_entries(self) -> list[CustomWorkflowGenerationParameters]:
        """Get all custom workflow entries."""
        return [c for c in self.components if isinstance(c, CustomWorkflowGenerationParameters)]

    @property
    def lora_params(self) -> list[LoRaEntry]:
        """Get all LoRa entries.

        Deprecated: Use lora_entries instead. This property returns a plain list instead of LoRaEntries wrapper.
        """
        return self.lora_entries

    @property
    def ti_params(self) -> list[TIEntry]:
        """Get all Textual Inversion entries.

        Deprecated: Use ti_entries instead. This property returns a plain list instead of TIEntries wrapper.
        """
        return self.ti_entries

    @property
    def custom_workflows_params(self) -> list[CustomWorkflowGenerationParameters]:
        """Get all custom workflow entries.

        Deprecated: Use custom_workflow_entries instead. This property returns a plain list instead of
        CustomWorkflows wrapper.
        """
        return self.custom_workflow_entries

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True, from_attributes=True
)

components class-attribute instance-attribute

components: list[
    Image2ImageGenerationParameters
    | RemixGenerationParameters
    | ControlnetGenerationParameters
    | HiresFixGenerationParameters
    | LoRaEntry
    | TIEntry
    | CustomWorkflowGenerationParameters
] = Field(default_factory=list)

The list of generation components.

image2image_params property

image2image_params: Image2ImageGenerationParameters | None

Get the image-to-image parameters if they exist.

remix_params property

remix_params: RemixGenerationParameters | None

Get the remix parameters if they exist.

controlnet_params property

controlnet_params: ControlnetGenerationParameters | None

Get the controlnet parameters if they exist.

hires_fix_params property

hires_fix_params: HiresFixGenerationParameters | None

Get the hires fix parameters if they exist.

lora_entries property

lora_entries: list[LoRaEntry]

Get all LoRa entries.

ti_entries property

ti_entries: list[TIEntry]

Get all Textual Inversion entries.

custom_workflow_entries property

custom_workflow_entries: list[
    CustomWorkflowGenerationParameters
]

Get all custom workflow entries.

lora_params property

lora_params: list[LoRaEntry]

Get all LoRa entries.

Deprecated: Use lora_entries instead. This property returns a plain list instead of LoRaEntries wrapper.

ti_params property

ti_params: list[TIEntry]

Get all Textual Inversion entries.

Deprecated: Use ti_entries instead. This property returns a plain list instead of TIEntries wrapper.

custom_workflows_params property

custom_workflows_params: list[
    CustomWorkflowGenerationParameters
]

Get all custom workflow entries.

Deprecated: Use custom_workflow_entries instead. This property returns a plain list instead of CustomWorkflows wrapper.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

  • If associated with a auxiliary process that is model based, such as a LoRa, this should be set to MODEL.
  • If instead a service is used to produce results, this should be set to MODEL_FROM_SERVICE.
  • If there is no generative model involved, and instead a "traditional" algorithm is used, this should be set to NON_MODEL_ALGORITHM.

Otherwise, if this component is simply a set of parameters that, in itself, does not produce results, this should be set to None.

add

add(
    component: (
        Image2ImageGenerationParameters
        | RemixGenerationParameters
        | ControlnetGenerationParameters
        | HiresFixGenerationParameters
        | LoRaEntry
        | TIEntry
        | CustomWorkflowGenerationParameters
    ),
) -> None

Add a component to the container.

Parameters:

Source code in horde_sdk/generation_parameters/image/object_models.py
def add(
    self,
    component: (
        Image2ImageGenerationParameters
        | RemixGenerationParameters
        | ControlnetGenerationParameters
        | HiresFixGenerationParameters
        | LoRaEntry
        | TIEntry
        | CustomWorkflowGenerationParameters
    ),
) -> None:
    """Add a component to the container.

    Args:
        component: The component to add.
    """
    self.components.append(component)

add_all

add_all(
    components: list[
        Image2ImageGenerationParameters
        | RemixGenerationParameters
        | ControlnetGenerationParameters
        | HiresFixGenerationParameters
        | LoRaEntry
        | TIEntry
        | CustomWorkflowGenerationParameters
    ],
) -> None

Add multiple components to the container.

Parameters:

Source code in horde_sdk/generation_parameters/image/object_models.py
def add_all(
    self,
    components: list[
        Image2ImageGenerationParameters
        | RemixGenerationParameters
        | ControlnetGenerationParameters
        | HiresFixGenerationParameters
        | LoRaEntry
        | TIEntry
        | CustomWorkflowGenerationParameters
    ],
) -> None:
    """Add multiple components to the container.

    Args:
        components: The list of components to add.
    """
    self.components.extend(components)

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

ImageGenerationParametersTemplate

Bases: CompositeParametersBase

Represents the parameters for an image generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class ImageGenerationParametersTemplate(CompositeParametersBase):
    """Represents the parameters for an image generation."""

    batch_size: int | None = Field(default=None, ge=1)
    """The number of images to generated batched (simultaneously). This is the `n_iter` parameter in ComfyUI"""

    source_processing: KNOWN_IMAGE_SOURCE_PROCESSING | str | None = None
    """txt2img, img2img, etc. See `KNOWN_IMAGE_SOURCE_PROCESSING` for more information."""

    base_params: BasicImageGenerationParametersTemplate | None = None
    """The base parameters for the generation."""

    additional_params: ImageGenerationComponentContainer | None = None
    """Additional parameters for the generation. This can include parameters for img2img, remix, controlnet, hires fix,
    and custom workflows."""

    alchemy_params: AlchemyParameters | None = None
    """If alchemy is also requested, the parameters specific to those operations."""

    @model_validator(mode="after")
    def verify_source_processing(self: ImageGenerationParametersTemplate) -> ImageGenerationParametersTemplate:
        """Ensure that the appropriate parameters are set based on the source processing type."""
        if self.source_processing in [
            KNOWN_IMAGE_SOURCE_PROCESSING.img2img,
            KNOWN_IMAGE_SOURCE_PROCESSING.inpainting,
            KNOWN_IMAGE_SOURCE_PROCESSING.outpainting,
        ]:
            if self.additional_params is None:
                raise ValueError("additional_params must be provided for img2img or inpainting source processing.")

            if self.additional_params.image2image_params is None:
                raise ValueError("img2img_params must be provided for img2img source processing.")
        elif self.source_processing == KNOWN_IMAGE_SOURCE_PROCESSING.remix:
            if self.additional_params is None:
                raise ValueError("additional_params must be provided for remix source processing.")

            if self.additional_params.remix_params is None:
                raise ValueError("remix_params must be provided for remix source processing.")

        return self

    @override
    def get_number_expected_results(self: ImageGenerationParametersTemplate) -> int:
        """Return the number of expected results for this parameter set.

        Returns:
            int: The number of expected results.
        """
        return self.batch_size if self.batch_size is not None else 1

    def to_parameters(
        self,
        *,
        base_param_updates: BasicImageGenerationParametersTemplate | None = None,
        additional_param_updates: ImageGenerationComponentContainer | None = None,
        result_ids: Sequence[ID_TYPES] | None = None,
        allocator: ResultIdAllocator | None = None,
        seed: str = "image",
    ) -> ImageGenerationParameters:
        """Convert this template into concrete image generation parameters."""
        base_params = self.base_params
        if base_params is None:
            raise ValueError("Image generation templates must define base_params before conversion.")

        overrides: dict[str, object] | None = None
        if base_param_updates:
            overrides = {
                "base_params": base_params.model_copy(update=base_param_updates.model_dump(exclude_none=True)),
            }

        if additional_param_updates:
            if overrides is None:
                overrides = {}
            if not self.additional_params:
                raise ValueError("additional_params must be defined before applying updates.")
            overrides["additional_params"] = self.additional_params.model_copy(update=dict(additional_param_updates))

        finalization = finalize_template_for_parameters(
            self,
            overrides=overrides,
            exclude_none=False,
            fingerprint_exclude_fields=("result_ids",),
        )

        finalized_template = finalization.template
        resolved_base_params = finalized_template.base_params
        if resolved_base_params is None:
            raise ValueError("Image generation templates must define base_params before conversion.")

        batch_size = finalized_template.batch_size or 1

        resolved_result_ids = resolve_result_ids_from_payload(
            explicit_ids=result_ids,
            payload_value=finalization.payload.get("result_ids"),
            count=batch_size,
            allocator=allocator,
            seed=seed,
            fingerprint=finalization.fingerprint,
        )

        concrete_base_params = BasicImageGenerationParameters.model_validate(
            resolved_base_params,
            from_attributes=True,
        )

        resolved_additional_params = (
            finalized_template.additional_params
            if finalized_template.additional_params is not None
            else ImageGenerationComponentContainer()
        )

        parameter_payload = finalized_template.model_copy(
            update={
                "base_params": concrete_base_params,
                "result_ids": resolved_result_ids,
                "additional_params": resolved_additional_params,
                "batch_size": batch_size,
            },
        )

        return ImageGenerationParameters.model_validate(
            parameter_payload,
            from_attributes=True,
        )

batch_size class-attribute instance-attribute

batch_size: int | None = Field(default=None, ge=1)

The number of images to generated batched (simultaneously). This is the n_iter parameter in ComfyUI

source_processing class-attribute instance-attribute

source_processing: (
    KNOWN_IMAGE_SOURCE_PROCESSING | str | None
) = None

txt2img, img2img, etc. See KNOWN_IMAGE_SOURCE_PROCESSING for more information.

base_params class-attribute instance-attribute

base_params: (
    BasicImageGenerationParametersTemplate | None
) = None

The base parameters for the generation.

additional_params class-attribute instance-attribute

additional_params: (
    ImageGenerationComponentContainer | None
) = None

Additional parameters for the generation. This can include parameters for img2img, remix, controlnet, hires fix, and custom workflows.

alchemy_params class-attribute instance-attribute

alchemy_params: AlchemyParameters | None = None

If alchemy is also requested, the parameters specific to those operations.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

verify_source_processing

verify_source_processing() -> (
    ImageGenerationParametersTemplate
)

Ensure that the appropriate parameters are set based on the source processing type.

Source code in horde_sdk/generation_parameters/image/object_models.py
@model_validator(mode="after")
def verify_source_processing(self: ImageGenerationParametersTemplate) -> ImageGenerationParametersTemplate:
    """Ensure that the appropriate parameters are set based on the source processing type."""
    if self.source_processing in [
        KNOWN_IMAGE_SOURCE_PROCESSING.img2img,
        KNOWN_IMAGE_SOURCE_PROCESSING.inpainting,
        KNOWN_IMAGE_SOURCE_PROCESSING.outpainting,
    ]:
        if self.additional_params is None:
            raise ValueError("additional_params must be provided for img2img or inpainting source processing.")

        if self.additional_params.image2image_params is None:
            raise ValueError("img2img_params must be provided for img2img source processing.")
    elif self.source_processing == KNOWN_IMAGE_SOURCE_PROCESSING.remix:
        if self.additional_params is None:
            raise ValueError("additional_params must be provided for remix source processing.")

        if self.additional_params.remix_params is None:
            raise ValueError("remix_params must be provided for remix source processing.")

    return self

get_number_expected_results

get_number_expected_results() -> int

Return the number of expected results for this parameter set.

Returns:

  • int ( int ) –

    The number of expected results.

Source code in horde_sdk/generation_parameters/image/object_models.py
@override
def get_number_expected_results(self: ImageGenerationParametersTemplate) -> int:
    """Return the number of expected results for this parameter set.

    Returns:
        int: The number of expected results.
    """
    return self.batch_size if self.batch_size is not None else 1

to_parameters

to_parameters(
    *,
    base_param_updates: (
        BasicImageGenerationParametersTemplate | None
    ) = None,
    additional_param_updates: (
        ImageGenerationComponentContainer | None
    ) = None,
    result_ids: Sequence[ID_TYPES] | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "image"
) -> ImageGenerationParameters

Convert this template into concrete image generation parameters.

Source code in horde_sdk/generation_parameters/image/object_models.py
def to_parameters(
    self,
    *,
    base_param_updates: BasicImageGenerationParametersTemplate | None = None,
    additional_param_updates: ImageGenerationComponentContainer | None = None,
    result_ids: Sequence[ID_TYPES] | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "image",
) -> ImageGenerationParameters:
    """Convert this template into concrete image generation parameters."""
    base_params = self.base_params
    if base_params is None:
        raise ValueError("Image generation templates must define base_params before conversion.")

    overrides: dict[str, object] | None = None
    if base_param_updates:
        overrides = {
            "base_params": base_params.model_copy(update=base_param_updates.model_dump(exclude_none=True)),
        }

    if additional_param_updates:
        if overrides is None:
            overrides = {}
        if not self.additional_params:
            raise ValueError("additional_params must be defined before applying updates.")
        overrides["additional_params"] = self.additional_params.model_copy(update=dict(additional_param_updates))

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=("result_ids",),
    )

    finalized_template = finalization.template
    resolved_base_params = finalized_template.base_params
    if resolved_base_params is None:
        raise ValueError("Image generation templates must define base_params before conversion.")

    batch_size = finalized_template.batch_size or 1

    resolved_result_ids = resolve_result_ids_from_payload(
        explicit_ids=result_ids,
        payload_value=finalization.payload.get("result_ids"),
        count=batch_size,
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    concrete_base_params = BasicImageGenerationParameters.model_validate(
        resolved_base_params,
        from_attributes=True,
    )

    resolved_additional_params = (
        finalized_template.additional_params
        if finalized_template.additional_params is not None
        else ImageGenerationComponentContainer()
    )

    parameter_payload = finalized_template.model_copy(
        update={
            "base_params": concrete_base_params,
            "result_ids": resolved_result_ids,
            "additional_params": resolved_additional_params,
            "batch_size": batch_size,
        },
    )

    return ImageGenerationParameters.model_validate(
        parameter_payload,
        from_attributes=True,
    )

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

ImageGenerationParameters

Bases: ImageGenerationParametersTemplate

Represents the common bare-minimum parameters for an image generation.

Source code in horde_sdk/generation_parameters/image/object_models.py
class ImageGenerationParameters(ImageGenerationParametersTemplate):
    """Represents the common bare-minimum parameters for an image generation."""

    result_ids: list[ID_TYPES]
    """The IDs to assign to the resulting images."""

    base_params: BasicImageGenerationParameters
    """The base parameters for the generation."""

    additional_params: ImageGenerationComponentContainer = Field(default_factory=ImageGenerationComponentContainer)
    """Additional parameters for the generation. This can include parameters for img2img, remix, controlnet, hires fix,
    and custom workflows."""

    batch_size: int | None = Field(default=1, ge=1)
    """The number of images to generated batched (simultaneously, not concurrently).
    This is the `n_iter` parameter in ComfyUI"""

    @model_validator(mode="after")
    def verify_id_count(self: ImageGenerationParameters) -> ImageGenerationParameters:
        """Ensure that at least one generation ID is provided."""
        if not self.result_ids:
            raise ValueError("At least one generation ID must be provided.")

        if len(self.result_ids) != self.batch_size:
            raise ValueError("The number of generation IDs must match the batch size.")

        return self

result_ids instance-attribute

result_ids: list[ID_TYPES]

The IDs to assign to the resulting images.

base_params instance-attribute

base_params: BasicImageGenerationParameters

The base parameters for the generation.

additional_params class-attribute instance-attribute

additional_params: ImageGenerationComponentContainer = (
    Field(default_factory=ImageGenerationComponentContainer)
)

Additional parameters for the generation. This can include parameters for img2img, remix, controlnet, hires fix, and custom workflows.

batch_size class-attribute instance-attribute

batch_size: int | None = Field(default=1, ge=1)

The number of images to generated batched (simultaneously, not concurrently). This is the n_iter parameter in ComfyUI

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

source_processing class-attribute instance-attribute

source_processing: (
    KNOWN_IMAGE_SOURCE_PROCESSING | str | None
) = None

txt2img, img2img, etc. See KNOWN_IMAGE_SOURCE_PROCESSING for more information.

alchemy_params class-attribute instance-attribute

alchemy_params: AlchemyParameters | None = None

If alchemy is also requested, the parameters specific to those operations.

verify_id_count

verify_id_count() -> ImageGenerationParameters

Ensure that at least one generation ID is provided.

Source code in horde_sdk/generation_parameters/image/object_models.py
@model_validator(mode="after")
def verify_id_count(self: ImageGenerationParameters) -> ImageGenerationParameters:
    """Ensure that at least one generation ID is provided."""
    if not self.result_ids:
        raise ValueError("At least one generation ID must be provided.")

    if len(self.result_ids) != self.batch_size:
        raise ValueError("The number of generation IDs must match the batch size.")

    return self

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Return the number of expected results for this parameter set.

Returns:

  • int ( int ) –

    The number of expected results.

Source code in horde_sdk/generation_parameters/image/object_models.py
@override
def get_number_expected_results(self: ImageGenerationParametersTemplate) -> int:
    """Return the number of expected results for this parameter set.

    Returns:
        int: The number of expected results.
    """
    return self.batch_size if self.batch_size is not None else 1

verify_source_processing

verify_source_processing() -> (
    ImageGenerationParametersTemplate
)

Ensure that the appropriate parameters are set based on the source processing type.

Source code in horde_sdk/generation_parameters/image/object_models.py
@model_validator(mode="after")
def verify_source_processing(self: ImageGenerationParametersTemplate) -> ImageGenerationParametersTemplate:
    """Ensure that the appropriate parameters are set based on the source processing type."""
    if self.source_processing in [
        KNOWN_IMAGE_SOURCE_PROCESSING.img2img,
        KNOWN_IMAGE_SOURCE_PROCESSING.inpainting,
        KNOWN_IMAGE_SOURCE_PROCESSING.outpainting,
    ]:
        if self.additional_params is None:
            raise ValueError("additional_params must be provided for img2img or inpainting source processing.")

        if self.additional_params.image2image_params is None:
            raise ValueError("img2img_params must be provided for img2img source processing.")
    elif self.source_processing == KNOWN_IMAGE_SOURCE_PROCESSING.remix:
        if self.additional_params is None:
            raise ValueError("additional_params must be provided for remix source processing.")

        if self.additional_params.remix_params is None:
            raise ValueError("remix_params must be provided for remix source processing.")

    return self

to_parameters

to_parameters(
    *,
    base_param_updates: (
        BasicImageGenerationParametersTemplate | None
    ) = None,
    additional_param_updates: (
        ImageGenerationComponentContainer | None
    ) = None,
    result_ids: Sequence[ID_TYPES] | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "image"
) -> ImageGenerationParameters

Convert this template into concrete image generation parameters.

Source code in horde_sdk/generation_parameters/image/object_models.py
def to_parameters(
    self,
    *,
    base_param_updates: BasicImageGenerationParametersTemplate | None = None,
    additional_param_updates: ImageGenerationComponentContainer | None = None,
    result_ids: Sequence[ID_TYPES] | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "image",
) -> ImageGenerationParameters:
    """Convert this template into concrete image generation parameters."""
    base_params = self.base_params
    if base_params is None:
        raise ValueError("Image generation templates must define base_params before conversion.")

    overrides: dict[str, object] | None = None
    if base_param_updates:
        overrides = {
            "base_params": base_params.model_copy(update=base_param_updates.model_dump(exclude_none=True)),
        }

    if additional_param_updates:
        if overrides is None:
            overrides = {}
        if not self.additional_params:
            raise ValueError("additional_params must be defined before applying updates.")
        overrides["additional_params"] = self.additional_params.model_copy(update=dict(additional_param_updates))

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=("result_ids",),
    )

    finalized_template = finalization.template
    resolved_base_params = finalized_template.base_params
    if resolved_base_params is None:
        raise ValueError("Image generation templates must define base_params before conversion.")

    batch_size = finalized_template.batch_size or 1

    resolved_result_ids = resolve_result_ids_from_payload(
        explicit_ids=result_ids,
        payload_value=finalization.payload.get("result_ids"),
        count=batch_size,
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    concrete_base_params = BasicImageGenerationParameters.model_validate(
        resolved_base_params,
        from_attributes=True,
    )

    resolved_additional_params = (
        finalized_template.additional_params
        if finalized_template.additional_params is not None
        else ImageGenerationComponentContainer()
    )

    parameter_payload = finalized_template.model_copy(
        update={
            "base_params": concrete_base_params,
            "result_ids": resolved_result_ids,
            "additional_params": resolved_additional_params,
            "batch_size": batch_size,
        },
    )

    return ImageGenerationParameters.model_validate(
        parameter_payload,
        from_attributes=True,
    )

image_parameters_to_feature_flags

image_parameters_to_feature_flags(
    parameters: ImageGenerationParametersTemplate,
) -> ImageGenerationFeatureFlags

Create a feature flag object representing the features used in the parameters.

Source code in horde_sdk/generation_parameters/image/object_models.py
def image_parameters_to_feature_flags(
    parameters: ImageGenerationParametersTemplate,
) -> ImageGenerationFeatureFlags:
    """Create a feature flag object representing the features used in the parameters."""
    all_alchemy_forms = None
    if parameters.alchemy_params is not None and parameters.alchemy_params._all_alchemy_operations is not None:
        all_alchemy_forms = [x.form for x in parameters.alchemy_params._all_alchemy_operations if x.form is not None]

    baselines: list[KNOWN_IMAGE_GENERATION_BASELINE | str]
    if parameters.base_params and parameters.base_params.model_baseline is not None:
        baselines = [parameters.base_params.model_baseline]
    else:
        baselines = [KNOWN_IMAGE_GENERATION_BASELINE.infer]

    schedulers = []
    samplers = []

    if parameters.base_params is not None:
        if parameters.base_params.scheduler is not None:
            schedulers.append(parameters.base_params.scheduler)
        if parameters.base_params.sampler_name is not None:
            samplers.append(parameters.base_params.sampler_name)

    source_processing = [parameters.source_processing] if parameters.source_processing is not None else []

    post_processing = all_alchemy_forms

    tiling = bool(parameters.base_params and parameters.base_params.tiling)

    hires_fix = False
    controlnets_feature_flags = None
    workflows: list[str] | None = None
    tis: list[KNOWN_AUX_MODEL_SOURCE | str] | None = None
    loras: list[KNOWN_AUX_MODEL_SOURCE | str] | None = None

    if parameters.additional_params:
        hires_fix = parameters.additional_params.hires_fix_params is not None

        controlnets_feature_flags = (
            ControlnetFeatureFlags(
                controlnets=[parameters.additional_params.controlnet_params.controlnet_type],
                image_is_control=parameters.additional_params.controlnet_params.source_image is not None,
                return_control_map=parameters.additional_params.controlnet_params.return_control_map,
            )
            if parameters.additional_params.controlnet_params is not None
            else None
        )

        if parameters.additional_params.custom_workflows_params:
            workflow_names = [wf.custom_workflow_name for wf in parameters.additional_params.custom_workflows_params]
            workflows = workflow_names or None

        if parameters.additional_params.ti_params:
            ti_names = [ti.name for ti in parameters.additional_params.ti_params if ti.name is not None]
            tis = ti_names or None

        if parameters.additional_params.lora_params:
            lora_names = [lora.name for lora in parameters.additional_params.lora_params if lora.name is not None]
            loras = lora_names or None

    return ImageGenerationFeatureFlags(
        baselines=baselines,
        hires_fix=hires_fix,
        tiling=tiling,
        schedulers=schedulers,
        samplers=samplers,
        controlnets_feature_flags=controlnets_feature_flags,
        post_processing=post_processing,
        source_processing=source_processing,
        workflows=workflows,
        tis=tis,
        loras=loras,
    )