Détail du package

@zeldafan0225/ai_horde

ZeldaFan022572kMIT6.0.1

A package to interact with the ai horde API

stable horde, ai horde, stable diffusion, image generation

readme

@zeldafan0225/ai_horde

This package allows you to communicate with the AI Horde API

DISCLAIMER: THIS PACKAGE/REPOSITORY IS IN NO WAY ASSOCIATED TO THE CREATORS OF AI HORDE

Versions 6.0.0 and later

v6 focuses on API coverage, consistency, and cleanup.

  • Minor breaking changes:
  • Some method signatures got small adjustments for consistency.
  • JSDoc/TypeDoc aligns with the current options; remove/adjust any usage of undocumented options.

Starting with Version 6.0.0 publishing is automatically done through a GitHub Action.

Versions 5.0.0 and later

Version 5.0.0 introduces some breaking changes:

  • Node 18.0.0 or higher is required
  • The way some things are exported is changed

It also features an internal restructure to reduce complexity and improve performance.

Bugs

To report bugs please open an issue on GitHub.

Features

  • Configurable Caching
  • Methods for all endpoints on the API V2
  • Default Token
  • Types with comments and explanations (TS)

Features that are currently missing

  • Ratelimit bucket

Contribute

I am always happy about contributions. You can contribute by forking this repository, updating or adding and then creating a pull request. You can contribute by adding new features, optimizing the currently existing code, adding examples or anything else I missed.

How to use

The package exports the class AIHorde which includes basically everything you need, when using typescript you can also export types. The package also exports constant values used in the hordes API request payloads

const { AIHorde } = require("@zeldafan0225/ai_horde");

/*
Create new instance of the ai_horde class to communicate with the rest API
You can configure which cache should contain the data for what time
You can also configure at what interval the cache is checking if there are any data that should be deleted

The class also takes a default token. This is helpful if you want to use this package only using your own token.
The token is not a required argument in any method.

A default API route is also in the contrictor for changing where the requests are directed to (e.g. when using a subdomain like https://test.aihorde.net)
*/
const ai_horde = new AIHorde({
  cache_interval: 1000 * 10,
  cache: {
    generations_check: 1000 * 30,
  },
  client_agent: "My-Project:v0.0.1:My-Contact"
});

// start the generation of an image with the given payload
const generation = await ai_horde.postAsyncImageGenerate({
  prompt: "The legend of Zelda",
});
console.log(generation);

// check the status of your generation using the generations id
const check = await ai_horde.getImageGenerationCheck(generation.id);
console.log(check);

See the auto-generated docs for more info on methods and parameters.

Publishing

This package is published to npm automatically when a Git tag with a semantic version is pushed to the repository.

  • Tag format: either vX.Y.Z or X.Y.Z (e.g. v5.2.1)
  • The workflow sets the package version from the tag and runs npm publish
  • Maintainers: add an npm Automation Token as the repo secret NPM_TOKEN
  • Supply chain: publishes include npm provenance attestation via GitHub OIDC

Example to publish a new version (maintainers only):

  1. Update changelog and code as needed
  2. Push a tag, e.g. git tag v5.2.1 && git push origin v5.2.1

Provenance / Attestations

The release workflow uses GitHub’s OIDC to request an ID token and publishes with --provenance. On npm, this shows the “Provenance” badge on the package/version page. Consumers can verify the package was built in this repository’s CI and matches the published tarball.