Skip to content

_stats

StatsModelsTimeframe

Bases: StrEnum

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class StatsModelsTimeframe(StrEnum):
    day = auto()
    month = auto()
    total = auto()

day class-attribute instance-attribute

day = auto()

month class-attribute instance-attribute

month = auto()

total class-attribute instance-attribute

total = auto()

ImageStatsModelsResponse

Bases: HordeResponseBaseModel

Represents the data returned from the /v2/stats/img/models endpoint.

v2 API Model: ImgModelStats

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
@Unequatable
@Unhashable
class ImageStatsModelsResponse(HordeResponseBaseModel):
    """Represents the data returned from the `/v2/stats/img/models` endpoint.

    v2 API Model: `ImgModelStats`
    """

    day: dict[str, int]
    """The stats for the past day."""
    month: dict[str, int]
    """The stats for the past month."""
    total: dict[str, int]
    """The total stats for all time."""

    @field_validator("day", "month", "total", mode="before")
    @classmethod
    def validate_timeframe_data(cls, v: dict[str, int | None]) -> dict[str, int]:
        """Validate the data for a timeframe.

        Args:
            v (dict[str, int | None]): The data for a timeframe.

        Raises:
            ValueError: If the data is invalid.

        Returns:
            dict[str, int]: The data for a timeframe.
        """
        if v is None:
            return {}

        if "additionalProp1" in v:
            logger.warning("Found `additionalProp` in stats data, this is a dummy result. Ignoring.")
            return {}

        return_v = {}
        # Replace all `None` values with 0
        for key, value in v.items():
            if value is None:
                return_v[key] = 0
            else:
                return_v[key] = value

        return return_v

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

    def get_timeframe(self, timeframe: StatsModelsTimeframe) -> dict[str, int]:
        """Return the data for the given timeframe.

        Args:
            timeframe (StatsModelsTimeframe): The timeframe to get the data for.

        Returns:
            dict[str, int]: The data for the given timeframe.
        """
        if timeframe == StatsModelsTimeframe.day:
            return self.day
        if timeframe == StatsModelsTimeframe.month:
            return self.month
        if timeframe == StatsModelsTimeframe.total:
            return self.total

        raise ValueError(f"Invalid timeframe: {timeframe}")

day instance-attribute

day: dict[str, int]

The stats for the past day.

month instance-attribute

month: dict[str, int]

The stats for the past month.

total instance-attribute

total: dict[str, int]

The total stats for all time.

validate_timeframe_data classmethod

validate_timeframe_data(v: dict[str, int | None]) -> dict[str, int]

Validate the data for a timeframe.

Parameters:

  • v (dict[str, int | None]) –

    The data for a timeframe.

Raises:

  • ValueError –

    If the data is invalid.

Returns:

  • dict[str, int] –

    dict[str, int]: The data for a timeframe.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
@field_validator("day", "month", "total", mode="before")
@classmethod
def validate_timeframe_data(cls, v: dict[str, int | None]) -> dict[str, int]:
    """Validate the data for a timeframe.

    Args:
        v (dict[str, int | None]): The data for a timeframe.

    Raises:
        ValueError: If the data is invalid.

    Returns:
        dict[str, int]: The data for a timeframe.
    """
    if v is None:
        return {}

    if "additionalProp1" in v:
        logger.warning("Found `additionalProp` in stats data, this is a dummy result. Ignoring.")
        return {}

    return_v = {}
    # Replace all `None` values with 0
    for key, value in v.items():
        if value is None:
            return_v[key] = 0
        else:
            return_v[key] = value

    return return_v

get_api_model_name classmethod

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

get_timeframe

get_timeframe(timeframe: StatsModelsTimeframe) -> dict[str, int]

Return the data for the given timeframe.

Parameters:

Returns:

  • dict[str, int] –

    dict[str, int]: The data for the given timeframe.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
def get_timeframe(self, timeframe: StatsModelsTimeframe) -> dict[str, int]:
    """Return the data for the given timeframe.

    Args:
        timeframe (StatsModelsTimeframe): The timeframe to get the data for.

    Returns:
        dict[str, int]: The data for the given timeframe.
    """
    if timeframe == StatsModelsTimeframe.day:
        return self.day
    if timeframe == StatsModelsTimeframe.month:
        return self.month
    if timeframe == StatsModelsTimeframe.total:
        return self.total

    raise ValueError(f"Invalid timeframe: {timeframe}")

ImageStatsModelsRequest

Bases: BaseAIHordeRequest

Represents the data needed to make a request to the /v2/stats/img/models endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class ImageStatsModelsRequest(BaseAIHordeRequest):
    """Represents the data needed to make a request to the `/v2/stats/img/models` endpoint."""

    model_config = ConfigDict(
        protected_namespaces=(),  # Allows the "model_" prefix on attrs
    )

    model_state: MODEL_STATE = Field(
        default=MODEL_STATE.all,
    )
    """The state of the models to get stats for. Known models are models that are known to the system."""

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

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

model_config class-attribute instance-attribute

model_config = ConfigDict(protected_namespaces=())

model_state class-attribute instance-attribute

model_state: MODEL_STATE = Field(default=all)

The state of the models to get stats for. Known models are models that are known to the system.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/_stats.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/_stats.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/_stats.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_stats_img_models

get_default_success_response_type classmethod

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

SinglePeriodImgStat

Bases: HordeAPIObjectBaseModel

Represents the stats for a single period of image generation.

v2 API Model: SinglePeriodImgStat

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class SinglePeriodImgStat(HordeAPIObjectBaseModel):
    """Represents the stats for a single period of image generation.

    v2 API Model: `SinglePeriodImgStat`
    """

    images: int | None = Field(
        default=None,
    )
    """The amount of images generated during this period."""
    ps: int | None = Field(
        default=None,
    )
    """The amount of pixelsteps generated during this period."""

    @property
    def mps(self) -> int | None:
        """The amount of megapixelsteps generated during this period."""
        if self.ps is None:
            return None

        return self.ps // 1_000_000

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

images class-attribute instance-attribute

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

The amount of images generated during this period.

ps class-attribute instance-attribute

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

The amount of pixelsteps generated during this period.

mps property

mps: int | None

The amount of megapixelsteps generated during this period.

get_api_model_name classmethod

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

ImageStatsModelsTotalResponse

Bases: HordeResponseBaseModel

Represents the data returned from the /v2/stats/img/totals endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class ImageStatsModelsTotalResponse(HordeResponseBaseModel):
    """Represents the data returned from the `/v2/stats/img/totals` endpoint."""

    day: SinglePeriodImgStat | None = None
    """The total stats for the past day."""
    hour: SinglePeriodImgStat | None = None
    """The total stats for the past hour."""
    minute: SinglePeriodImgStat | None = None
    """The total stats for the past minute."""
    month: SinglePeriodImgStat | None = None
    """The total stats for the past month."""
    total: SinglePeriodImgStat | None = None
    """The total stats for all time."""

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

day class-attribute instance-attribute

day: SinglePeriodImgStat | None = None

The total stats for the past day.

hour class-attribute instance-attribute

hour: SinglePeriodImgStat | None = None

The total stats for the past hour.

minute class-attribute instance-attribute

minute: SinglePeriodImgStat | None = None

The total stats for the past minute.

month class-attribute instance-attribute

month: SinglePeriodImgStat | None = None

The total stats for the past month.

total class-attribute instance-attribute

total: SinglePeriodImgStat | None = None

The total stats for all time.

get_api_model_name classmethod

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

ImageStatsModelsTotalRequest

Bases: BaseAIHordeRequest

Represents the data needed to make a request to the /v2/stats/img/totals endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class ImageStatsModelsTotalRequest(BaseAIHordeRequest):
    """Represents the data needed to make a request to the `/v2/stats/img/totals` 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_stats_img_totals

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

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/_stats.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/_stats.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/_stats.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_stats_img_totals

get_default_success_response_type classmethod

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

TextStatsModelResponse

Bases: HordeResponseBaseModel

Represents the data returned from the /v2/stats/text/models endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
@Unhashable
class TextStatsModelResponse(HordeResponseBaseModel):
    """Represents the data returned from the `/v2/stats/text/models` endpoint."""

    day: dict[str, int]
    """The stats for the past day."""
    month: dict[str, int]
    """The stats for the past month."""
    total: dict[str, int]
    """The total stats for all time."""

    @field_validator("day", "month", "total", mode="before")
    @classmethod
    def validate_timeframe_data(cls, v: dict[str, int | None]) -> dict[str, int]:
        """Validate the data for a timeframe.

        Args:
            v (dict[str, int | None]): The data for a timeframe.

        Raises:
            ValueError: If the data is invalid.

        Returns:
            dict[str, int]: The data for a timeframe.
        """
        if v is None:
            return {}

        return_v = {}
        # Replace all `None` values with 0
        for key, value in v.items():
            if value is None:
                return_v[key] = 0
            else:
                return_v[key] = value

        return return_v

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

day instance-attribute

day: dict[str, int]

The stats for the past day.

month instance-attribute

month: dict[str, int]

The stats for the past month.

total instance-attribute

total: dict[str, int]

The total stats for all time.

validate_timeframe_data classmethod

validate_timeframe_data(v: dict[str, int | None]) -> dict[str, int]

Validate the data for a timeframe.

Parameters:

  • v (dict[str, int | None]) –

    The data for a timeframe.

Raises:

  • ValueError –

    If the data is invalid.

Returns:

  • dict[str, int] –

    dict[str, int]: The data for a timeframe.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
@field_validator("day", "month", "total", mode="before")
@classmethod
def validate_timeframe_data(cls, v: dict[str, int | None]) -> dict[str, int]:
    """Validate the data for a timeframe.

    Args:
        v (dict[str, int | None]): The data for a timeframe.

    Raises:
        ValueError: If the data is invalid.

    Returns:
        dict[str, int]: The data for a timeframe.
    """
    if v is None:
        return {}

    return_v = {}
    # Replace all `None` values with 0
    for key, value in v.items():
        if value is None:
            return_v[key] = 0
        else:
            return_v[key] = value

    return return_v

get_api_model_name classmethod

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

TextStatsModelsRequest

Bases: BaseAIHordeRequest

Represents the data needed to make a request to the /v2/stats/text/models endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class TextStatsModelsRequest(BaseAIHordeRequest):
    """Represents the data needed to make a request to the `/v2/stats/text/models` 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_stats_text_models

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

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/_stats.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/_stats.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/_stats.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_stats_text_models

get_default_success_response_type classmethod

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

SinglePeriodTxtStat

Bases: HordeAPIObjectBaseModel

Represents the stats for a single period.

v2 API Model: SinglePeriodTxtStat

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class SinglePeriodTxtStat(HordeAPIObjectBaseModel):
    """Represents the stats for a single period.

    v2 API Model: `SinglePeriodTxtStat`
    """

    requests: int | None = Field(
        default=None,
    )
    """The number of requests made during this period."""
    tokens: int | None = Field(
        default=None,
    )
    """The number of tokens generated during this period."""

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

requests class-attribute instance-attribute

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

The number of requests made during this period.

tokens class-attribute instance-attribute

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

The number of tokens generated during this period.

get_api_model_name classmethod

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

TextStatsModelsTotalResponse

Bases: HordeResponseBaseModel

Represents the data returned from the /v2/stats/text/totals endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
@Unhashable
class TextStatsModelsTotalResponse(HordeResponseBaseModel):
    """Represents the data returned from the `/v2/stats/text/totals` endpoint."""

    minute: dict[str, int]
    """The total stats for the past minute."""
    hour: dict[str, int]
    """The total stats for the past hour."""
    day: dict[str, int]
    """The total stats for the past day."""
    month: dict[str, int]
    """The total stats for the past month."""
    total: dict[str, int]
    """The total stats for all time."""

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

minute instance-attribute

minute: dict[str, int]

The total stats for the past minute.

hour instance-attribute

hour: dict[str, int]

The total stats for the past hour.

day instance-attribute

day: dict[str, int]

The total stats for the past day.

month instance-attribute

month: dict[str, int]

The total stats for the past month.

total instance-attribute

total: dict[str, int]

The total stats for all time.

get_api_model_name classmethod

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

TextStatsModelsTotalRequest

Bases: BaseAIHordeRequest

Represents the data needed to make a request to the /v2/stats/text/totals endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/_stats.py
class TextStatsModelsTotalRequest(BaseAIHordeRequest):
    """Represents the data needed to make a request to the `/v2/stats/text/totals` 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_stats_text_totals

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

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/_stats.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/_stats.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/_stats.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_stats_text_totals

get_default_success_response_type classmethod

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