npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

opex-kandisky

v1.0.4

Published

fusionbrain.ai txt2img wrapper / Kandisky 2.1

Downloads

19

Readme

Kandisky Text-To-Image API

This is a Node.js module that wraps the Kandisky Text-To-Image API endpoint, providing an easy-to-use interface for generating images from text and various styles.

Installation

To install this module, use npm:

npm install opex-kandisky --save

Usage

Here's an example of how to use this module to generate an image:

const { generate } = require('opex-kandisky');
(async () => {
  const query = 'A beautiful sunset over the mountains';
  const style = 'ultra';
  const image1 = await generate(query, style);
  console.log(image1.url);

  const image2 = await generate(query);
  //without style
  console.log(image2.url);

  const customStyle = 'in beadwork style, intricate details made of small beads';
  const image3 = await generate(query, style);
  //with custom style
  console.log(image3.url);
})();

The generate function takes three parameters: query, style and checkSeconds. The first parameter is mandatory, and the second and third are optional. Here's what they do:

  • query: The text you want to generate an image for.
  • style: (Optional) The style of the image you want to generate. This can be empty, custom or one of the following: 'middleAges', 'anime', 'ultra', 'cyberpunk', 'kandinsky', 'aivazovsky', 'malevich', 'picasso', 'goncharova', 'classicism', 'renaissance', 'oilPainting', 'pencil', 'digital', 'sovietCartoons', 'unreal', 'cartoon', 'glamorous', 'portrait', 'mosaic', 'icon', 'khokhloma', or 'christmas'.
  • checkSeconds: (Optional) The number of seconds to wait between checking the status of the request. By default, this is set to 3 seconds.

The generate function returns an object with the following properties:

  • url: A URL to the generated image.
  • buffer: The raw image data as a buffer.
  • censored: Can be true or false. true means the prompt had forbidden words and the image was censored.

Functions

This module provides the following functions:

  • createRequest(query, style, ): Creates a new request for generating an image with the specified query and style. Returns an object with the following properties:

    • requestId: The ID of the created request.
    • success: A boolean indicating whether the request was successful.
    • message: (Optional) If success is false, this contains an error message.
  • getStatus(requestId): Gets the status of the request with the specified requestId. Returns an object with the following properties:

    • result: The current status of the request. This can be one of the following: 'INITIAL', 'PROCESSING', or 'SUCCESS'.
    • success: A boolean indicating whether the request was successful.
    • message: (Optional) If success is false, this contains an error message.
  • getResult(requestId): Gets the result of the request with the specified requestId. Returns an object with the following properties:

    • url: A URL to the generated image.
    • buffer: The raw image data as a buffer.
    • success: A boolean indicating whether the request was successful.
    • message: (Optional) If success is false, this contains an error message.
  • generate(query, style, checkSeconds): Generates an image with the specified query and style. Returns an object with the following properties:

    • url: A URL to the generated image.
    • buffer: The raw image data as a buffer.
    • success: A boolean indicating whether the request was successful.
    • message: (Optional) If success is false, this contains an error message.
  • styleNames: An array of all available style names.

  • styles: An object of all available styles and their prompts.

Credits

This module was developed by OpexDev, and is licensed under the ISC License.