Skip to content

status

AIHordeHeartbeatResponse

Bases: HordeResponseBaseModel, ContainsMessageResponseMixin

Returns the status of the AI Horde API and a message if present.

Represents the data returned from the /v2/status/heartbeat endpoint with http status code 200.

v2 API Model: _ANONYMOUS_MODEL

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class AIHordeHeartbeatResponse(HordeResponseBaseModel, ContainsMessageResponseMixin):
    """Returns the status of the AI Horde API and a message if present.

    Represents the data returned from the /v2/status/heartbeat endpoint with http status code 200.

    v2 API Model: `_ANONYMOUS_MODEL`
    """

    version: str
    """The version of the AI Horde API that this node is running."""

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

version instance-attribute

version: str

The version of the AI Horde API that this node is running.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

message class-attribute instance-attribute

message: str = ''

A message from the API. This is typically an error or warning message, but may also be informational.

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/status.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return _ANONYMOUS_MODEL

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
    }

AIHordeHeartbeatRequest

Bases: BaseAIHordeRequest

Request a heartbeat from the AI Horde API, suitable for checking if the API is up and running.

These requests may also return other meta information, such as the version of the API.

Represents a GET request to the /v2/status/heartbeat endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class AIHordeHeartbeatRequest(BaseAIHordeRequest):
    """Request a heartbeat from the AI Horde API, suitable for checking if the API is up and running.

    These requests may also return other meta information, such as the version of the API.

    Represents a GET request to the /v2/status/heartbeat 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_status_heartbeat

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

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

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/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/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/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_status_heartbeat

get_default_success_response_type classmethod

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

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

HordePerformanceResponse

Bases: HordeResponseBaseModel

Information about the performance of the horde, such as worker counts and queue sizes.

Represents the data returned from the /v2/status/performance endpoint with http status code 200.

v2 API Model: HordePerformance

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class HordePerformanceResponse(HordeResponseBaseModel):
    """Information about the performance of the horde, such as worker counts and queue sizes.

    Represents the data returned from the /v2/status/performance endpoint with http status code 200.

    v2 API Model: `HordePerformance`
    """

    interrogator_count: int | None = Field(
        default=None,
        description=(
            "How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes."
        ),
    )
    """How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes."""
    interrogator_thread_count: int | None = Field(
        default=None,
        description=(
            "How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5"
            " minutes."
        ),
    )
    """How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5
    minutes."""
    past_minute_megapixelsteps: float | None = Field(
        default=None,
    )
    """How many megapixelsteps this horde generated in the last minute."""
    past_minute_tokens: float | None = Field(
        default=None,
    )
    """How many tokens this horde generated in the last minute."""
    queued_forms: float | None = Field(
        default=None,
    )
    """The amount of image interrogations waiting and processing currently in this horde."""
    queued_megapixelsteps: float | None = Field(
        default=None,
    )
    """The amount of megapixelsteps in waiting and processing requests currently in this horde."""
    queued_requests: int | None = Field(
        default=None,
    )
    """The amount of waiting and processing image requests currently in this horde."""
    queued_text_requests: int | None = Field(
        default=None,
    )
    """The amount of waiting and processing text requests currently in this horde."""
    queued_tokens: float | None = Field(
        default=None,
    )
    """The amount of tokens in waiting and processing requests currently in this horde."""
    text_thread_count: int | None = Field(
        default=None,
        description=(
            "How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5"
            " minutes."
        ),
    )
    """How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5
    minutes."""
    text_worker_count: int | None = Field(
        default=None,
    )
    """How many workers are actively processing prompt generations in this horde in the past 5 minutes."""
    thread_count: int | None = Field(
        default=None,
        description=(
            "How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5"
            " minutes."
        ),
    )
    """How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5
    minutes."""
    worker_count: int | None = Field(
        default=None,
    )
    """How many workers are actively processing prompt generations in this horde in the past 5 minutes."""

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

interrogator_count class-attribute instance-attribute

interrogator_count: int | None = Field(
    default=None,
    description="How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes.",
)

How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes.

interrogator_thread_count class-attribute instance-attribute

interrogator_thread_count: int | None = Field(
    default=None,
    description="How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5 minutes.",
)

How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5 minutes.

past_minute_megapixelsteps class-attribute instance-attribute

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

How many megapixelsteps this horde generated in the last minute.

past_minute_tokens class-attribute instance-attribute

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

How many tokens this horde generated in the last minute.

queued_forms class-attribute instance-attribute

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

The amount of image interrogations waiting and processing currently in this horde.

queued_megapixelsteps class-attribute instance-attribute

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

The amount of megapixelsteps in waiting and processing requests currently in this horde.

queued_requests class-attribute instance-attribute

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

The amount of waiting and processing image requests currently in this horde.

queued_text_requests class-attribute instance-attribute

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

The amount of waiting and processing text requests currently in this horde.

queued_tokens class-attribute instance-attribute

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

The amount of tokens in waiting and processing requests currently in this horde.

text_thread_count class-attribute instance-attribute

text_thread_count: int | None = Field(
    default=None,
    description="How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5 minutes.",
)

How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5 minutes.

text_worker_count class-attribute instance-attribute

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

How many workers are actively processing prompt generations in this horde in the past 5 minutes.

thread_count class-attribute instance-attribute

thread_count: int | None = Field(
    default=None,
    description="How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5 minutes.",
)

How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5 minutes.

worker_count class-attribute instance-attribute

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

How many workers are actively processing prompt generations in this horde in the past 5 minutes.

time_constructed property

time_constructed: float

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

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/status.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "HordePerformance"

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
    }

HordePerformanceRequest

Bases: BaseAIHordeRequest

Request performance information about the horde, such as worker counts and queue sizes.

Represents a GET request to the /v2/status/performance endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class HordePerformanceRequest(BaseAIHordeRequest):
    """Request performance information about the horde, such as worker counts and queue sizes.

    Represents a GET request to the /v2/status/performance 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_status_performance

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

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

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/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/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/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_status_performance

get_default_success_response_type classmethod

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

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

Newspiece

Bases: HordeAPIObjectBaseModel

A piece of news from the horde, such as updates or other news from the AI-Horde team.

v2 API Model: Newspiece

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class Newspiece(HordeAPIObjectBaseModel):
    """A piece of news from the horde, such as updates or other news from the AI-Horde team.

    v2 API Model: `Newspiece`
    """

    date_published: str | None = Field(
        default=None,
    )
    """The date this newspiece was published."""
    importance: str | None = Field(default=None, examples=["Information"])
    """How critical this piece of news is."""
    newspiece: str | None = Field(
        default=None,
    )
    """The actual piece of news."""
    tags: list[str] | None = Field(
        default=None,
    )
    """The tags associated with this newspiece."""
    title: str | None = Field(
        default=None,
    )
    """The title of this newspiece."""
    more_info_urls: list[str] | None = Field(
        default=None,
    )
    """The URLs for more information about this newspiece."""

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

date_published class-attribute instance-attribute

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

The date this newspiece was published.

importance class-attribute instance-attribute

importance: str | None = Field(
    default=None, examples=["Information"]
)

How critical this piece of news is.

newspiece class-attribute instance-attribute

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

The actual piece of news.

tags class-attribute instance-attribute

tags: list[str] | None = Field(default=None)

The tags associated with this newspiece.

title class-attribute instance-attribute

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

The title of this newspiece.

more_info_urls class-attribute instance-attribute

more_info_urls: list[str] | None = Field(default=None)

The URLs for more information about this newspiece.

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/status.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "Newspiece"

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
    }

NewsResponse

Bases: HordeResponseRootModel[list[Newspiece]]

A list of newspieces from the horde, which are updates or other news from the AI-Horde team.

Represents the data returned from the /v2/status/news endpoint with http status code 200.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
@Unhashable
@Unequatable
class NewsResponse(HordeResponseRootModel[list[Newspiece]]):
    """A list of newspieces from the horde, which are updates or other news from the AI-Horde team.

    Represents the data returned from the /v2/status/news endpoint with http status code 200.
    """

    root: list[Newspiece]
    """The underlying list of newspieces."""

    def __iter__(self) -> Iterator[Newspiece]:  # type: ignore
        return iter(self.root)

    def __getitem__(self, index: int) -> Newspiece:
        return self.root[index]

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

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, NewsResponse):
            return False
        return all(newspiece in other.root for newspiece in self.root)

root instance-attribute

root: list[Newspiece]

The underlying list of newspieces.

time_constructed property

time_constructed: float

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

model_config class-attribute instance-attribute

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

__iter__

__iter__() -> Iterator[Newspiece]
Source code in horde_sdk/ai_horde_api/apimodels/status.py
def __iter__(self) -> Iterator[Newspiece]:  # type: ignore
    return iter(self.root)

__getitem__

__getitem__(index: int) -> Newspiece
Source code in horde_sdk/ai_horde_api/apimodels/status.py
def __getitem__(self, index: int) -> Newspiece:
    return self.root[index]

get_api_model_name classmethod

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

__eq__

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

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
    }

NewsRequest

Bases: BaseAIHordeRequest

Request news from the horde, such as updates or other news from the AI-Horde team.

Represents a GET request to the /v2/status/news endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class NewsRequest(BaseAIHordeRequest):
    """Request news from the horde, such as updates or other news from the AI-Horde team.

    Represents a GET request to the /v2/status/news 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_status_news

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

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

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/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/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/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_status_news

get_default_success_response_type classmethod

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

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

HordeStatusModelsAllResponse

Bases: HordeResponseRootModel[list[ActiveModel]]

A list of details about active models in the horde.

Represents the data returned from the /v2/status/models endpoint with http status code 200.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
@Unhashable
@Unequatable
class HordeStatusModelsAllResponse(HordeResponseRootModel[list[ActiveModel]]):
    """A list of details about active models in the horde.

    Represents the data returned from the /v2/status/models endpoint with http status code 200.
    """

    root: list[ActiveModel]
    """The underlying list of models."""

    def __iter__(self) -> Iterator[ActiveModel]:  # type: ignore
        return iter(self.root)

    def __getitem__(self, index: int) -> ActiveModel:
        return self.root[index]

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

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, HordeStatusModelsAllResponse):
            return False
        return all(model in other.root for model in self.root)

root instance-attribute

root: list[ActiveModel]

The underlying list of models.

time_constructed property

time_constructed: float

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

model_config class-attribute instance-attribute

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

__iter__

__iter__() -> Iterator[ActiveModel]
Source code in horde_sdk/ai_horde_api/apimodels/status.py
def __iter__(self) -> Iterator[ActiveModel]:  # type: ignore
    return iter(self.root)

__getitem__

__getitem__(index: int) -> ActiveModel
Source code in horde_sdk/ai_horde_api/apimodels/status.py
def __getitem__(self, index: int) -> ActiveModel:
    return self.root[index]

get_api_model_name classmethod

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

__eq__

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

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
    }

HordeStatusModelsAllRequest

Bases: BaseAIHordeRequest

Request details about models in the horde.

Represents a GET request to the /v2/status/models endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class HordeStatusModelsAllRequest(BaseAIHordeRequest):
    """Request details about models in the horde.

    Represents a GET request to the /v2/status/models endpoint.
    """

    type_: MODEL_TYPE = Field(
        default=MODEL_TYPE.image,
        examples=[MODEL_TYPE.image, MODEL_TYPE.text],
        alias="type",
    )
    """The type of model to filter by."""

    min_count: int | None = None
    """Filter only models that have at least this amount of threads serving."""
    max_count: int | None = None
    """Filter only models that have at most this amount of threads serving."""

    model_state: MODEL_STATE = MODEL_STATE.all
    """If 'known', only show stats for known models in the model reference. If 'custom' only show stats for custom
    models. If 'all' shows stats for all models."""

    @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_status_models_all

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

    @override
    @classmethod
    def get_query_fields(cls) -> list[str]:
        return ["type_", "min_count", "max_count"]

type_ class-attribute instance-attribute

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

The type of model to filter by.

min_count class-attribute instance-attribute

min_count: int | None = None

Filter only models that have at least this amount of threads serving.

max_count class-attribute instance-attribute

max_count: int | None = None

Filter only models that have at most this amount of threads serving.

model_state class-attribute instance-attribute

model_state: MODEL_STATE = all

If 'known', only show stats for known models in the model reference. If 'custom' only show stats for custom models. If 'all' shows stats for all models.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

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/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/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/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_status_models_all

get_default_success_response_type classmethod

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

get_query_fields classmethod

get_query_fields() -> list[str]
Source code in horde_sdk/ai_horde_api/apimodels/status.py
@override
@classmethod
def get_query_fields(cls) -> list[str]:
    return ["type_", "min_count", "max_count"]

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_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

HordeStatusModelsSingleResponse

Bases: HordeResponseRootModel[list[ActiveModel]]

A list of details about a single active model in the horde.

Represents the data returned from the /v2/status/models/{model_name} endpoint with http status code 200.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
@Unhashable
@Unequatable
class HordeStatusModelsSingleResponse(HordeResponseRootModel[list[ActiveModel]]):
    """A list of details about a single active model in the horde.

    Represents the data returned from the /v2/status/models/{model_name} endpoint with http status code 200.
    """

    # This is a list because of an oversight in the structure of the API response. # FIXME

    root: list[ActiveModel]
    """The underlying list of models."""

    def __iter__(self) -> Iterator[ActiveModel]:  # type: ignore
        return iter(self.root)

    def __getitem__(self, index: int) -> ActiveModel:
        return self.root[index]

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

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, HordeStatusModelsSingleResponse):
            return False
        return all(model in other.root for model in self.root)

root instance-attribute

root: list[ActiveModel]

The underlying list of models.

time_constructed property

time_constructed: float

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

model_config class-attribute instance-attribute

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

__iter__

__iter__() -> Iterator[ActiveModel]
Source code in horde_sdk/ai_horde_api/apimodels/status.py
def __iter__(self) -> Iterator[ActiveModel]:  # type: ignore
    return iter(self.root)

__getitem__

__getitem__(index: int) -> ActiveModel
Source code in horde_sdk/ai_horde_api/apimodels/status.py
def __getitem__(self, index: int) -> ActiveModel:
    return self.root[index]

get_api_model_name classmethod

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

__eq__

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

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
    }

HordeStatusModelsSingleRequest

Bases: BaseAIHordeRequest

Request details about a single model in the horde by its name.

Represents a GET request to the /v2/status/models/{model_name} endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class HordeStatusModelsSingleRequest(BaseAIHordeRequest):
    """Request details about a single model in the horde by its name.

    Represents a GET request to the /v2/status/models/{model_name} endpoint.
    """

    model_name: str
    """The name of the model to request."""

    @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_status_models_single

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

model_name instance-attribute

model_name: str

The name of the model to request.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

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/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/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/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_status_models_single

get_default_success_response_type classmethod

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

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

HordeModes

Bases: HordeAPIObjectBaseModel

The current modes of the horde, such as maintenance mode, invite-only mode, and raid mode.

v2 API Model: HordeModes

Source code in horde_sdk/ai_horde_api/apimodels/status.py
class HordeModes(HordeAPIObjectBaseModel):
    """The current modes of the horde, such as maintenance mode, invite-only mode, and raid mode.

    v2 API Model: `HordeModes`
    """

    maintenance_mode: bool = Field(
        default=False,
    )
    """Whether the horde is in maintenance mode."""

    invite_only_mode: bool = Field(
        default=False,
    )
    """Whether the horde is in invite-only mode."""

    raid_mode: bool = Field(
        default=False,
    )
    """Whether the horde is in raid mode."""

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

maintenance_mode class-attribute instance-attribute

maintenance_mode: bool = Field(default=False)

Whether the horde is in maintenance mode.

invite_only_mode class-attribute instance-attribute

invite_only_mode: bool = Field(default=False)

Whether the horde is in invite-only mode.

raid_mode class-attribute instance-attribute

raid_mode: bool = Field(default=False)

Whether the horde is in raid mode.

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/status.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "HordeModes"

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
    }