1.0.4 • Published 1 year ago

opex-kandisky v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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.

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago