base
The base classes for all AI Horde API requests/responses.
__all__
module-attribute
__all__ = [
"ActiveModel",
"ActiveModelLite",
"BaseAIHordeRequest",
"ExtraSourceImageEntry",
"ExtraTextEntry",
"GenMetadataEntry",
"ImageGenerateParamMixin",
"JobRequestMixin",
"JobResponseMixin",
"JobSubmitResponse",
"LorasPayloadEntry",
"MessageSpecifiesSharedKeyMixin",
"SingleWarningEntry",
"TIPayloadEntry",
"WorkerRequestMixin",
"WorkerRequestNameMixin",
"_BaseImageGenerateParamMixin",
]
BaseAIHordeRequest
Bases: HordeRequest
Base class for all AI Horde API requests.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
model_config
class-attribute
instance-attribute
accept
class-attribute
instance-attribute
The 'accept' header field.
client_agent
class-attribute
instance-attribute
The requesting client's agent. You should set this to reflect the name, version and contact information for your client.
get_api_url
classmethod
get_api_model_name
abstractmethod
classmethod
Return the name of the model as seen in the published swagger doc.
If none, there is no payload, such as for a GET request.
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
get_http_method
abstractmethod
classmethod
get_api_endpoint_url
classmethod
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
get_api_endpoint_subpath
abstractmethod
classmethod
Return the subpath to the specific API action defined by this object.
get_default_success_response_type
abstractmethod
classmethod
Return the type of the response expected in the ordinary case of success.
get_success_status_response_pairs
classmethod
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
get_header_fields
classmethod
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
get_query_fields
classmethod
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
get_number_of_results_expected
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
get_requires_follow_up
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
JobRequestMixin
Bases: HordeAPIData
Mix-in class for data relating to any generation jobs.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
id_
class-attribute
instance-attribute
The UUID for this job. Use this to post the results in the future.
model_config
class-attribute
instance-attribute
validate_id
Ensure that the job ID is not empty.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
__eq__
JobResponseMixin
Bases: HordeAPIData
Mix-in class for data relating to any generation jobs.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
model_config
class-attribute
instance-attribute
validate_id
Ensure that the job ID is not empty.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
WorkerRequestMixin
Bases: HordeAPIData
Mix-in class for data relating to worker requests.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
WorkerRequestNameMixin
Bases: HordeAPIData
Mix-in class for data relating to worker requests.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
LorasPayloadEntry
Bases: HordeAPIObjectBaseModel
Represents a single lora parameter.
v2 API Model: ModelPayloadLorasStable
Source code in horde_sdk/ai_horde_api/apimodels/base.py
name
class-attribute
instance-attribute
The name of the LoRa model to use.
model
class-attribute
instance-attribute
The strength of the LoRa against the stable diffusion model.
clip
class-attribute
instance-attribute
The strength of the LoRa against the clip model.
inject_trigger
class-attribute
instance-attribute
Any trigger required to activate the LoRa model.
is_version
class-attribute
instance-attribute
If true, will treat the lora name as a version ID.
model_config
class-attribute
instance-attribute
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
TIPayloadEntry
Bases: HordeAPIObjectBaseModel
Represents a single textual inversion (embedding) parameter.
v2 API Model: ModelPayloadTextualInversionsStable
Source code in horde_sdk/ai_horde_api/apimodels/base.py
name
class-attribute
instance-attribute
The name or ID of the textual inversion model to use.
inject_ti
class-attribute
instance-attribute
Whether to automatically insert the TI into the prompt or negprompt.
strength
class-attribute
instance-attribute
The strength to apply the textual inversion model.
model_config
class-attribute
instance-attribute
validate_inject_ti
Ensure that the inject_ti is either 'prompt' or 'negprompt'.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
validate_strength
Ensure that the strength is non-zero.
strength_only_if_inject_ti
Ensure that the strength is only set if the inject_ti is set.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
ExtraSourceImageEntry
Bases: HordeAPIObjectBaseModel
Represents a single extra source image.
v2 API Model: ExtraSourceImage
Source code in horde_sdk/ai_horde_api/apimodels/base.py
original_url
class-attribute
instance-attribute
The URL of the original image after it was downloaded.
image
class-attribute
instance-attribute
The URL of the image to download, or the base64 string once downloaded.
strength
class-attribute
instance-attribute
The strength to apply to this image on various operations.
model_config
class-attribute
instance-attribute
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
ExtraTextEntry
Bases: HordeAPIObjectBaseModel
Represents a single extra text.
v2 API Model: ExtraText
Source code in horde_sdk/ai_horde_api/apimodels/base.py
text
class-attribute
instance-attribute
Extra text required for this generation.
reference
class-attribute
instance-attribute
Reference pointing to how this text is to be used.
model_config
class-attribute
instance-attribute
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
SingleWarningEntry
Bases: HordeAPIObjectBaseModel
Represents a single warning.
v2 API Model: RequestSingleWarning
Source code in horde_sdk/ai_horde_api/apimodels/base.py
code
class-attribute
instance-attribute
The code uniquely identifying this warning.
message
class-attribute
instance-attribute
The human-readable description of this warning
model_config
class-attribute
instance-attribute
code_must_be_known
Ensure that the warning code is in this list of supported warning codes.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
ImageGenerateParamMixin
Bases: _BaseImageGenerateParamMixin
Contains basic and api-specific parameters for image generation.
v2 API Model: ModelPayloadRootStable
Source code in horde_sdk/ai_horde_api/apimodels/base.py
model_config
class-attribute
instance-attribute
model_config = (
ConfigDict(frozen=True, extra="allow")
if not getenv("TESTS_ONGOING")
else ConfigDict(frozen=True, extra="forbid")
)
seed
class-attribute
instance-attribute
The seed to use for this generation. If not provided, a random seed will be used.
seed_variation
class-attribute
instance-attribute
Deprecated.
control_type
class-attribute
instance-attribute
The type of control net type to use.
image_is_control
class-attribute
instance-attribute
Set to True if the image is a control image.
return_control_map
class-attribute
instance-attribute
Set to True if you want the ControlNet map returned instead of a generated image.
extra_texts
class-attribute
instance-attribute
A list of extra texts and prompts to use in the comfyUI workflow.
use_nsfw_censor
class-attribute
instance-attribute
If the request is SFW, and the worker accidentally generates NSFW, it will send back a censored image.
height
class-attribute
instance-attribute
The desired output image height.
width
class-attribute
instance-attribute
The desired output image width.
sampler_name
class-attribute
instance-attribute
The sampler to use for this generation. Defaults to KNOWN_IMAGE_SAMPLERS.k_lms.
karras
class-attribute
instance-attribute
Set to True if you want to use the Karras scheduling.
cfg_scale
class-attribute
instance-attribute
The cfg_scale to use for this generation. Defaults to 7.5.
denoising_strength
class-attribute
instance-attribute
The denoising strength to use for this generation. Defaults to 1.
clip_skip
class-attribute
instance-attribute
The number of clip layers to skip.
post_processing
class-attribute
instance-attribute
post_processing: list[
str
| KNOWN_UPSCALERS
| KNOWN_FACEFIXERS
| KNOWN_MISC_POST_PROCESSORS
] = Field(default_factory=list)
A list of post-processing models to use.
post_processing_order
class-attribute
instance-attribute
The order in which to apply post-processing models. Applying upscalers or removing backgrounds before facefixers costs less kudos.
facefixer_strength
class-attribute
instance-attribute
The strength of the facefixer model.
hires_fix
class-attribute
instance-attribute
Set to True if you want to use the hires fix.
hires_fix_denoising_strength
class-attribute
instance-attribute
The strength of the denoising for the hires fix second pass.
loras
class-attribute
instance-attribute
A list of lora parameters to use.
tis
class-attribute
instance-attribute
A list of textual inversion (embedding) parameters to use.
workflow
class-attribute
instance-attribute
The specific comfyUI workflow to use.
transparent
class-attribute
instance-attribute
When true, will generate an image with a transparent background
tiling
class-attribute
instance-attribute
Set to True if you want to use seamless tiling.
special
class-attribute
instance-attribute
Reserved for future use.
get_api_model_name
classmethod
random_seed_if_none
If the seed is None, generate a random seed.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
control_type_must_be_known
control_type_must_be_known(
v: str | KNOWN_IMAGE_CONTROLNETS | None,
) -> str | KNOWN_IMAGE_CONTROLNETS | None
Ensure that the control type is in this list of supported control types.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
post_processors_must_be_known
post_processors_must_be_known(
v: list[
str
| KNOWN_UPSCALERS
| KNOWN_FACEFIXERS
| KNOWN_MISC_POST_PROCESSORS
],
) -> list[
str
| KNOWN_UPSCALERS
| KNOWN_FACEFIXERS
| KNOWN_MISC_POST_PROCESSORS
]
Ensure that the post processors are in this list of supported post processors.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
sampler_name_must_be_known
Ensure that the sampler name is in this list of supported samplers.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
JobSubmitResponse
Bases: HordeResponseBaseModel
Indicates that a generation job was successfully submitted and the amount of kudos gained.
Represents the data returned from the following endpoints and http status codes
- /v2/generate/text/submit | TextGenerationJobSubmitRequest [POST] -> 200
- /v2/generate/submit | ImageGenerationJobSubmitRequest [POST] -> 200
v2 API Model: GenerationSubmitted
Source code in horde_sdk/ai_horde_api/apimodels/base.py
time_constructed
property
The time the model was constructed (in epoch time).
model_config
class-attribute
instance-attribute
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
GenMetadataEntry
Bases: HordeAPIObjectBaseModel
Represents a single generation metadata entry.
v2 API Model: GenerationMetadataStable
Source code in horde_sdk/ai_horde_api/apimodels/base.py
type_
class-attribute
instance-attribute
The relevance of the metadata field.
value
class-attribute
instance-attribute
The value of the metadata field.
ref
class-attribute
instance-attribute
Optionally a reference for the metadata (e.g. a lora ID)
model_config
class-attribute
instance-attribute
validate_type
Ensure that the type is in this list of supported types.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
validate_value
Ensure that the value is in this list of supported values.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
MessageSpecifiesSharedKeyMixin
Bases: HordeAPIData
Mix-in class to describe an endpoint for which you can specify a shared key.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
sharedkey_id
class-attribute
instance-attribute
The shared key ID to use for this request.
model_config
class-attribute
instance-attribute
validate_sharedkey_id
Ensure that the shared key ID is not empty.
Source code in horde_sdk/ai_horde_api/apimodels/base.py
ActiveModelLite
Bases: HordeAPIObjectBaseModel
Represents a single active model.
v2 API Model: ActiveModelLite
Source code in horde_sdk/ai_horde_api/apimodels/base.py
count
class-attribute
instance-attribute
How many of workers in this horde are running this model.
name
class-attribute
instance-attribute
The Name of a model available by workers in this horde.
model_config
class-attribute
instance-attribute
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.
Source code in horde_sdk/generic_api/apimodels.py
ActiveModel
Bases: ActiveModelLite
Represents a single active model.
v2 API Model: ActiveModel
Source code in horde_sdk/ai_horde_api/apimodels/base.py
eta
class-attribute
instance-attribute
Estimated time in seconds for this model's queue to be cleared.
jobs
class-attribute
instance-attribute
The job count waiting to be generated by this model.
performance
class-attribute
instance-attribute
The average speed of generation for this model.
queued
class-attribute
instance-attribute
The amount waiting to be generated by this model.
type_
class-attribute
instance-attribute
The model type (text or image).
model_config
class-attribute
instance-attribute
count
class-attribute
instance-attribute
How many of workers in this horde are running this model.
name
class-attribute
instance-attribute
The Name of a model available by workers in this horde.
get_api_model_name
classmethod
get_sensitive_fields
classmethod
get_extra_fields_to_exclude_from_log
Return an additional set of fields to exclude from the log_safe_model_dump method.
log_safe_model_dump
Return a dict of the model's fields, with any sensitive fields redacted.