aipg_horde
Version:
A package to interact with the ai horde API
1,081 lines • 101 kB
TypeScript
import SuperMap from "@thunder04/supermap";
export declare const ErrorMessages: Readonly<{
readonly MissingPrompt: "The generation prompt was not given";
readonly CorruptPrompt: "The prompts was rejected as unethical";
readonly KudosValidationError: "Something went wrong when transferring kudos. This is a base rc, so you should never typically see it.";
readonly NoValidActions: "Something went wrong when modifying an entity on the horde. This is a base rc, so you should never typically see it.";
readonly InvalidSize: "Requested image size is not a multiple of 64";
readonly InvalidPromptSize: "Prompt is too large";
readonly TooManySteps: "Too many steps requested for image generation";
readonly Profanity: "Profanity Detected. This is a base rc, so you should never typically see i";
readonly ProfaneWorkerName: "Profanity detected in worker name";
readonly ProfaneBridgeAgent: "Profanity detected in bridge agent";
readonly ProfaneWorkerInfo: "Profanity detected in worker info";
readonly ProfaneUserName: "Profanity detected in username";
readonly ProfaneUserContact: "Profanity detected in user contact details";
readonly ProfaneAdminComment: "Profanity detected in admin comment";
readonly ProfaneTeamName: "Profanity detected in team name";
readonly ProfaneTeamInfo: "Profanity detected in team info";
readonly TooLong: "Provided string was too long. This is a base rc, so you should never typically see it.";
readonly TooLongWorkerName: "The provided worker name is too long";
readonly TooLongUserName: "The provided username is too long";
readonly NameAlreadyExists: "The provided name already exists. This is a base rc, so you should never typically see it.";
readonly WorkerNameAlreadyExists: "The provided worker name already exists";
readonly TeamNameAlreadyExists: "The provided team name already exists";
readonly PolymorphicNameConflict: "The provided worker name already exists for a different worker type (e.g. Dreamer VS Scribe)";
readonly ImageValidationFailed: "Source image validation failed unexpectedly";
readonly SourceImageResolutionExceeded: "Source image resolution larger than the max allowed by the AI Horde";
readonly SourceImageSizeExceeded: "Source image file size larger than the max allowed by the AI Horde";
readonly SourceImageUrlInvalid: "Source image url does not contain an image";
readonly SourceImageUnreadable: "Source image could not be parsed";
readonly InpaintingMissingMask: "Missing mask or alpha channel for inpainting";
readonly SourceMaskUnnecessary: "Source mask sent without a source image";
readonly UnsupportedSampler: "Selected sampler unsupported with selected model";
readonly UnsupportedModel: "The required model name is unsupported with this payload. This is a base rc, so you should never typically see it.";
readonly ControlNetUnsupported: "ControlNet is unsupported in combination with this model";
readonly ControlNetSourceMissing: "Missing source image for ControlNet workflow";
readonly ControlNetInvalidPayload: "sent CN source and requested CN source at the same time";
readonly SourceImageRequiredForModel: "Source image is required for using this model";
readonly UnexpectedModelName: "Model name sent is not a Stable Diffusion checkpoint";
readonly TooManyUpscalers: "Tried to use more than 1 upscaler at a time";
readonly ProcGenNotFound: "The used generation for aesthetic ratings doesn't exist";
readonly InvalidAestheticAttempt: "Aesthetics rating attempt failed";
readonly AestheticsNotCompleted: "Attempted to rate non-completed request";
readonly AestheticsNotPublic: "Attempted to rate non-shared request";
readonly AestheticsDuplicate: "Sent duplicate images in an aesthetics set";
readonly AestheticsMissing: "Aesthetic ratings missing";
readonly AestheticsSolo: "Aesthetic ratings best-of contain a single image";
readonly AestheticsConfused: "The best image is not the one with the highest aesthetic rating";
readonly AestheticsAlreadyExist: "Aesthetic rating already submitted";
readonly AestheticsServerRejected: "Aesthetic server rejected submission";
readonly AestheticsServerError: "Aesthetic server returned error (provided)";
readonly AestheticsServerDown: "Aesthetic server is down";
readonly AestheticsServerTimeout: "Aesthetic server timed out during submission";
readonly InvalidAPIKey: "Invalid AI Horde API key provided";
readonly WrongCredentials: "Provided user does not own this worker";
readonly NotAdmin: "Request needs AI Horded admin credentials";
readonly NotModerator: "Request needs AI Horded moderator credentials";
readonly NotOwner: "Request needs worker owner credentials";
readonly NotPrivileged: "This user is not hardcoded to perform this operation";
readonly AnonForbidden: "Anonymous is not allowed to perform this operation";
readonly AnonForbiddenWorker: "Anonymous tried to run a worker";
readonly AnonForbiddenUserMod: "Anonymous tried to modify their user account";
readonly NotTrusted: "Untrusted users are not allowed to perform this operation";
readonly UntrustedTeamCreation: "Untrusted user tried to create a team";
readonly UntrustedUnsafeIP: "Untrusted user tried to use a VPN for a worker";
readonly WorkerMaintenance: "Worker has been put into maintenance and cannot pop new jobs";
readonly WorkerFlaggedMaintenance: "Worker owner has been flagged and worker has been put into permanent maintenance";
readonly TooManySameIPs: "Same IP attempted to spawn too many workers";
readonly WorkerInviteOnly: "AI Horde is in worker invite-only mode and worker owner needs to request permission";
readonly UnsafeIP: "Worker attempted to connect from VPN";
readonly TimeoutIP: "Operation rejected because user IP in timeout";
readonly TooManyNewIPs: "Too many workers from new IPs currently";
readonly KudosUpfront: "This request requires upfront kudos to accept";
readonly SharedKeyEmpty: "Shared Key used in the request does not have any more kudos";
readonly InvalidJobID: "Job not found when trying to submit. This probably means its request was delected for inactivity";
readonly RequestNotFound: "Request not found. This probably means it was delected for inactivity";
readonly WorkerNotFound: "Worker ID not found";
readonly TeamNotFound: "Team ID not found";
readonly FilterNotFound: "Regex filter not found";
readonly UserNotFound: "User not found";
readonly DuplicateGen: "Job has already been submitted";
readonly AbortedGen: "Request aborted because too many jobs have failed";
readonly RequestExpired: "Request expired";
readonly TooManyPrompts: "User has requested too many generations concurrently";
readonly NoValidWorkers: "No workers online which can pick up this request";
readonly MaintenanceMode: "Request aborted because horde is in maintenance mode";
readonly TargetAccountFlagged: "Action rejected because target user has been flagged for violating Horde ToS";
readonly SourceAccountFlagged: "Action rejected because source user has been flagged for violating Horde ToS";
readonly FaultWhenKudosReceiving: "Unexpected error when receiving kudos";
readonly FaultWhenKudosSending: "Unexpected error when sending kudos";
readonly TooFastKudosTransfers: "User tried to send kudos too fast after receiving them from the same user";
readonly KudosTransferToAnon: "User tried to transfer kudos to Anon";
readonly KudosTransferToSelf: "User tried to transfer kudos to themselves";
readonly KudosTransferNotEnough: "User tried to transfer more kudos than they have";
readonly NegativeKudosTransfer: "User tried to transfer negative kudos";
readonly KudosTransferFromAnon: "User tried to transfer kudos using the Anon API key";
readonly InvalidAwardUsername: "Tried to award kudos to non-existing user";
readonly KudosAwardToAnon: "Tried to award kudos to Anonymous user";
readonly NotAllowedAwards: "This user is not allowed to Award Kudos";
readonly NoWorkerModSelected: "No valid worker modification selected";
readonly NoUserModSelected: "No valid user modification selected";
readonly NoHordeModSelected: "No valid horde modification selected";
readonly NoTeamModSelected: "No valid team modification selected";
readonly NoFilterModSelected: "No valid regex filter modification selected";
readonly NoSharedKeyModSelected: "No valid shared key modification selected";
readonly BadRequest: "Generic HTTP 400 code. You should typically never see this";
readonly Forbidden: "Generic HTTP 401 code. You should typically never see this";
readonly Locked: "Generic HTTP code. You should typically never see this";
readonly Unknown: "Unknown rc code";
}>;
export declare const ModelGenerationInputStableSamplers: Readonly<{
readonly lcm: "lcm";
readonly k_lms: "k_lms";
readonly k_heun: "k_heun";
readonly k_euler_a: "k_euler_a";
readonly k_euler: "k_euler";
readonly k_dpm_2: "k_dpm_2";
readonly k_dpm_2_a: "k_dpm_2_a";
readonly DDIM: "DDIM";
readonly PLMS: "PLMS";
readonly k_dpm_fast: "k_dpm_fast";
readonly k_dpm_adaptive: "k_dpm_adaptive";
readonly k_dpmpp_2s_a: "k_dpmpp_2s_a";
readonly k_dpmpp_2m: "k_dpmpp_2m";
readonly dpmsolver: "dpmsolver";
readonly k_dpmpp_sde: "k_dpmpp_sde";
}>;
export declare const SourceImageProcessingTypes: Readonly<{
readonly img2img: "img2img";
readonly inpainting: "inpainting";
readonly outpainting: "outpainting";
readonly remix: "remix";
}>;
export declare const ModelGenerationInputPostProcessingTypes: Readonly<{
readonly GFPGAN: "GFPGAN";
readonly RealESRGAN_x4plus: "RealESRGAN_x4plus";
readonly RealESRGAN_x2plus: "RealESRGAN_x2plus";
readonly RealESRGAN_x4plus_anime_6B: "RealESRGAN_x4plus_anime_6B";
readonly NMKD_Siax: "NMKD_Siax";
readonly "4x_AnimeSharp": "4x_AnimeSharp";
readonly strip_background: "strip_background";
readonly CodeFormers: "CodeFormers";
}>;
export declare const ModelInterrogationFormTypes: Readonly<{
readonly caption: "caption";
readonly interrogation: "interrogation";
readonly nsfw: "nsfw";
readonly GFPGAN: "GFPGAN";
readonly RealESRGAN_x4plus: "RealESRGAN_x4plus";
readonly RealESRGAN_x4plus_anime_6B: "RealESRGAN_x4plus_anime_6B";
readonly NMKD_Siax: "NMKD_Siax";
readonly "4x_AnimeSharp": "4x_AnimeSharp";
readonly CodeFormers: "CodeFormers";
readonly strip_background: "strip_background";
}>;
export declare const HordeAsyncRequestStates: Readonly<{
readonly waiting: "waiting";
readonly processing: "processing";
readonly done: "done";
readonly faulted: "faulted";
readonly partial: "partial";
readonly cancelled: "cancelled";
}>;
export declare const ModelGenerationInputControlTypes: Readonly<{
readonly canny: "canny";
readonly hed: "hed";
readonly depth: "depth";
readonly normal: "normal";
readonly openpose: "openpose";
readonly seg: "seg";
readonly scribble: "scribble";
readonly fakescribbles: "fakescribbles";
readonly hough: "hough";
}>;
export declare const ModelPayloadTextInversionsStable: Readonly<{
readonly prompt: "prompt";
readonly negrpompt: "negprompt";
}>;
export declare const ModelGenerationInputWorkflows: Readonly<{
readonly qr_code: "qr_code";
}>;
export declare const RequestSingleWarningCodes: Readonly<{
readonly NoAvailableWorker: "NoAvailableWorker";
readonly ClipSkipMismatch: "ClipSkipMismatch";
readonly StepsTooFew: "StepsTooFew";
readonly StepsTooMany: "StepsTooMany";
readonly CfgScaleMismatch: "CfgScaleMismatch";
readonly CfgScaleTooSmall: "CfgScaleTooSmall";
readonly CfgScaleTooLarge: "CfgScaleTooLarge";
readonly SamplerMismatch: "SamplerMismatch";
readonly SchedulerMismatch: "SchedulerMismatch";
}>;
export declare const GenerationMetadataStableTypes: Readonly<{
readonly lora: "lora";
readonly ti: "ti";
readonly censorship: "censorship";
readonly source_image: "source_image";
readonly source_mask: "source_mask";
readonly extra_source_images: "extra_source_images";
readonly batch_index: "batch_index";
readonly information: "information";
}>;
export declare const GenerationMetadataStableValues: Readonly<{
readonly download_failed: "download_failed";
readonly parse_failed: "parse_failed";
readonly baseline_mismatch: "baseline_mismatch";
readonly csam: "csam";
readonly nsfw: "nsfw";
readonly see_ref: "see_ref";
}>;
export declare class APIError extends Error {
rawError: RequestError;
status: number;
method: string;
url: string;
requestBody: any;
errors: Record<string, string>;
error_code: string;
constructor(rawError: RequestError | ValidationError, core_res: Response, method?: string, requestBody?: any);
get name(): string;
}
export declare class AIHorde {
#private;
VERSION: string;
ratings: AIHordeRatings;
constructor(options?: AIHordeInitOptions);
clearCache(): void;
get cache(): AIHordeCache;
parseAgent(agent: string): {
name: string;
version: string;
link: string;
};
generateFieldsString(fields?: string[]): string | undefined;
/**
* Lookup user details based on their API key.
* This can be used to verify a user exists
* @param options.token - The token of the user; If none given the default from the contructor is used
* @param options.fields - Array of fields that will be included in the returned data
* @returns UserDetails - The user data of the requested user
*/
findUser<T extends keyof UserDetails>(options?: {
token?: string;
fields?: T[];
}): Promise<Pick<UserDetails, T>>;
/**
* Details and statistics about a specific user
* @param id - The user ids to get
* @param options.token - The token of the requesting user; Has to be Moderator, Admin or Reuqested users token
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns UserDetails - The user data of the requested user
*/
getUserDetails<T extends keyof UserDetails>(id: number, options?: {
token?: string;
force?: boolean;
fields?: T[];
}): Promise<Pick<UserDetails, T>>;
/**
* Details of a worker Team
* @param id - The teams id to get
* @param options.token - The token of the requesting user
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns TeamDetailsStable - The team data
*/
getTeam<T extends keyof TeamDetailsStable>(id: string, options?: {
token?: string;
force?: boolean;
fields?: T[];
}): Promise<Pick<TeamDetailsStable, T>>;
/**
* Details of a registered worker.
* This can be used to verify a user exists
* @param id - The id of the worker
* @param options.token - Moderator or API key of workers owner (gives more information if requesting user is owner or moderator)
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns worker details for the requested worker
*/
getWorkerDetails<T extends keyof WorkerDetailsStable>(id: string, options?: {
token?: string;
force?: boolean;
fields?: T[];
}): Promise<Pick<WorkerDetailsStable, T>>;
/**
* Retrieve the status of an Asynchronous generation request without images
* Use this method to check the status of a currently running asynchronous request without consuming bandwidth.
* @param id - The id of the generation
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestStatusCheck - The Check data of the Generation
*/
getImageGenerationCheck<T extends keyof RequestStatusCheck>(id: string, options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<RequestStatusCheck, T>>;
/**
* Retrieve the full status of an Asynchronous generation request
* This method will include all already generated images in base64 encoded .webp files.
* As such, you are requested to not retrieve this data often. Instead use the getGenerationCheck method first
* This method is limited to 1 request per minute
* @param id - The id of the generation
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestStatusStable - The Status of the Generation
*/
getImageGenerationStatus<T extends keyof RequestStatusStable>(id: string, options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<RequestStatusStable, T>>;
/**
* This request will include all already generated texts.
* @param id - The id of the generation
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestStatusStable - The Status of the Generation
*/
getTextGenerationStatus<T extends keyof RequestStatusKobold>(id: string, options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<RequestStatusKobold, T>>;
/**
* This request will include all already generated images.
* As such, you are requested to not retrieve this endpoint often. Instead use the /check/ endpoint first
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns InterrogationStatus - The Status data of the Interrogation
*/
getInterrogationStatus<T extends keyof InterrogationStatus>(id: string, options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<InterrogationStatus, T>>;
/**
* If this loads, this node is available
* @returns true - If request was successful, if not throws error
*/
getHeartbeat(): Promise<true>;
/**
* Returns a list of models active currently in this horde
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns ActiveModel[] - Array of Active Models
*/
getModels<T extends keyof ActiveModel>(options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<ActiveModel, T>[]>;
/**
* Returns the statistics of a specific model in this horde
* @param model_name - The name of the model to fetch
* @param options.fields - Array of fields that will be included in the returned data
* @returns ActiveModel - The active model
*/
getModel<T extends keyof ActiveModel>(model_name: string, options?: {
fields?: T[];
}): Promise<Pick<ActiveModel, T>[]>;
/**
* Horde Maintenance Mode Status
* Use this method to quicky determine if this horde is in maintenance, invite_only or raid mode
* @param options.token - Requires Admin or Owner API key
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns HordeModes - The current modes of the horde
*/
getModes<T extends keyof HordeModes>(options?: {
token?: string;
force?: boolean;
fields?: T[];
}): Promise<Pick<HordeModes, T>>;
/**
* Read the latest happenings on the horde
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns Newspiece[] - Array of all news articles
*/
getNews<T extends keyof Newspiece>(options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<Newspiece, T>[]>;
/**
* Details about the current performance of this Horde
* @param options.force - Set to true to skip cache
* @param options.fields - Array of fields that will be included in the returned data
* @returns HordePerformanceStable - The hordes current performance
*/
getPerformance<T extends keyof HordePerformanceStable>(options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<HordePerformanceStable, T>>;
/**
* A List with the details and statistic of all registered users
* @param options.fields - Array of fields that will be included in the returned data
* @returns UserDetails[] - An array of all users data
*/
getUsers<T extends keyof UserDetails>(options?: {
force?: boolean;
fields?: T[];
}): Promise<Pick<UserDetails, T>[]>;
/**
* A List with the details of all registered and active workers
* @param options.fields - Array of fields that will be included in the returned data
* @returns An array of all workers data
*/
getWorkers<T extends keyof WorkerDetailsStable>(options?: {
fields?: T[];
}): Promise<Pick<WorkerDetailsStable, T>[]>;
/**
* Details how many images were generated per model for the past day, month and total
* @param options.fields - Array of fields that will be included in the returned data
* @returns ImageModelStats - The stats
*/
getImageModelStats<T extends keyof ImageModelStats>(options?: {
fields?: T[];
}): Promise<Pick<ImageModelStats, T>>;
/**
* Details how many images have been generated in the past minux,hour,day,month and total
* @param options.fields - Array of fields that will be included in the returned data
* @returns ImageTotalStats - The stats
*/
getImageTotalStats<T extends keyof ImageModelStats>(options?: {
fields?: T[];
}): Promise<Pick<ImageTotalStats, T>>;
/**
* Details how many texts were generated per model for the past day, month and total
* @param options.fields - Array of fields that will be included in the returned data
* @returns TextModelStats - The stats
*/
getTextModelStats<T extends keyof ImageModelStats>(options?: {
fields?: T[];
}): Promise<Pick<TextModelStats, T>>;
/**
* Details how many images have been generated in the past minux,hour,day,month and total
* @param options.fields - Array of fields that will be included in the returned data
* @returns TextTotalStats - The stats
*/
getTextTotalStats<T extends keyof ImageModelStats>(options?: {
fields?: T[];
}): Promise<Pick<TextTotalStats, T>>;
/**
* A List with the details of all teams
* @param options.fields - Array of fields that will be included in the returned data
* @returns TeamDetailsStable[] - Array of Team Details
*/
getTeams<T extends keyof TeamDetailsStable>(options?: {
fields?: T[];
}): Promise<Pick<TeamDetailsStable, T>[]>;
/**
* A List of filters
* @param query.filter_type - The type of filter to show
* @param query.contains - Only return filter containing this word
* @param options.token - The sending users API key; User must be a moderator
* @param options.fields - Array of fields that will be included in the returned data
* @returns FilterDetails[] - Array of Filter Details
*/
getFilters<T extends keyof FilterDetails>(query?: {
filter_type?: string;
contains?: string;
}, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<FilterDetails, T>[]>;
/**
* Gets Details for a specific filter
* @param filter_id - The filter to show
* @param options.token - The sending users API key; User must be a moderator
* @param options.fields - Array of fields that will be included in the returned data
* @returns FilterDetails - Filter Details
*/
getFilter<T extends keyof FilterDetails>(filter_id?: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<FilterDetails, T>>;
/**
* Gets Details about an existing Shared Key for this user
* @param sharedkey_id - The shared key to show
* @param options.token - The sending users API key; User must be a moderator
* @param options.fields - Array of fields that will be included in the returned data
* @returns FilterDetails - Filter Details
*/
getSharedKey<T extends keyof SharedKeyDetails>(sharedkey_id?: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<SharedKeyDetails, T>>;
/**
* Transfer Kudos to a registered user
* @param check_data - The prompt to check
* @param options.token - The sending users API key; User must be a moderator
* @param options.fields - Array of fields that will be included in the returned data
* @returns FilterPromptSuspicion
*/
postFilters<T extends keyof FilterPromptSuspicion>(check_data: FilterCheckPayload, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<FilterPromptSuspicion, T>>;
/**
* Initiate an Asynchronous request to generate images
* This method will immediately return with the UUID of the request for generation.
* This method will always be accepted, even if there are no workers available currently to fulfill this request.
* Perhaps some will appear in the next 10 minutes.
* Asynchronous requests live for 10 minutes before being considered stale and being deleted.
* @param generation_data - The data to generate the image
* @param options.token - The token of the requesting user
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestAsync - The id and message for the async generation request
*/
postAsyncImageGenerate<T extends keyof RequestAsync>(generation_data: ImageGenerationInput, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<RequestAsync, T>>;
/**
* Initiate an Asynchronous request to generate text
* This endpoint will immediately return with the UUID of the request for generation.
* This endpoint will always be accepted, even if there are no workers available currently to fulfill this request.
* Perhaps some will appear in the next 20 minutes.
* Asynchronous requests live for 20 minutes before being considered stale and being deleted.
* @param generation_data - The data to generate the text
* @param options.token - The token of the requesting user
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestAsync - The id and message for the async generation request
*/
postAsyncTextGenerate<T extends keyof RequestAsync>(generation_data: GenerationInputKobold, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<RequestAsync, T>>;
/**
* Submit aesthetic ratings for generated images to be used by LAION
* The request has to have been sent as shared: true.
* You can select the best image in the set, and/or provide a rating for each or some images in the set.
* If you select best-of image, you will gain 4 kudos. Each rating is 5 kudos. Best-of will be ignored when ratings conflict with it.
* You can never gain more kudos than you spent for this generation. Your reward at max will be your kudos consumption - 1.
* @param generation_id - The ID of the generation to rate
* @param rating - The data to rating data
* @param options.token - The token of the requesting user
* @param options.fields - Array of fields that will be included in the returned data
* @returns GenerationSubmitted - The kudos awarded for the rating
*/
postRating<T extends keyof GenerationSubmitted>(generation_id: string, rating: AestheticsPayload, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<GenerationSubmitted, T>>;
/**
* Check if there are generation requests queued for fulfillment
* This endpoint is used by registered workers only
* @param pop_input
* @param options.token - The token of the registered user
* @param options.fields - Array of fields that will be included in the returned data
* @returns GenerationPayloadStable
*/
postImageGenerationPop<T extends keyof GenerationPayloadStable>(pop_input: PopInputStable, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<GenerationPayloadStable, T>>;
/**
* Check if there are generation requests queued for fulfillment
* This endpoint is used by registered workers only
* @param pop_input
* @param options.token - The token of the registered user
* @param options.fields - Array of fields that will be included in the returned data
* @returns GenerationPayloadKobold
*/
postTextGenerationPop<T extends keyof GenerationPayloadKobold>(pop_input: PopInputKobold, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<GenerationPayloadKobold, T>>;
/**
* Submit a generated image
* This endpoint is used by registered workers only
* @param generation_submit
* @param options.token - The workers owner API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns GenerationSubmitted
*/
postImageGenerationSubmit<T extends keyof GenerationSubmitted>(generation_submit: {
id: string;
generation: string;
seed: string;
}, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<GenerationSubmitted, T>>;
/**
* Submit generated text
* This endpoint is used by registered workers only
* @param generation_submit
* @param options.token - The workers owner API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns GenerationSubmitted
*/
postTextGenerationSubmit<T extends keyof GenerationSubmitted>(generation_submit: {
id: string;
generation: string;
state: "ok" | "censored" | "faulted";
}, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<GenerationSubmitted, T>>;
/**
* Initiate an Asynchronous request to interrogate an image.
* This endpoint will immediately return with the UUID of the request for interrogation.
* This endpoint will always be accepted, even if there are no workers available currently to fulfill this request.
* Perhaps some will appear in the next 20 minutes.
* Asynchronous requests live for 20 minutes before being considered stale and being deleted.
* @param interrogate_payload
* @param options.token - The sending users API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestInterrogationResponse
*/
postAsyncInterrogate<T extends keyof RequestInterrogationResponse>(interrogate_payload: ModelInterrogationInputStable, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<RequestInterrogationResponse, T>>;
/**
* Check if there are interrogation requests queued for fulfillment
* This endpoint is used by registered workers only
* @param pop_input
* @param options.token - The token of the registered user
* @param options.fields - Array of fields that will be included in the returned data
* @returns InterrogationPopPayload
*/
postInterrogationPop<T extends keyof InterrogationPopPayload>(pop_input: InterrogationPopInput, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<InterrogationPopPayload, T>>;
/**
* Submit the results of an interrogated image
* This endpoint is used by registered workers only
* @param generation_submit
* @param options.token - The workers owner API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns GenerationSubmitted
*/
postInterrogationSubmit<T extends keyof GenerationSubmitted>(interrogation_submit: {
id: string;
result: string;
}, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<GenerationSubmitted, T>>;
/**
* Transfer Kudos to a registered user
* @param transfer_data - The data specifiying who to send how many kudos
* @param options.token - The sending users API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns KudosTransferred
*/
postKudosTransfer<T extends keyof KudosTransferred>(transfer_data: {
username: string;
amount: number;
}, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<KudosTransferred, T>>;
/**
* Receive kudos from the KoboldAI Horde
* @param user_id - The stable horde user id of the receiving user
* @param transfer_data - The data specifiying who to send how many kudos
* @param options.token - The sending users API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns null
*/
postKoboldTransfer(user_id: string, transfer_data: {
kai_id: string;
kudos_amount: number;
trusted: boolean;
}, options?: {
token?: string;
}): Promise<null>;
/**
* Create a new team
* Only trusted users can create new teams.
* @param create_payload - The data to create the team with
* @param options.token - The API key of a trusted user
* @param options.fields - Array of fields that will be included in the returned data
* @returns ModifyTeam
*/
createTeam<T extends keyof ModifyTeam>(create_payload: CreateTeamInput, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<ModifyTeam, T>>;
/** PUT */
/**
* Change Horde Modes
* @param modes - The new status of the Horde
* @param options.token - Requires Admin API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns HordeModes
*/
putStatusModes<T extends keyof HordeModes>(modes: {
maintenance: boolean;
shutdown: number;
invite_only: boolean;
raid: boolean;
}, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<HordeModes, T>>;
/**
* Method for horde admins to perform operations on users
* @param update_payload - The data to change on the target user
* @param id - The targeted users ID
* @param options.token - Requires Admin API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns ModifyUser
*/
updateUser<T extends keyof ModifyUser>(update_payload: ModifyUserInput, id: number, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<ModifyUser, T>>;
/**
* Put the worker into maintenance or pause mode
* Maintenance can be set by the owner of the serve or an admin.
* When in maintenance, the worker will receive a 503 request when trying to retrieve new requests. Use this to avoid disconnecting your worker in the middle of a generation
* Paused can be set only by the admins of this Horde.
* When in paused mode, the worker will not be given any requests to generate.
* @param update_payload - The data to change on the target worker
* @param id - The targeted workers ID
* @param options.token - The worker owners API key or Admin API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns ModifyWorker
*/
updateWorker<T extends keyof ModifyWorker>(update_payload: ModifyWorkerInput, id: string, options?: {
token?: string;
fields?: T[];
}): Promise<ModifyWorker>;
/**
* Adds a new regex filer
* @param create_payload - The data to create the filter with
* @param options.token - The Moderator API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns FilterDetails
*/
addFilter<T extends keyof FilterDetails>(create_payload: PutNewFilter, id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<FilterDetails, T>>;
/**
* Create a new SharedKey for this user
* @param create_payload - The data to create the shared key with
* @param options.token - The User API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns SharedKeyInput
*/
putSharedKey<T extends keyof SharedKeyDetails>(create_payload: SharedKeyInput, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<SharedKeyDetails, T>>;
/** PATCH */
/**
* Updates a Team's information
* @param update_payload - The data to update the team with
* @param options.token - The Moderator or Creator API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns ModifyTeam
*/
updateTeam<T extends keyof ModifyTeam>(update_payload: ModifyTeamInput, id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<ModifyTeam, T>>;
/**
* Updates an existing regex filer
* @param update_payload - The data to update the filter with
* @param id - The ID of the filter
* @param options.token - The Moderator API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns FilterDetails
*/
updateFilter<T extends keyof FilterDetails>(update_payload: PatchExistingFilter, id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<FilterDetails, T>>;
/**
* Modify an existing Shared Key
* @param update_payload - The data to update the shared key with
* @param id - The ID of the shared key
* @param options.token - The User API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns SharedKeyDetails
*/
updateSharedKey<T extends keyof SharedKeyDetails>(update_payload: SharedKeyInput, id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<SharedKeyDetails, T>>;
/** DELETE */
/**
* Cancel an unfinished request
* This request will include all already generated images in base64 encoded .webp files.
* @param id - The targeted generations ID
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestStatusStable
*/
deleteImageGenerationRequest<T extends keyof RequestStatusStable>(id: string, options?: {
fields?: T[];
}): Promise<Pick<RequestStatusStable, T>>;
/**
* Cancel an unfinished request
* This request will include all already generated images in base64 encoded .webp files.
* @param id - The targeted generations ID
* @param options.fields - Array of fields that will be included in the returned data
* @returns RequestStatusKobold
*/
deleteTextGenerationRequest<T extends keyof RequestStatusKobold>(id: string, options?: {
fields?: T[];
}): Promise<Pick<RequestStatusKobold, T>>;
/**
* Cancel an unfinished interrogation request
* This request will return all already interrogated image results.
* @param id - The targeted generations ID
* @param options.fields - Array of fields that will be included in the returned data
* @returns InterrogationStatus
*/
deleteInterrogationRequest<T extends keyof InterrogationStatus>(id: string, options?: {
fields?: T[];
}): Promise<Pick<InterrogationStatus, T>>;
/**
* Delete the worker entry
* This will delete the worker and their statistics. Will not affect the kudos generated by that worker for their owner.
* Only the worker's owner and an admin can use this endpoint.
* This action is unrecoverable!
* @param id - The targeted workers ID
* @param options.token - The worker owners API key or a Moderators API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns DeletedWorker
*/
deleteWorker<T extends keyof DeletedWorker>(id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<DeletedWorker, T>>;
/**
* Delete an existing SharedKey for this user
* @param id - The targeted Shared Key's ID
* @param options.token - The worker owners API key or a Moderators API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns SimpleResponse
*/
deleteSharedKey<T extends keyof SimpleResponse>(id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<SimpleResponse, T>>;
/**
* Delete the team entry
* Only the team's creator or a horde moderator can use this endpoint.
* This action is unrecoverable!
* @param id - The targeted teams ID
* @param options.token - The worker owners API key or a Moderators API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns DeletedTeam
*/
deleteTeam<T extends keyof DeletedTeam>(id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<DeletedTeam, T>>;
/**
* Remove an IP from timeout
* Only usable by horde moderators
* @param ip - The IP address
* @param options.token - Moderators API key
* @param options.fields - Array of fields that will be included in the returned data
* @returns SimpleResponse
*/
deleteIPTimeout<T extends keyof SimpleResponse>(delete_payload: DeleteTimeoutIPInput, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<SimpleResponse, T>>;
/**
* Delete a regex filter
* @param filter_id - The ID of the filter to delete
* @param options.token - The sending users API key; User must be a moderator
* @param options.fields - Array of fields that will be included in the returned data
* @returns SimpleResponse
*/
deleteFilter<T extends keyof SimpleResponse>(filter_id: string, options?: {
token?: string;
fields?: T[];
}): Promise<Pick<SimpleResponse, T>>;
}
export interface AIHordeInitOptions {
/** The configuration for caching results */
cache?: AIHordeCacheConfiguration;
/**
* The interval to check expired data in the cache
* @default 1000
*/
cache_interval?: number;
/** The default token to use for requests */
default_token?: string;
/** The base api domain + route to use for requests */
api_route?: string;
/** The ratings api domain + route to use for requests */
ratings_api_route?: string;
/** The client agent to pass in the requests. */
client_agent?: string;
}
export interface AIHordeCacheConfiguration {
/** How long to cache a specific user for in Milliseconds */
users?: number;
/** How long to cache generation check data for in Milliseconds */
generations_check?: number;
/** How long to cache generation status data for in Milliseconds */
generations_status?: number;
/** How long to cache interrogation status data for in Milliseconds */
interrogations_status?: number;
/** How long to cache models for in Milliseconds */
models?: number;
/** How long to cache modes for in Milliseconds */
modes?: number;
/** How long to cache news for in Milliseconds */
news?: number;
/** How long to cache performance for in Milliseconds */
performance?: number;
/** How long to cache workers for in Milliseconds */
workers?: number;
/** How long to cache teams for in Milliseconds */
teams?: number;
/** How long to cache sharedkeys for in Milliseconds */
sharedkeys?: number;
}
interface AIHordeCache {
users?: SuperMap<string, UserDetails>;
generations_check?: SuperMap<string, RequestStatusCheck>;
generations_status?: SuperMap<string, RequestStatusStable>;
interrogations_status?: SuperMap<string, InterrogationStatus>;
models?: SuperMap<string, ActiveModel[]>;
modes?: SuperMap<string, HordeModes>;
news?: SuperMap<string, Newspiece[]>;
performance?: SuperMap<string, HordePerformanceStable>;
workers?: SuperMap<string, WorkerDetailsStable>;
teams?: SuperMap<string, TeamDetails>;
sharedkeys?: SuperMap<string, SharedKeyDetails>;
}
export interface ModifyUserInput {
/** The amount of kudos to modify (can be negative) */
kudos?: number;
/**
* The amount of concurrent request this user can have
* @minimum 0
* @maximum 100
*/
concurrency?: number;
/**
* The amount by which to multiply the users kudos consumption
* @minimum 0.1
* @maximum 10
*/
usage_multiplier?: number;
/** Set to the amount of workers this user is allowed to join to the horde when in worker invite-only mode. */
worker_invited?: number;
/**
* Set to true to Make this user a horde moderator
* @example false
*/
moderator?: boolean;
/**
* Set to true to Make this user a display their worker IDs
* @example false
*/
public_workers?: boolean;
/**
* When specified, will start assigning the user monthly kudos, starting now!
* @minimum 0
*/
monthly_kudos?: number;
/**
* When specified, will change the username. No profanity allowed!
* @minLength 3
* @maxLength 100
*/
username?: string;
/**
* When set to true,the user and their servers will not be affected by suspicion
* @example false
*/
trusted?: boolean;
/** Set the user's suspicion back to 0 */
reset_suspicion?: boolean;
/**
* Contact details for the horde admins to reach the user in case of emergency. This is only visible to horde moderators.
* @example email@example.com
* @minLength 5
* @maxLength 500
*/
contact?: string;
}
export interface ModifyWorkerInput {
/** (Mods only) Set to true to put this worker into maintenance. */
maintenance?: boolean;
/** (Mods only) Set to true to pause this worker. */
paused?: boolean;
/**
* You can optionally provide a server note which will be seen in the server details. No profanity allowed!
* @minLength 5
* @maxLength 1000
*/
info?: string;
/**
* When this is set, it will change the worker's name. No profanity allowed!
* @minLength 5
* @maxLength 100
*/
name?: string;
/**
* The team towards which this worker contributes kudos. No profanity allowed!
* @example 0bed257b-e57c-4327-ac64-40cdfb1ac5e6
* @minLength 3
* @maxLength 100
*/
team?: string;
}
/**
* @link https://aihorde.net/api/
*/
export interface GenerationInputKobold {
/** The prompt which will be sent to KoboldAI to generate text */
prompt?: string;
params?: ModelGenerationInputKobold;
/**
* Specify which softpompt needs to be used to service this request
* @minLength 1
*/
softprompt?: string;
/**
* When true, only trusted workers will serve this request. When False, Evaluating workers will also be used which can increase speed but adds more risk!
* @default true
*/
trusted_workers?: boolean;
/** Specify which workers are allowed to service this request */
workers?: string[];
/** Specify which models are allowed to be used for this request */
models?: string[];
}
export interface ModelGenerationInputKobold {
/**
* @example 1
* @minimum 1
* @maximum 20
*/
n?: number;
/**
* Input formatting option. When enabled, adds a leading space to your input if there is no trailing whitespace at the end of the previous action.
* @example false
*/
frmtadsnsp?: boolean;
/**
* Output formatting option. When enabled, replaces all occurrences of two or more consecutive newlines in the output with one newline.
* @example false
*/
frmtrmblln?: boolean;
/**
* Output formatting option. When enabled, removes #/@%}{+=~|^<> from the output.
* @example false
*/
frmtrmspch?: boolean;
/**
* Output formatting option. When enabled, removes some characters from the end of the output such that the output doesn't end in the middle of a sentence. If the output is less than one sentence long, does nothing.
* @example false
*/
frmttriminc?: boolean;
/**
* Maximum number of tokens to send to the model.
* @example 1024
* @minimum 80
* @maximum 2048
*/
max_context_length?: number;
/**
* Number of tokens to generate.
* @minimum 16
* @maximum 512
*/
max_length?: number;
/**
* Base repetition penalty value.
* @maximum 1
*/
rep_pen?: number;
/** Repetition penalty range. */
rep_pen_range?: number;
/** Repetition penalty slope. */
rep_pen_slope?: number;
/**
* Output formatting option. When enabled, removes everything after the first line of the output, including the newline.