horde_api_models
Pydantic models for AI Horde public API responses.
API Documentation: https://aihorde.net/api/
HordeWorkerType
module-attribute
HordeModelStatus
Bases: BaseModel
Model status from Horde API status endpoint.
Source code in src/horde_model_reference/integrations/horde_api_models.py
HordeModelStatsResponse
Bases: BaseModel
Model statistics from Horde API stats endpoint.
Source code in src/horde_model_reference/integrations/horde_api_models.py
day
class-attribute
instance-attribute
day: dict[str, int] = Field(
default_factory=dict,
description="Statistics for the past day (model_name -> count)",
)
HordeTotalStatsTimePeriod
Bases: BaseModel
Statistics for a specific time period.
Source code in src/horde_model_reference/integrations/horde_api_models.py
images
class-attribute
instance-attribute
images: int | None = Field(
default=None,
description="Number of images generated (for image type)",
)
requests
class-attribute
instance-attribute
HordeTotalStatsResponse
Bases: BaseModel
Total statistics across all models from Horde API.
Source code in src/horde_model_reference/integrations/horde_api_models.py
minute
class-attribute
instance-attribute
minute: HordeTotalStatsTimePeriod = Field(
default_factory=HordeTotalStatsTimePeriod,
description="Statistics for the past minute",
)
hour
class-attribute
instance-attribute
hour: HordeTotalStatsTimePeriod = Field(
default_factory=HordeTotalStatsTimePeriod,
description="Statistics for the past hour",
)
day
class-attribute
instance-attribute
day: HordeTotalStatsTimePeriod = Field(
default_factory=HordeTotalStatsTimePeriod,
description="Statistics for the past day",
)
HordeModelUsageStats
Bases: BaseModel
Usage statistics for a specific model.
Source code in src/horde_model_reference/integrations/horde_api_models.py
minute
class-attribute
instance-attribute
hour
class-attribute
instance-attribute
month
class-attribute
instance-attribute
BackendVariation
Bases: BaseModel
Per-backend statistics for a text generation model variant.
This tracks statistics for a specific backend (e.g., 'aphrodite' or 'koboldcpp') serving a particular model. Used to show backend-specific details in the UI while still providing aggregated totals at the model level.
Source code in src/horde_model_reference/integrations/horde_api_models.py
backend
class-attribute
instance-attribute
backend: str = Field(
description="Backend name (e.g., 'aphrodite', 'koboldcpp', or 'canonical' for non-prefixed)"
)
variant_name
class-attribute
instance-attribute
variant_name: str = Field(
description="Full model name as reported by Horde API (may include backend prefix)"
)
worker_count
class-attribute
instance-attribute
performance
class-attribute
instance-attribute
performance: float | None = Field(
default=None,
description="Performance metric for this variant",
)
queued
class-attribute
instance-attribute
queued: int | None = Field(
default=None,
description="Number of queued requests for this variant",
)
queued_jobs
class-attribute
instance-attribute
queued_jobs: int | None = Field(
default=None,
description="Number of active jobs for this variant",
)
eta
class-attribute
instance-attribute
eta: int | None = Field(
default=None,
description="Estimated time to completion for this variant",
)
usage_day
class-attribute
instance-attribute
usage_month
class-attribute
instance-attribute
HordeWorkerTeam
Bases: BaseModel
Worker team information.
Source code in src/horde_model_reference/integrations/horde_api_models.py
HordeKudosDetails
Bases: BaseModel
Kudos breakdown by source.
Source code in src/horde_model_reference/integrations/horde_api_models.py
IndexedHordeModelStatus
Bases: RootModel[dict[str, HordeModelStatus]]
Indexed model status for O(1) lookups by model name.
This wraps the status list and provides case-insensitive dictionary access. Time complexity: O(1) for lookups instead of O(n) for list iteration.
Usage
indexed = IndexedHordeModelStatus([status1, status2, ...]) status = indexed.get("model_name") # Case-insensitive lookup all_statuses = indexed.get_all() # Get all as list
Source code in src/horde_model_reference/integrations/horde_api_models.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
__init__
Build indexed lookup from status list.
Parameters:
-
status_list(list[HordeModelStatus]) –List of HordeModelStatus from API
Source code in src/horde_model_reference/integrations/horde_api_models.py
get
Get status for a model by name (case-insensitive).
Time Complexity: O(1)
Parameters:
-
model_name(str) –Model name to look up
Returns:
-
HordeModelStatus | None–HordeModelStatus if found, None otherwise
Source code in src/horde_model_reference/integrations/horde_api_models.py
get_all
Get all status entries as a list.
Returns:
-
list[HordeModelStatus]–List of all HordeModelStatus objects
get_aggregated_status
Get aggregated status across all backend variants of a model.
This method aggregates status from all possible backend-prefixed variants, taking the maximum worker count (count field) and the first non-None value for other fields.
Parameters:
-
canonical_name(str) –The canonical model name from the model reference.
Returns:
-
HordeModelStatus | None–Aggregated HordeModelStatus or None if no variants have status.
Source code in src/horde_model_reference/integrations/horde_api_models.py
get_status_with_variations
get_status_with_variations(
canonical_name: str,
) -> tuple[
HordeModelStatus | None, dict[str, HordeModelStatus]
]
Get aggregated status and individual backend variations.
This method returns both the aggregated status (same as get_aggregated_status) and a dictionary of individual backend statuses keyed by backend name.
Parameters:
-
canonical_name(str) –The canonical model name from the model reference.
Returns:
-
HordeModelStatus | None–Tuple of (aggregated_status, variations_dict) where:
-
dict[str, HordeModelStatus]–- aggregated_status: Combined status or None if no variants found
-
tuple[HordeModelStatus | None, dict[str, HordeModelStatus]]–- variations_dict: Dict of backend_name -> HordeModelStatus Keys are 'canonical', 'aphrodite', 'koboldcpp' depending on what's found
Source code in src/horde_model_reference/integrations/horde_api_models.py
_StatsLookup
Bases: BaseModel
Internal structure for indexed stats lookups.
Source code in src/horde_model_reference/integrations/horde_api_models.py
IndexedHordeModelStats
Bases: RootModel[_StatsLookup]
Indexed model stats for O(1) lookups by model name.
This wraps the stats response and provides case-insensitive dictionary access. Time complexity: O(1) for lookups instead of O(n) for dict iteration.
Two indexes are built: - _base_name_index: Groups ALL variants (including different sizes) for group-level aggregation - _model_with_size_index: Groups only quantization variants for per-model stats
Usage
indexed = IndexedHordeModelStats(stats_response) day_count = indexed.get_day("model_name") # Case-insensitive has_data = indexed.has_stats("model_name") # Check existence
Source code in src/horde_model_reference/integrations/horde_api_models.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
_base_name_index
class-attribute
instance-attribute
_model_with_size_index
class-attribute
instance-attribute
__init__
Build indexed lookups from stats response.
Parameters:
-
stats_response(HordeModelStatsResponse) –HordeModelStatsResponse from API
Source code in src/horde_model_reference/integrations/horde_api_models.py
get_day
get_month
get_total
has_stats
Check if model has any stats (case-insensitive). O(1).
Source code in src/horde_model_reference/integrations/horde_api_models.py
get_aggregated_stats
Get aggregated stats across all backend variants and quantization versions of a model.
This method aggregates stats from: - Exact name variants (canonical, aphrodite/, koboldcpp/ prefixed) - All quantization variants sharing the same base model name (Q4_K_M, Q8_0, etc.) - Different org-prefixed variants (e.g., "NeverSleep/Lumimaid" matches "Lumimaid")
Parameters:
-
canonical_name(str) –The canonical model name from the model reference.
Returns:
-
tuple[int, int, int]–Tuple of (day_total, month_total, total_total) aggregated across all variants.
Example
indexed = IndexedHordeModelStats(stats_response) day, month, total = indexed.get_aggregated_stats("Lumimaid-v0.2-8B")
Will aggregate: Lumimaid-v0.2-8B, koboldcpp/Lumimaid-v0.2-8B,
koboldcpp/Lumimaid-v0.2-8B-Q8_0, aphrodite/NeverSleep/Lumimaid-v0.2-8B, etc.
Source code in src/horde_model_reference/integrations/horde_api_models.py
get_stats_with_variations
get_stats_with_variations(
canonical_name: str,
) -> tuple[
tuple[int, int, int], dict[str, tuple[int, int, int]]
]
Get stats for a specific model broken down by backend.
Unlike get_aggregated_stats which aggregates across all models with the same base name (e.g., all Lumimaid-v0.2 sizes), this method returns stats only for the exact model specified (including its quantization variants), broken down by backend prefix.
This enables showing per-model stats in the UI when displaying grouped models, where each model variant (8B, 12B, etc.) shows its own stats by backend.
Parameters:
-
canonical_name(str) –The canonical model name from the model reference.
Returns:
-
tuple[int, int, int]–Tuple of (aggregated_stats, variations_dict) where:
-
dict[str, tuple[int, int, int]]–- aggregated_stats: (day_total, month_total, total_total) for this exact model
-
tuple[tuple[int, int, int], dict[str, tuple[int, int, int]]]–- variations_dict: Dict of backend_name -> (day, month, total) Keys are 'canonical', 'aphrodite', 'koboldcpp' depending on what's found
Source code in src/horde_model_reference/integrations/horde_api_models.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
HordeWorker
Bases: BaseModel
Worker information from Horde API.
This is a simplified model that captures the common fields needed for merging. The API returns additional type-specific fields that aren't needed for basic integration.
Source code in src/horde_model_reference/integrations/horde_api_models.py
type
class-attribute
instance-attribute
performance
class-attribute
instance-attribute
requests_fulfilled
class-attribute
instance-attribute
kudos_rewards
class-attribute
instance-attribute
kudos_details
class-attribute
instance-attribute
threads
class-attribute
instance-attribute
uptime
class-attribute
instance-attribute
uncompleted_jobs
class-attribute
instance-attribute
maintenance_mode
class-attribute
instance-attribute
nsfw
class-attribute
instance-attribute
trusted
class-attribute
instance-attribute
flagged
class-attribute
instance-attribute
online
class-attribute
instance-attribute
models
class-attribute
instance-attribute
models: list[str] = Field(
default_factory=list,
description="List of model names this worker serves",
)
team
class-attribute
instance-attribute
bridge_agent
class-attribute
instance-attribute
max_pixels
class-attribute
instance-attribute
megapixelsteps_generated
class-attribute
instance-attribute
megapixelsteps_generated: float | None = Field(
default=None,
description="Total megapixelsteps (image workers)",
)
img2img
class-attribute
instance-attribute
painting
class-attribute
instance-attribute
lora
class-attribute
instance-attribute
controlnet
class-attribute
instance-attribute
sdxl_controlnet
class-attribute
instance-attribute
sdxl_controlnet: bool | None = Field(
default=None,
description="Supports SDXL ControlNet (image workers)",
)
max_length
class-attribute
instance-attribute
max_context_length
class-attribute
instance-attribute
max_context_length: int | None = Field(
default=None,
description="Maximum context length (text workers)",
)
info
class-attribute
instance-attribute
IndexedHordeWorkers
Bases: RootModel[dict[str, list[HordeWorker]]]
Indexed workers for O(1) lookups by model name.
This wraps the workers list and provides case-insensitive dictionary access where keys are model names and values are lists of workers serving that model. Time complexity: O(1) for lookups instead of O(w*m) iteration.
Usage
indexed = IndexedHordeWorkers([worker1, worker2, ...]) workers = indexed.get("model_name") # Case-insensitive lookup all_workers = indexed.get_all() # Get all unique workers
Source code in src/horde_model_reference/integrations/horde_api_models.py
__init__
Build indexed lookup from workers list.
Parameters:
-
workers_list(list[HordeWorker]) –List of HordeWorker from API
Source code in src/horde_model_reference/integrations/horde_api_models.py
get
Get workers for a model by name (case-insensitive).
Time Complexity: O(1)
Parameters:
-
model_name(str) –Model name to look up
Returns:
-
list[HordeWorker]–List of HordeWorker serving this model (empty list if none)
Source code in src/horde_model_reference/integrations/horde_api_models.py
get_all
Get all unique workers as a list.
Returns:
-
list[HordeWorker]–List of all HordeWorker objects (deduplicated)
Source code in src/horde_model_reference/integrations/horde_api_models.py
_strip_quantization_suffix
Strip quantization suffix from a model name, preserving size.
This is different from get_base_model_name which strips BOTH size and quantization. This function only strips quantization, keeping the size suffix.
Parameters:
-
model_name(str) –Model name potentially with quantization suffix.
Returns:
-
str–Model name without quantization suffix, but with size preserved.
Example
"Lumimaid-v0.2-8B-Q8_0" -> "Lumimaid-v0.2-8B" "Lumimaid-v0.2-8B" -> "Lumimaid-v0.2-8B" "koboldcpp/Lumimaid-v0.2-8B-Q4_K_M" -> "koboldcpp/Lumimaid-v0.2-8B"
Source code in src/horde_model_reference/integrations/horde_api_models.py
_build_base_name_index
Build an index mapping base model names to all matching model names.
This enables aggregating stats across quantization variants (e.g., Q4_K_M, Q8_0) and different backend prefixes (aphrodite/, koboldcpp/).
Parameters:
-
model_names(list[str]) –List of model names from API stats (may include backend prefixes and quantization suffixes).
Returns:
-
dict[str, list[str]]–Dictionary mapping lowercase base model names to lists of original model names
-
dict[str, list[str]]–(lowercase) that match that base.
Example
Input: ["koboldcpp/Lumimaid-v0.2-8B", "koboldcpp/Lumimaid-v0.2-8B-Q8_0", "aphrodite/NeverSleep/Lumimaid-v0.2-8B"] Output: {"lumimaid-v0.2": ["koboldcpp/lumimaid-v0.2-8b", "koboldcpp/lumimaid-v0.2-8b-q8_0", "aphrodite/neversleep/lumimaid-v0.2-8b"]}
Source code in src/horde_model_reference/integrations/horde_api_models.py
_build_model_with_size_index
Build an index mapping model names (with size, without quant) to all matching names.
This enables aggregating stats across quantization variants only (e.g., Q4_K_M, Q8_0) while keeping different sizes separate.
Unlike _build_base_name_index which groups ALL variants (including different sizes), this index only groups quantization variants of the SAME sized model.
The key normalizes: - Backend prefix (stripped for matching, but preserved in values) - Org prefix (stripped for matching) - Quantization suffix (stripped for matching)
But preserves: - Size suffix (8B, 12B, etc.)
Parameters:
-
model_names(list[str]) –List of model names from API stats (may include backend prefixes and quantization suffixes).
Returns:
-
dict[str, list[str]]–Dictionary mapping normalized model names (backend/model-size) to lists of
-
dict[str, list[str]]–original model names (lowercase) that match that model.
Example
Input: ["koboldcpp/Lumimaid-v0.2-8B", "koboldcpp/Lumimaid-v0.2-8B-Q8_0", "koboldcpp/Lumimaid-v0.2-12B", "aphrodite/NeverSleep/Lumimaid-v0.2-8B"] Output: { "koboldcpp/lumimaid-v0.2-8b": [ "koboldcpp/lumimaid-v0.2-8b", "koboldcpp/lumimaid-v0.2-8b-q8_0" ], "koboldcpp/lumimaid-v0.2-12b": ["koboldcpp/lumimaid-v0.2-12b"], "aphrodite/lumimaid-v0.2-8b": ["aphrodite/neversleep/lumimaid-v0.2-8b"] }