JSPM

stable-diffusion-api

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29
  • Score
    100M100P100Q58655F
  • License MIT

API translation for Automatic1111 Stable Diffusion WebUI

Package Exports

  • stable-diffusion-api
  • stable-diffusion-api/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stable-diffusion-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Stable Diffusion Api

npm npm GitHub

A Typescript API client for AUTOMATIC111/stable-diffusion-webui API that is unremarkably inspired by the Python library webuiapi.

Requisites

  • To use this API client, you have to run stable-diffusion-webui with the --api command line argument.
  • Optionally you can add --nowebui to disable the web interface.

Installation

npm install stable-diffusion-api
yarn add stable-diffusion-api

Usage

Instantiation

import StableDiffusionApi from "stable-diffusion-api";

const api = new StableDiffusionApi();

const api = new StableDiffusionApi({
  host: "localhost",
  port: 7860,
  protocol: "http",
  defaultSampler: "Euler a",
  defaultStepCount: 20,
});

const api = new StableDiffusionApi({
  baseUrl: "http://localhost:7860",
});

txt2img

const result = await api.txt2img({
    prompt: "An AI-powered robot that accidentally starts doing everyone's job, causing chaos in the workplace."
    ...
})

result.image.toFile('result.png')

| Result image |:-------------------------: |

img2img

const image = sharp('image.png')

const result = await api.img2img({
    init_images: [image],
    prompt: "Man, scared of AGI, running away on a burning lava floor."
    ...
})

result.image.toFile('result.png')
Init image Result image