Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jozsefsallai/node-stablehorde
Unofficial Node.js API client for Stable Horde.
https://github.com/jozsefsallai/node-stablehorde
api-client stable-diffusion stable-horde
Last synced: about 2 months ago
JSON representation
Unofficial Node.js API client for Stable Horde.
- Host: GitHub
- URL: https://github.com/jozsefsallai/node-stablehorde
- Owner: jozsefsallai
- License: mit
- Created: 2022-11-24T22:10:36.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-24T22:12:32.000Z (about 2 years ago)
- Last Synced: 2024-10-08T04:24:36.307Z (3 months ago)
- Topics: api-client, stable-diffusion, stable-horde
- Language: TypeScript
- Homepage: https://jozsefsallai.github.io/node-stablehorde/
- Size: 74.2 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-stablehorde
Unofficial Node.js API client for [Stable Horde][stablehorde-url].
## Getting Started
Install the module:
```bash
npm install stablehorde
# or
yarn add stablehorde
```Instantiate the client:
```js
const { Client } = require('stablehorde');const stablehorde = new Client({
apiKey: 'your-api-key',
});
```### Async Mode
You can use the methods offered by the client object directly. When you do this,
the polling logic is left to you.```js
// initiate a generation request
const request = await stablehorde.generateAsync({
prompt: 'Painting of a dachshund drinking water in the style of Van Gogh',
}); // initiate a generation request// check the status of the request
const status = await stablehorde.check(request);// get the resulting generations
// you should only call this if the status object says the request is complete
// you can only send this request twice every minute
const generations = await stablehorde.generations(request);
```### Event Emitter Mode
You can also let the library handle the polling logic for you in an event
emitter style. This is the recommended way to use the library.```js
const handler = client.newRequestHandler(10000); // poll every 10 secondshandler.on('created', (request) => {
console.log('request created', request);
});handler.on('statusPolled', (status) => {
console.log('status polled', status);
});handler.on('finished', (generations) => {
console.log('generations finished', generations);
});handler.on('error', (err) => {
console.error('error', err);
});handler.generate({
prompt: 'Painting of a dachshund drinking water in the style of Van Gogh',
});
```## Join The Horde!
Stable Horde is run by individuals all around the world. If you want to help
out and reduce waiting times for everyone, consider [joining the horde][join-horde-url]!## For Contributors
`node-stablehorde` is written in TypeScript, therefore, you have to compile it
to JavaScript if you'd like to test your changes. You may do so using the
following command:```
npm run build
```The library does not currently employ any unit testing measures, however, if you
would like to contribute to the library, please make sure that your changes pass
linting. You can run the following command to check:```
npm run lint
```## License
MIT. Please read the LICENSE file for more information.
[stablehorde-url]: https://stablehorde.net/
[join-horde-url]: https://github.com/db0/AI-Horde/blob/main/README_StableHorde.md