Skip to content

horde_sdk.ai_horde_api.apimodels.base

The base classes for all AI Horde API requests/responses.

__all__ module-attribute

__all__ = [
    "ActiveModel",
    "ActiveModelLite",
    "BaseAIHordeRequest",
    "ExtraSourceImageEntry",
    "ExtraTextEntry",
    "GenMetadataEntry",
    "ImageGenerateParamMixin",
    "JobRequestMixin",
    "JobResponseMixin",
    "JobSubmitResponse",
    "LorasPayloadEntry",
    "MessageSpecifiesSharedKeyMixin",
    "SingleWarningEntry",
    "TIPayloadEntry",
    "WorkerRequestMixin",
    "WorkerRequestNameMixin",
    "_BaseImageGenerateParamMixin",
]

BaseAIHordeRequest

Bases: HordeRequest

Base class for all AI Horde API requests.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class BaseAIHordeRequest(HordeRequest):
    """Base class for all AI Horde API requests."""

    @override
    @classmethod
    def get_api_url(cls) -> str:
        return AI_HORDE_BASE_URL

get_api_url classmethod

get_api_url() -> str
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_url(cls) -> str:
    return AI_HORDE_BASE_URL

JobRequestMixin

Bases: HordeAPIData

Mix-in class for data relating to any generation jobs.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class JobRequestMixin(HordeAPIData):
    """Mix-in class for data relating to any generation jobs."""

    id_: GenerationID = Field(alias="id")
    """The UUID for this job. Use this to post the results in the future."""

    @field_validator("id_", mode="before")
    def validate_id(cls, v: str | GenerationID) -> GenerationID | str:
        """Ensure that the job ID is not empty."""
        if isinstance(v, str) and v == "":
            logger.warning("Job ID is empty")
            return GenerationID(root=uuid.uuid4())

        return v

    def __eq__(self, __value: object) -> bool:
        if isinstance(__value, JobRequestMixin):
            return self.id_ == __value.id_
        return False

    def __hash__(self) -> int:
        return hash(JobRequestMixin.__name__) + hash(self.id_)

id_ class-attribute instance-attribute

id_: GenerationID = Field(alias='id')

The UUID for this job. Use this to post the results in the future.

validate_id

validate_id(v: str | GenerationID) -> GenerationID | str

Ensure that the job ID is not empty.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("id_", mode="before")
def validate_id(cls, v: str | GenerationID) -> GenerationID | str:
    """Ensure that the job ID is not empty."""
    if isinstance(v, str) and v == "":
        logger.warning("Job ID is empty")
        return GenerationID(root=uuid.uuid4())

    return v

__eq__

__eq__(__value: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/base.py
def __eq__(self, __value: object) -> bool:
    if isinstance(__value, JobRequestMixin):
        return self.id_ == __value.id_
    return False

__hash__

__hash__() -> int
Source code in horde_sdk/ai_horde_api/apimodels/base.py
def __hash__(self) -> int:
    return hash(JobRequestMixin.__name__) + hash(self.id_)

JobResponseMixin

Bases: HordeAPIData

Mix-in class for data relating to any generation jobs.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class JobResponseMixin(HordeAPIData):
    """Mix-in class for data relating to any generation jobs."""

    id_: GenerationID = Field(alias="id")
    """The UUID for this job."""

    @field_validator("id_", mode="before")
    def validate_id(cls, v: str | GenerationID) -> GenerationID | str:
        """Ensure that the job ID is not empty."""
        if isinstance(v, str) and v == "":
            logger.warning("Job ID is empty")
            return GenerationID(root=uuid.uuid4())

        return v

id_ class-attribute instance-attribute

id_: GenerationID = Field(alias='id')

The UUID for this job.

validate_id

validate_id(v: str | GenerationID) -> GenerationID | str

Ensure that the job ID is not empty.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("id_", mode="before")
def validate_id(cls, v: str | GenerationID) -> GenerationID | str:
    """Ensure that the job ID is not empty."""
    if isinstance(v, str) and v == "":
        logger.warning("Job ID is empty")
        return GenerationID(root=uuid.uuid4())

    return v

WorkerRequestMixin

Bases: HordeAPIData

Mix-in class for data relating to worker requests.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class WorkerRequestMixin(HordeAPIData):
    """Mix-in class for data relating to worker requests."""

    worker_id: str | WorkerID
    """The UUID of the worker in question for this request."""

worker_id instance-attribute

worker_id: str | WorkerID

The UUID of the worker in question for this request.

WorkerRequestNameMixin

Bases: HordeAPIData

Mix-in class for data relating to worker requests.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class WorkerRequestNameMixin(HordeAPIData):
    """Mix-in class for data relating to worker requests."""

    worker_name: str
    """The name of the worker in question for this request."""

worker_name instance-attribute

worker_name: str

The name of the worker in question for this request.

LorasPayloadEntry

Bases: HordeAPIObjectBaseModel

Represents a single lora parameter.

v2 API Model: ModelPayloadLorasStable

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class LorasPayloadEntry(HordeAPIObjectBaseModel):
    """Represents a single lora parameter.

    v2 API Model: `ModelPayloadLorasStable`
    """

    name: str = Field(min_length=1, max_length=255)
    """The name of the LoRa model to use."""
    model: float = Field(default=1, ge=-5, le=5)
    """The strength of the LoRa against the stable diffusion model."""
    clip: float = Field(default=1, ge=-5, le=5)
    """The strength of the LoRa against the clip model."""
    inject_trigger: str | None = Field(default=None, min_length=1, max_length=30)
    """Any trigger required to activate the LoRa model."""
    is_version: bool = Field(default=False)
    """If true, will treat the lora name as a version ID."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "ModelPayloadLorasStable"

name class-attribute instance-attribute

name: str = Field(min_length=1, max_length=255)

The name of the LoRa model to use.

model class-attribute instance-attribute

model: float = Field(default=1, ge=-5, le=5)

The strength of the LoRa against the stable diffusion model.

clip class-attribute instance-attribute

clip: float = Field(default=1, ge=-5, le=5)

The strength of the LoRa against the clip model.

inject_trigger class-attribute instance-attribute

inject_trigger: str | None = Field(
    default=None, min_length=1, max_length=30
)

Any trigger required to activate the LoRa model.

is_version class-attribute instance-attribute

is_version: bool = Field(default=False)

If true, will treat the lora name as a version ID.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "ModelPayloadLorasStable"

TIPayloadEntry

Bases: HordeAPIObjectBaseModel

Represents a single textual inversion (embedding) parameter.

v2 API Model: ModelPayloadTextualInversionsStable

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class TIPayloadEntry(HordeAPIObjectBaseModel):
    """Represents a single textual inversion (embedding) parameter.

    v2 API Model: `ModelPayloadTextualInversionsStable`
    """

    name: str = Field(min_length=1, max_length=255)
    """The name or ID of the textual inversion model to use."""
    inject_ti: str | None = None
    """Whether to automatically insert the TI into the prompt or negprompt."""
    strength: float = Field(default=1, ge=-5, le=5)
    """The strength to apply the textual inversion model."""

    @field_validator("inject_ti")
    def validate_inject_ti(cls, v: str | None) -> str | None:
        """Ensure that the inject_ti is either 'prompt' or 'negprompt'."""
        if v is None:
            return None
        if v not in ["prompt", "negprompt"]:
            raise ValueError("inject_ti must be either 'prompt' or 'negprompt'")
        return v

    @field_validator("strength")
    def validate_strength(cls, v: float) -> float:
        """Ensure that the strength is non-zero."""
        if v == 0:
            logger.debug("strength should be non-zero")

        return v

    @model_validator(mode="after")
    def strength_only_if_inject_ti(self) -> TIPayloadEntry:
        """Ensure that the strength is only set if the inject_ti is set."""
        if self.strength and self.inject_ti is None:
            logger.debug("strength is only valid when inject_ti is set")
        return self

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "ModelPayloadTextualInversionsStable"

name class-attribute instance-attribute

name: str = Field(min_length=1, max_length=255)

The name or ID of the textual inversion model to use.

inject_ti class-attribute instance-attribute

inject_ti: str | None = None

Whether to automatically insert the TI into the prompt or negprompt.

strength class-attribute instance-attribute

strength: float = Field(default=1, ge=-5, le=5)

The strength to apply the textual inversion model.

validate_inject_ti

validate_inject_ti(v: str | None) -> str | None

Ensure that the inject_ti is either 'prompt' or 'negprompt'.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("inject_ti")
def validate_inject_ti(cls, v: str | None) -> str | None:
    """Ensure that the inject_ti is either 'prompt' or 'negprompt'."""
    if v is None:
        return None
    if v not in ["prompt", "negprompt"]:
        raise ValueError("inject_ti must be either 'prompt' or 'negprompt'")
    return v

validate_strength

validate_strength(v: float) -> float

Ensure that the strength is non-zero.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("strength")
def validate_strength(cls, v: float) -> float:
    """Ensure that the strength is non-zero."""
    if v == 0:
        logger.debug("strength should be non-zero")

    return v

strength_only_if_inject_ti

strength_only_if_inject_ti() -> TIPayloadEntry

Ensure that the strength is only set if the inject_ti is set.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@model_validator(mode="after")
def strength_only_if_inject_ti(self) -> TIPayloadEntry:
    """Ensure that the strength is only set if the inject_ti is set."""
    if self.strength and self.inject_ti is None:
        logger.debug("strength is only valid when inject_ti is set")
    return self

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "ModelPayloadTextualInversionsStable"

ExtraSourceImageEntry

Bases: HordeAPIObjectBaseModel

Represents a single extra source image.

v2 API Model: ExtraSourceImage

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class ExtraSourceImageEntry(HordeAPIObjectBaseModel):
    """Represents a single extra source image.

    v2 API Model: `ExtraSourceImage`
    """

    original_url: str | None = None
    """The URL of the original image after it was downloaded."""

    image: str = Field(min_length=1)
    """The URL of the image to download, or the base64 string once downloaded."""
    strength: float = Field(default=1, ge=-5, le=5)
    """The strength to apply to this image on various operations."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "ExtraSourceImage"

original_url class-attribute instance-attribute

original_url: str | None = None

The URL of the original image after it was downloaded.

image class-attribute instance-attribute

image: str = Field(min_length=1)

The URL of the image to download, or the base64 string once downloaded.

strength class-attribute instance-attribute

strength: float = Field(default=1, ge=-5, le=5)

The strength to apply to this image on various operations.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "ExtraSourceImage"

ExtraTextEntry

Bases: HordeAPIObjectBaseModel

Represents a single extra text.

v2 API Model: ExtraText

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class ExtraTextEntry(HordeAPIObjectBaseModel):
    """Represents a single extra text.

    v2 API Model: `ExtraText`
    """

    text: str = Field(min_length=1)
    """Extra text required for this generation."""
    reference: str = Field(min_length=3)
    """Reference pointing to how this text is to be used."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "ExtraText"

text class-attribute instance-attribute

text: str = Field(min_length=1)

Extra text required for this generation.

reference class-attribute instance-attribute

reference: str = Field(min_length=3)

Reference pointing to how this text is to be used.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "ExtraText"

SingleWarningEntry

Bases: HordeAPIObjectBaseModel

Represents a single warning.

v2 API Model: RequestSingleWarning

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class SingleWarningEntry(HordeAPIObjectBaseModel):
    """Represents a single warning.

    v2 API Model: `RequestSingleWarning`
    """

    code: WarningCode | str = Field(min_length=1)
    """The code uniquely identifying this warning."""
    message: str = Field(min_length=1)
    """The human-readable description of this warning"""

    @field_validator("code")
    def code_must_be_known(cls, v: str | WarningCode) -> str | WarningCode:
        """Ensure that the warning code is in this list of supported warning codes."""
        if isinstance(v, WarningCode):
            return v
        if v not in WarningCode.__members__ or v not in WarningCode.__members__.values():
            logger.warning(f"Unknown warning code {v}. Is your SDK out of date or did the API change?")

        return v

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "RequestSingleWarning"

code class-attribute instance-attribute

code: WarningCode | str = Field(min_length=1)

The code uniquely identifying this warning.

message class-attribute instance-attribute

message: str = Field(min_length=1)

The human-readable description of this warning

code_must_be_known

code_must_be_known(
    v: str | WarningCode,
) -> str | WarningCode

Ensure that the warning code is in this list of supported warning codes.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("code")
def code_must_be_known(cls, v: str | WarningCode) -> str | WarningCode:
    """Ensure that the warning code is in this list of supported warning codes."""
    if isinstance(v, WarningCode):
        return v
    if v not in WarningCode.__members__ or v not in WarningCode.__members__.values():
        logger.warning(f"Unknown warning code {v}. Is your SDK out of date or did the API change?")

    return v

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "RequestSingleWarning"

ImageGenerateParamMixin

Bases: _BaseImageGenerateParamMixin

Contains basic and api-specific parameters for image generation.

v2 API Model: ModelPayloadRootStable

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class ImageGenerateParamMixin(_BaseImageGenerateParamMixin):
    """Contains basic and api-specific parameters for image generation.

    v2 API Model: `ModelPayloadRootStable`
    """

    model_config = (
        ConfigDict(frozen=True, extra="allow")
        if not os.getenv("TESTS_ONGOING")
        else ConfigDict(frozen=True, extra="forbid")
    )

    seed: str | None = None
    """The seed to use for this generation. If not provided, a random seed will be used."""
    seed_variation: int | None = Field(default=None, ge=1, le=1000)
    """Deprecated."""

    control_type: str | KNOWN_IMAGE_CONTROLNETS | None = None
    """The type of control net type to use."""
    image_is_control: bool | None = None
    """Set to True if the image is a control image."""
    return_control_map: bool | None = None
    """Set to True if you want the ControlNet map returned instead of a generated image."""

    extra_texts: list[ExtraTextEntry] | None = None
    """A list of extra texts and prompts to use in the comfyUI workflow."""
    use_nsfw_censor: bool = False
    """If the request is SFW, and the worker accidentally generates NSFW, it will send back a censored image."""

    # @model_validator(mode="after")
    # def validate_hires_fix(self) -> ImageGenerateParamMixin:
    #     if self.hires_fix and (self.width < 512 or self.height < 512):
    #         raise ValueError("hires_fix is only valid when width and height are both >= 512")
    #     return self

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "ModelPayloadRootStable"

    @field_validator("seed")
    def random_seed_if_none(cls, v: str | None) -> str | None:
        """If the seed is None, generate a random seed."""
        if v is None:
            random_seed = str(random.randint(1, 1000000000))
            logger.debug(f"Using random seed ({random_seed})")
            return random_seed

        return v

    @field_validator("control_type")
    def control_type_must_be_known(
        cls,
        v: str | KNOWN_IMAGE_CONTROLNETS | None,
    ) -> str | KNOWN_IMAGE_CONTROLNETS | None:
        """Ensure that the control type is in this list of supported control types."""
        if v is None:
            return None
        if isinstance(v, KNOWN_IMAGE_CONTROLNETS):
            return v

        try:
            KNOWN_IMAGE_CONTROLNETS(v)
        except ValueError:
            logger.warning(f"Unknown control type {v}. Is your SDK out of date or did the API change?")

        return v

model_config class-attribute instance-attribute

model_config = (
    ConfigDict(frozen=True, extra="allow")
    if not os.getenv("TESTS_ONGOING")
    else ConfigDict(frozen=True, extra="forbid")
)

seed class-attribute instance-attribute

seed: str | None = None

The seed to use for this generation. If not provided, a random seed will be used.

seed_variation class-attribute instance-attribute

seed_variation: int | None = Field(
    default=None, ge=1, le=1000
)

Deprecated.

control_type class-attribute instance-attribute

control_type: str | KNOWN_IMAGE_CONTROLNETS | None = None

The type of control net type to use.

image_is_control class-attribute instance-attribute

image_is_control: bool | None = None

Set to True if the image is a control image.

return_control_map class-attribute instance-attribute

return_control_map: bool | None = None

Set to True if you want the ControlNet map returned instead of a generated image.

extra_texts class-attribute instance-attribute

extra_texts: list[ExtraTextEntry] | None = None

A list of extra texts and prompts to use in the comfyUI workflow.

use_nsfw_censor class-attribute instance-attribute

use_nsfw_censor: bool = False

If the request is SFW, and the worker accidentally generates NSFW, it will send back a censored image.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "ModelPayloadRootStable"

random_seed_if_none

random_seed_if_none(v: str | None) -> str | None

If the seed is None, generate a random seed.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("seed")
def random_seed_if_none(cls, v: str | None) -> str | None:
    """If the seed is None, generate a random seed."""
    if v is None:
        random_seed = str(random.randint(1, 1000000000))
        logger.debug(f"Using random seed ({random_seed})")
        return random_seed

    return v

control_type_must_be_known

control_type_must_be_known(
    v: str | KNOWN_IMAGE_CONTROLNETS | None,
) -> str | KNOWN_IMAGE_CONTROLNETS | None

Ensure that the control type is in this list of supported control types.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("control_type")
def control_type_must_be_known(
    cls,
    v: str | KNOWN_IMAGE_CONTROLNETS | None,
) -> str | KNOWN_IMAGE_CONTROLNETS | None:
    """Ensure that the control type is in this list of supported control types."""
    if v is None:
        return None
    if isinstance(v, KNOWN_IMAGE_CONTROLNETS):
        return v

    try:
        KNOWN_IMAGE_CONTROLNETS(v)
    except ValueError:
        logger.warning(f"Unknown control type {v}. Is your SDK out of date or did the API change?")

    return v

JobSubmitResponse

Bases: HordeResponseBaseModel

Indicates that a generation job was successfully submitted and the amount of kudos gained.

Represents the data returned from the following endpoints and http status codes
  • /v2/generate/text/submit | TextGenerationJobSubmitRequest [POST] -> 200
  • /v2/generate/submit | ImageGenerationJobSubmitRequest [POST] -> 200

v2 API Model: GenerationSubmitted

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class JobSubmitResponse(HordeResponseBaseModel):
    """Indicates that a generation job was successfully submitted and the amount of kudos gained.

    Represents the data returned from the following endpoints and http status codes:
        - /v2/generate/text/submit | TextGenerationJobSubmitRequest [POST] -> 200
        - /v2/generate/submit | ImageGenerationJobSubmitRequest [POST] -> 200

    v2 API Model: `GenerationSubmitted`
    """

    reward: float
    """The amount of kudos gained for submitting this request."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "GenerationSubmitted"

reward instance-attribute

reward: float

The amount of kudos gained for submitting this request.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "GenerationSubmitted"

GenMetadataEntry

Bases: HordeAPIObjectBaseModel

Represents a single generation metadata entry.

v2 API Model: GenerationMetadataStable

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class GenMetadataEntry(HordeAPIObjectBaseModel):
    """Represents a single generation metadata entry.

    v2 API Model: `GenerationMetadataStable`
    """

    type_: METADATA_TYPE | str = Field(alias="type")
    """The relevance of the metadata field."""
    value: METADATA_VALUE | str = Field()
    """The value of the metadata field."""
    ref: str | None = Field(default=None, max_length=255)
    """Optionally a reference for the metadata (e.g. a lora ID)"""

    @field_validator("type_")
    def validate_type(cls, v: str | METADATA_TYPE) -> str | METADATA_TYPE:
        """Ensure that the type is in this list of supported types."""
        if isinstance(v, METADATA_TYPE):
            return v
        if isinstance(v, str) and v not in METADATA_TYPE.__members__:
            logger.warning(f"Unknown metadata type {v}. Is your SDK out of date or did the API change?")
        return v

    @field_validator("value")
    def validate_value(cls, v: str | METADATA_VALUE) -> str | METADATA_VALUE:
        """Ensure that the value is in this list of supported values."""
        if isinstance(v, METADATA_VALUE):
            return v
        if isinstance(v, str) and v not in METADATA_VALUE.__members__:
            logger.warning(f"Unknown metadata value {v}. Is your SDK out of date or did the API change?")
        return v

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "GenerationMetadataStable"

type_ class-attribute instance-attribute

type_: METADATA_TYPE | str = Field(alias='type')

The relevance of the metadata field.

value class-attribute instance-attribute

value: METADATA_VALUE | str = Field()

The value of the metadata field.

ref class-attribute instance-attribute

ref: str | None = Field(default=None, max_length=255)

Optionally a reference for the metadata (e.g. a lora ID)

validate_type

validate_type(
    v: str | METADATA_TYPE,
) -> str | METADATA_TYPE

Ensure that the type is in this list of supported types.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("type_")
def validate_type(cls, v: str | METADATA_TYPE) -> str | METADATA_TYPE:
    """Ensure that the type is in this list of supported types."""
    if isinstance(v, METADATA_TYPE):
        return v
    if isinstance(v, str) and v not in METADATA_TYPE.__members__:
        logger.warning(f"Unknown metadata type {v}. Is your SDK out of date or did the API change?")
    return v

validate_value

validate_value(
    v: str | METADATA_VALUE,
) -> str | METADATA_VALUE

Ensure that the value is in this list of supported values.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("value")
def validate_value(cls, v: str | METADATA_VALUE) -> str | METADATA_VALUE:
    """Ensure that the value is in this list of supported values."""
    if isinstance(v, METADATA_VALUE):
        return v
    if isinstance(v, str) and v not in METADATA_VALUE.__members__:
        logger.warning(f"Unknown metadata value {v}. Is your SDK out of date or did the API change?")
    return v

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "GenerationMetadataStable"

MessageSpecifiesSharedKeyMixin

Bases: HordeAPIData

Mix-in class to describe an endpoint for which you can specify a shared key.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class MessageSpecifiesSharedKeyMixin(HordeAPIData):
    """Mix-in class to describe an endpoint for which you can specify a shared key."""

    sharedkey_id: SharedKeyID = Field(alias="id")
    """The shared key ID to use for this request."""

    @field_validator("sharedkey_id", mode="before")
    def validate_sharedkey_id(cls, v: str | SharedKeyID) -> SharedKeyID | str:
        """Ensure that the shared key ID is not empty."""
        if isinstance(v, str) and v == "":
            logger.warning("Shared key ID is empty")

        return v

sharedkey_id class-attribute instance-attribute

sharedkey_id: SharedKeyID = Field(alias='id')

The shared key ID to use for this request.

validate_sharedkey_id

validate_sharedkey_id(
    v: str | SharedKeyID,
) -> SharedKeyID | str

Ensure that the shared key ID is not empty.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("sharedkey_id", mode="before")
def validate_sharedkey_id(cls, v: str | SharedKeyID) -> SharedKeyID | str:
    """Ensure that the shared key ID is not empty."""
    if isinstance(v, str) and v == "":
        logger.warning("Shared key ID is empty")

    return v

ActiveModelLite

Bases: HordeAPIObjectBaseModel

Represents a single active model.

v2 API Model: ActiveModelLite

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class ActiveModelLite(HordeAPIObjectBaseModel):
    """Represents a single active model.

    v2 API Model: `ActiveModelLite`
    """

    count: int | None = Field(
        default=None,
    )
    """How many of workers in this horde are running this model."""
    name: str | None = Field(
        default=None,
    )
    """The Name of a model available by workers in this horde."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "ActiveModelLite"

count class-attribute instance-attribute

count: int | None = Field(default=None)

How many of workers in this horde are running this model.

name class-attribute instance-attribute

name: str | None = Field(default=None)

The Name of a model available by workers in this horde.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "ActiveModelLite"

ActiveModel

Bases: ActiveModelLite

Represents a single active model.

v2 API Model: ActiveModel

Source code in horde_sdk/ai_horde_api/apimodels/base.py
class ActiveModel(ActiveModelLite):
    """Represents a single active model.

    v2 API Model: `ActiveModel`
    """

    eta: int | None = Field(
        default=None,
    )
    """Estimated time in seconds for this model's queue to be cleared."""
    jobs: float | None = Field(
        default=None,
    )
    """The job count waiting to be generated by this model."""
    performance: float | None = Field(
        default=None,
    )
    """The average speed of generation for this model."""
    queued: float | None = Field(
        default=None,
    )
    """The amount waiting to be generated by this model."""
    type_: MODEL_TYPE | None = Field(
        examples=[MODEL_TYPE.image, MODEL_TYPE.text],
        alias="type",
    )
    """The model type (text or image)."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "ActiveModel"

eta class-attribute instance-attribute

eta: int | None = Field(default=None)

Estimated time in seconds for this model's queue to be cleared.

jobs class-attribute instance-attribute

jobs: float | None = Field(default=None)

The job count waiting to be generated by this model.

performance class-attribute instance-attribute

performance: float | None = Field(default=None)

The average speed of generation for this model.

queued class-attribute instance-attribute

queued: float | None = Field(default=None)

The amount waiting to be generated by this model.

type_ class-attribute instance-attribute

type_: MODEL_TYPE | None = Field(
    examples=[MODEL_TYPE.image, MODEL_TYPE.text],
    alias="type",
)

The model type (text or image).

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "ActiveModel"