Skip to content

status

Generation

Bases: HordeAPIObjectBaseModel

Mixin that contains common fields for generation responses.

v2 API Model: Generation

Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
class Generation(HordeAPIObjectBaseModel):
    """Mixin that contains common fields for generation responses.

    v2 API Model: `Generation`
    """

    model: str = Field(title="Generation Model")
    """The model which generated this image."""
    state: GENERATION_STATE = Field(
        ...,
        examples=["ok"],
        title="Generation State",
    )
    """OBSOLETE (Use the gen_metadata field). The state of this generation."""
    worker_id: str | WorkerID = Field(
        title="Worker ID",
    )
    """The UUID of the worker which generated this image."""
    worker_name: str = Field(
        title="Worker Name",
    )
    """The name of the worker which generated this image."""

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

model class-attribute instance-attribute

model: str = Field(title='Generation Model')

The model which generated this image.

state class-attribute instance-attribute

state: GENERATION_STATE = Field(
    ..., examples=["ok"], title="Generation State"
)

OBSOLETE (Use the gen_metadata field). The state of this generation.

worker_id class-attribute instance-attribute

worker_id: str | WorkerID = Field(title='Worker ID')

The UUID of the worker which generated this image.

worker_name class-attribute instance-attribute

worker_name: str = Field(title='Worker Name')

The name of the worker which generated this image.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

get_api_model_name classmethod

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

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]

Return a set of fields which should be redacted from logs.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    """Return a set of fields which should be redacted from logs."""
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

ImageGeneration

Bases: Generation

Represents an individual image generation in a status response, including the image data.

Represents the individual image generation responses in a ImageGenerateStatusResponse.

v2 API Model: GenerationStable

Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
class ImageGeneration(Generation):
    """Represents an individual image generation in a status response, including the image data.

    Represents the individual image generation responses in a ImageGenerateStatusResponse.

    v2 API Model: `GenerationStable`
    """

    id_: GenerationID = Field(alias="id")
    """The UUID of this generation. Is always returned as a `GenerationID`, but can initialized from a `str`."""
    # todo: remove `str`?
    img: str
    """The generated image as a Base64-encoded .webp file."""
    seed: str
    """The seed which generated this image."""
    censored: bool
    """When true this image has been censored by the worker's safety filter."""
    gen_metadata: list[GenMetadataEntry] | None = None
    """Extra metadata about faulted or defaulted components of the generation"""

    @override
    @classmethod
    def get_api_model_name(self) -> str | None:
        return "GenerationStable"

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

        return v

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, ImageGeneration):
            return False
        return self.id_ == other.id_

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

id_ class-attribute instance-attribute

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

The UUID of this generation. Is always returned as a GenerationID, but can initialized from a str.

img instance-attribute

img: str

The generated image as a Base64-encoded .webp file.

seed instance-attribute

seed: str

The seed which generated this image.

censored instance-attribute

censored: bool

When true this image has been censored by the worker's safety filter.

gen_metadata class-attribute instance-attribute

gen_metadata: list[GenMetadataEntry] | None = None

Extra metadata about faulted or defaulted components of the generation

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

model class-attribute instance-attribute

model: str = Field(title='Generation Model')

The model which generated this image.

state class-attribute instance-attribute

state: GENERATION_STATE = Field(
    ..., examples=["ok"], title="Generation State"
)

OBSOLETE (Use the gen_metadata field). The state of this generation.

worker_id class-attribute instance-attribute

worker_id: str | WorkerID = Field(title='Worker ID')

The UUID of the worker which generated this image.

worker_name class-attribute instance-attribute

worker_name: str = Field(title='Worker Name')

The name of the worker which generated this image.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_api_model_name(self) -> str | None:
    return "GenerationStable"

validate_id

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

Validate the ID is not an empty string.

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

    return v

__eq__

__eq__(other: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
def __eq__(self, other: object) -> bool:
    if not isinstance(other, ImageGeneration):
        return False
    return self.id_ == other.id_

__hash__

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

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]

Return a set of fields which should be redacted from logs.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    """Return a set of fields which should be redacted from logs."""
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

ImageGenerateStatusResponse

Bases: HordeResponseBaseModel, ResponseWithProgressMixin, ResponseGenerationProgressInfoMixin

The current status of an image generation request and the data if it is complete.

Represents the data returned from the following endpoints and http status codes
  • /v2/generate/status/{id} | ImageGenerateStatusRequest [GET] -> 200
  • /v2/generate/status/{id} | DeleteImageGenerateRequest [DELETE] -> 200

v2 API Model: RequestStatusStable

Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
class ImageGenerateStatusResponse(
    HordeResponseBaseModel,
    ResponseWithProgressMixin,
    ResponseGenerationProgressInfoMixin,
):
    """The current status of an image generation request and the data if it is complete.

    Represents the data returned from the following endpoints and http status codes:
        - /v2/generate/status/{id} | ImageGenerateStatusRequest [GET] -> 200
        - /v2/generate/status/{id} | DeleteImageGenerateRequest [DELETE] -> 200

    v2 API Model: `RequestStatusStable`
    """

    generations: list[ImageGeneration] = Field(default_factory=list)
    """The individual image generation responses in this request."""
    shared: bool | None = False
    """If True, These images have been shared with LAION."""

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

    @override
    @classmethod
    def get_finalize_success_request_type(cls) -> None:
        return None

    @override
    def is_job_complete(self, number_of_result_expected: int) -> bool:
        return len(self.generations) == number_of_result_expected

    @override
    def is_job_possible(self) -> bool:
        return self.is_possible

    @override
    @classmethod
    def is_final_follow_up(cls) -> bool:
        return True

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, ImageGenerateStatusResponse):
            return False
        return all(gen in other.generations for gen in self.generations)

    def __hash__(self) -> int:
        return hash(tuple(self.generations))

generations class-attribute instance-attribute

generations: list[ImageGeneration] = Field(
    default_factory=list
)

The individual image generation responses in this request.

shared class-attribute instance-attribute

shared: bool | None = False

If True, These images have been shared with LAION.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

finished instance-attribute

finished: int

The amount of finished jobs in this request.

processing instance-attribute

processing: int

The amount of still processing jobs in this request.

restarted instance-attribute

restarted: int

The amount of jobs that timed out and had to be restarted or were reported as failed by a worker.

waiting instance-attribute

waiting: int

The amount of jobs waiting to be picked up by a worker.

done instance-attribute

done: bool

True when all jobs in this request are done. Else False.

faulted class-attribute instance-attribute

faulted: bool = False

True when this request caused an internal server error and could not be completed.

wait_time instance-attribute

wait_time: int

The expected amount to wait (in seconds) to generate all jobs in this request.

queue_position instance-attribute

queue_position: int

The position in the requests queue. This position is determined by relative Kudos amounts.

kudos instance-attribute

kudos: float

The amount of total Kudos this request has consumed until now.

is_possible class-attribute instance-attribute

is_possible: bool = True

If False, this request will not be able to be completed with the pool of workers currently available.

time_constructed property

time_constructed: float

The time the model was constructed (in epoch time).

get_api_model_name classmethod

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

get_finalize_success_request_type classmethod

get_finalize_success_request_type() -> None
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_finalize_success_request_type(cls) -> None:
    return None

is_job_complete

is_job_complete(number_of_result_expected: int) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
def is_job_complete(self, number_of_result_expected: int) -> bool:
    return len(self.generations) == number_of_result_expected

is_job_possible

is_job_possible() -> bool
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
def is_job_possible(self) -> bool:
    return self.is_possible

is_final_follow_up classmethod

is_final_follow_up() -> bool
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def is_final_follow_up(cls) -> bool:
    return True

__eq__

__eq__(other: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
def __eq__(self, other: object) -> bool:
    if not isinstance(other, ImageGenerateStatusResponse):
        return False
    return all(gen in other.generations for gen in self.generations)

__hash__

__hash__() -> int
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
def __hash__(self) -> int:
    return hash(tuple(self.generations))

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]

Return a set of fields which should be redacted from logs.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    """Return a set of fields which should be redacted from logs."""
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

DeleteImageGenerateRequest

Bases: BaseAIHordeRequest, JobRequestMixin

Request to cancel an image generation by ID.

Represents a DELETE request to the /v2/generate/status/{id} endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
class DeleteImageGenerateRequest(
    BaseAIHordeRequest,
    JobRequestMixin,
):
    """Request to cancel an image generation by ID.

    Represents a DELETE request to the /v2/generate/status/{id} endpoint.
    """

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

    @override
    @classmethod
    def get_http_method(cls) -> HTTPMethod:
        return HTTPMethod.DELETE

    @override
    @classmethod
    def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
        return AI_HORDE_API_ENDPOINT_SUBPATH.v2_generate_status

    @override
    @classmethod
    def get_default_success_response_type(cls) -> type[ImageGenerateStatusResponse]:
        return ImageGenerateStatusResponse

    @override
    def __eq__(self, value: object) -> bool:
        if not isinstance(value, DeleteImageGenerateRequest):
            return False

        return self.id_ == value.id_

    @override
    def __hash__(self) -> int:
        return hash(DeleteImageGenerateRequest.__name__) + hash(self.id_)

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

id_ class-attribute instance-attribute

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

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

accept class-attribute instance-attribute

accept: GenericAcceptTypes = json

The 'accept' header field.

client_agent class-attribute instance-attribute

client_agent: str = Field(
    default=default_bridge_agent_string,
    alias="Client-Agent",
)

The requesting client's agent. You should set this to reflect the name, version and contact information for your client.

get_api_model_name classmethod

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

get_http_method classmethod

get_http_method() -> HTTPMethod
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.DELETE

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> AI_HORDE_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_generate_status

get_default_success_response_type classmethod

get_default_success_response_type() -> (
    type[ImageGenerateStatusResponse]
)
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[ImageGenerateStatusResponse]:
    return ImageGenerateStatusResponse

__eq__

__eq__(value: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
def __eq__(self, value: object) -> bool:
    if not isinstance(value, DeleteImageGenerateRequest):
        return False

    return self.id_ == value.id_

__hash__

__hash__() -> int
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
def __hash__(self) -> int:
    return hash(DeleteImageGenerateRequest.__name__) + hash(self.id_)

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

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]
Source code in horde_sdk/generic_api/apimodels.py
@override
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

get_api_endpoint_url classmethod

get_api_endpoint_url() -> str

Return the endpoint URL, including the path to the specific API action defined by this object.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_api_endpoint_url(cls) -> str:
    """Return the endpoint URL, including the path to the specific API action defined by this object."""
    return url_with_path(base_url=cls.get_api_url(), path=cls.get_api_endpoint_subpath())

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

get_success_status_response_pairs classmethod

get_success_status_response_pairs() -> (
    dict[HTTPStatusCode, type[HordeResponseTypes]]
)

Return a dict of HTTP status codes and the expected HordeResponse.

Defaults to {HTTPStatusCode.OK: cls.get_expected_response_type()}, but may be overridden to support other status codes.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_success_status_response_pairs(
    cls,
) -> dict[HTTPStatusCode, type[HordeResponseTypes]]:
    """Return a dict of HTTP status codes and the expected `HordeResponse`.

    Defaults to `{HTTPStatusCode.OK: cls.get_expected_response_type()}`, but may be overridden to support other
    status codes.
    """
    return {HTTPStatusCode.OK: cls.get_default_success_response_type()}

get_header_fields classmethod

get_header_fields() -> list[str]

Return a list of field names from this request object that should be sent as header fields.

This is in addition to GenericHeaderFields's values, and possibly the API specific class which inherits from GenericHeaderFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_header_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as header fields.

    This is in addition to `GenericHeaderFields`'s values, and possibly the API specific class
    which inherits from `GenericHeaderFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_query_fields classmethod

get_query_fields() -> list[str]

Return a list of field names from this request object that should be sent as query parameters.

This is in addition to GenericQueryFields's values, and possibly the API specific class which inherits from GenericQueryFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_query_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as query parameters.

    This is in addition to `GenericQueryFields`'s values, and possibly the API specific class
    which inherits from `GenericQueryFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_number_of_results_expected

get_number_of_results_expected() -> int

Return the number of (job) results expected from this request.

Defaults to 1, but may be overridden to dynamically change the number of results expected.

This is factored into context management; if the number of results expected is not met, the job is considered unhandled on an exception and followed up on to attempt to close it.

Source code in horde_sdk/generic_api/apimodels.py
def get_number_of_results_expected(self) -> int:
    """Return the number of (job) results expected from this request.

    Defaults to `1`, but may be overridden to dynamically change the number of results expected.

    This is factored into context management; if the number of results expected is not met, the job is considered
    unhandled on an exception and followed up on to attempt to close it.
    """
    return 1

get_requires_follow_up

get_requires_follow_up() -> bool

Return whether this request requires a follow up request(s).

Returns:

  • bool ( bool ) –

    Whether this request requires a follow up request to close the job on the server.

Source code in horde_sdk/generic_api/apimodels.py
def get_requires_follow_up(self) -> bool:
    """Return whether this request requires a follow up request(s).

    Returns:
        bool: Whether this request requires a follow up request to close the job on the server.
    """
    for response_type in self.get_success_status_response_pairs().values():
        if issubclass(response_type, ResponseRequiringFollowUpMixin):
            return True
    return False

ImageGenerateStatusRequest

Bases: BaseAIHordeRequest, JobRequestMixin

Request the status of an image generation by ID.

Important: This is a rate limited endpoint. Prefer using the check endpoint when simply checking the status. Use this endpoint when you need to get the resulting image data. See :class:horde_sdk.api_horde_api.apimodels.generate.check.ImageGenerateCheckRequest for more information.

Represents a GET request to the /v2/generate/status/{id} endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
class ImageGenerateStatusRequest(BaseAIHordeRequest, JobRequestMixin):
    """Request the status of an image generation by ID.

    Important: This is a rate limited endpoint. Prefer using the check endpoint when simply checking the status.
    Use this endpoint when you need to get the resulting image data.
    See :class:`horde_sdk.api_horde_api.apimodels.generate.check.ImageGenerateCheckRequest`
    for more information.

    Represents a GET request to the /v2/generate/status/{id} endpoint.
    """

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

    @override
    @classmethod
    def get_http_method(cls) -> HTTPMethod:
        return HTTPMethod.GET

    @override
    @classmethod
    def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
        return AI_HORDE_API_ENDPOINT_SUBPATH.v2_generate_status

    @override
    @classmethod
    def get_default_success_response_type(cls) -> type[ImageGenerateStatusResponse]:
        return ImageGenerateStatusResponse

    @override
    def __eq__(self, value: object) -> bool:
        if not isinstance(value, ImageGenerateStatusRequest):
            return False

        return self.id_ == value.id_

    @override
    def __hash__(self) -> int:
        return hash(ImageGenerateStatusRequest.__name__) + hash(self.id_)

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

id_ class-attribute instance-attribute

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

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

accept class-attribute instance-attribute

accept: GenericAcceptTypes = json

The 'accept' header field.

client_agent class-attribute instance-attribute

client_agent: str = Field(
    default=default_bridge_agent_string,
    alias="Client-Agent",
)

The requesting client's agent. You should set this to reflect the name, version and contact information for your client.

get_api_model_name classmethod

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

get_http_method classmethod

get_http_method() -> HTTPMethod
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> AI_HORDE_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_generate_status

get_default_success_response_type classmethod

get_default_success_response_type() -> (
    type[ImageGenerateStatusResponse]
)
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[ImageGenerateStatusResponse]:
    return ImageGenerateStatusResponse

__eq__

__eq__(value: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
def __eq__(self, value: object) -> bool:
    if not isinstance(value, ImageGenerateStatusRequest):
        return False

    return self.id_ == value.id_

__hash__

__hash__() -> int
Source code in horde_sdk/ai_horde_api/apimodels/generate/status.py
@override
def __hash__(self) -> int:
    return hash(ImageGenerateStatusRequest.__name__) + hash(self.id_)

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

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]
Source code in horde_sdk/generic_api/apimodels.py
@override
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

get_api_endpoint_url classmethod

get_api_endpoint_url() -> str

Return the endpoint URL, including the path to the specific API action defined by this object.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_api_endpoint_url(cls) -> str:
    """Return the endpoint URL, including the path to the specific API action defined by this object."""
    return url_with_path(base_url=cls.get_api_url(), path=cls.get_api_endpoint_subpath())

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

get_success_status_response_pairs classmethod

get_success_status_response_pairs() -> (
    dict[HTTPStatusCode, type[HordeResponseTypes]]
)

Return a dict of HTTP status codes and the expected HordeResponse.

Defaults to {HTTPStatusCode.OK: cls.get_expected_response_type()}, but may be overridden to support other status codes.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_success_status_response_pairs(
    cls,
) -> dict[HTTPStatusCode, type[HordeResponseTypes]]:
    """Return a dict of HTTP status codes and the expected `HordeResponse`.

    Defaults to `{HTTPStatusCode.OK: cls.get_expected_response_type()}`, but may be overridden to support other
    status codes.
    """
    return {HTTPStatusCode.OK: cls.get_default_success_response_type()}

get_header_fields classmethod

get_header_fields() -> list[str]

Return a list of field names from this request object that should be sent as header fields.

This is in addition to GenericHeaderFields's values, and possibly the API specific class which inherits from GenericHeaderFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_header_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as header fields.

    This is in addition to `GenericHeaderFields`'s values, and possibly the API specific class
    which inherits from `GenericHeaderFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_query_fields classmethod

get_query_fields() -> list[str]

Return a list of field names from this request object that should be sent as query parameters.

This is in addition to GenericQueryFields's values, and possibly the API specific class which inherits from GenericQueryFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_query_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as query parameters.

    This is in addition to `GenericQueryFields`'s values, and possibly the API specific class
    which inherits from `GenericQueryFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_number_of_results_expected

get_number_of_results_expected() -> int

Return the number of (job) results expected from this request.

Defaults to 1, but may be overridden to dynamically change the number of results expected.

This is factored into context management; if the number of results expected is not met, the job is considered unhandled on an exception and followed up on to attempt to close it.

Source code in horde_sdk/generic_api/apimodels.py
def get_number_of_results_expected(self) -> int:
    """Return the number of (job) results expected from this request.

    Defaults to `1`, but may be overridden to dynamically change the number of results expected.

    This is factored into context management; if the number of results expected is not met, the job is considered
    unhandled on an exception and followed up on to attempt to close it.
    """
    return 1

get_requires_follow_up

get_requires_follow_up() -> bool

Return whether this request requires a follow up request(s).

Returns:

  • bool ( bool ) –

    Whether this request requires a follow up request to close the job on the server.

Source code in horde_sdk/generic_api/apimodels.py
def get_requires_follow_up(self) -> bool:
    """Return whether this request requires a follow up request(s).

    Returns:
        bool: Whether this request requires a follow up request to close the job on the server.
    """
    for response_type in self.get_success_status_response_pairs().values():
        if issubclass(response_type, ResponseRequiringFollowUpMixin):
            return True
    return False