Socket
Socket
Sign inDemoInstall

dreamstudio.js

Package Overview
Dependencies
9
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dreamstudio.js

A nodejs package for interact with the stability.ai REST API


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

dreamstudio.js


Discord server npm version npm downloads

Installation

npm i dreamstudio.js

pnpm add dreamstudio.js

yarn add dreamstudio.js

Usage

Generate images:

Text to image

It would log an object with the property artifacts that contains an array of the images. Every image object have the base64 property which is the image.

import { textToImg } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  var images = await textToImg({
    apiKey,
    engineId: 'stable-diffusion-v1-5',
    text_prompts: [
      {
        text: 'a cat in the moon with a space suit, photorealistic, 4k',
        weight: 1,
      },
    ],
  });
  console.log(images.artifacts);
})();
Engines list:
IdNameType
stable-diffusion-v1Stable Diffusion v1.4PICTURE
stable-diffusion-v1-5Stable Diffusion v1.5PICTURE
stable-diffusion-512-v2-0Stable Diffusion v2.0PICTURE
stable-diffusion-768-v2-0Stable Diffusion v2.0-768PICTURE
stable-diffusion-512-v2-1'Stable Diffusion v2.1PICTURE
stable-diffusion-768-v2-1Stable Diffusion v2.1-768PICTURE
stable-inpainting-v1-0Stable Inpainting v1.0PICTURE
stable-inpainting-512-v2-0Stable Inpainting v2.0PICTURE
Options:
Option NameTypeDefaultRequired
apiKeystringnonetrue
engineIdstringnonetrue
cfg_scalenumber7false
clip_guidance_presetstringNONEfalse
widthnumber512false
heightnumber512false
samplesnumber1false
seednumberrandomfalse
stepsnumber50false
text_promptsArraynonetrue
Image to image

It would log an object with the property artifacts that contains an array of the images. Every image object have the base64 property which is the image.

import { imgToimg } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  const initImage = fs.readFileSync('./examples/init_image.png'); // the initial image path
  var images = await imgToimg({
    apiKey,
    initImage,
    engineId: 'stable-inpainting-512-v2-0',
    text_prompts: [
      {
        text: 'add a picture of van gogh to the wall',
        weight: 1,
      },
    ],
  });
  fs.writeFile('./examples/out.png', images.artifacts[0].base64, 'base64'); // save the result
})();
Engines list:
IdNameType
stable-diffusion-v1Stable Diffusion v1.4PICTURE
stable-diffusion-v1-5Stable Diffusion v1.5PICTURE
stable-diffusion-512-v2-0Stable Diffusion v2.0PICTURE
stable-diffusion-768-v2-0Stable Diffusion v2.0-768PICTURE
stable-diffusion-512-v2-1'Stable Diffusion v2.1PICTURE
stable-diffusion-768-v2-1Stable Diffusion v2.1-768PICTURE
stable-inpainting-v1-0Stable Inpainting v1.0PICTURE
stable-inpainting-512-v2-0Stable Inpainting v2.0PICTURE
Options:
Option NameTypeDefaultRequired
apiKeystringnonetrue
engineIdstringnonetrue
cfg_scalenumber7false
clip_guidance_presetstringNONEfalse
widthnumber512false
heightnumber512false
samplesnumber1false
seednumberrandomfalse
stepsnumber50false
text_promptsArraynonetrue
Image to image/Masking

Under development

User information:

import { getUser, getBalance } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  var user = await getUser(apiKey);
  console.log(user);
  var balance = await getBalance(apiKey);
  console.log(balance);
})();

Get engines list:

import { getEngines } from 'dreamstudio.js';
var apiKey = 'your dreamstudio api key';
(async () => {
  var engines = await getEngines(apiKey);
  console.log(engines);
})();

To do list:

  • User data
  • Engines list
  • Text to image
  • Image to image
  • Image to image/masking
  • Improve error messages

Keywords

FAQs

Last updated on 12 Jan 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc