Advertisement
WILDAN_IZZUDIN

[JS] ADOBE FIREFLY IMAGE GENERATOR

Apr 19th, 2024
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios')
  2.  
  3. class AdobeFirefly {
  4.     constructor(options = {}) {
  5.         this.options = options
  6.     }
  7.  
  8.     generate = prompt => new Promise(async resolve => {
  9.         try {
  10.             const json = await (await axios.post('https://firefly.adobe.io/v2/images/generate', {
  11.                 prompt, "size": {
  12.                     "width": 2048, "height": 2048
  13.                 }, "visualIntensity": 6, "locale": "en-ID", "seeds": [61438, 95119, 42010, 42205]}, {
  14.                 headers: {
  15.                     ...this.options
  16.                 }
  17.             })).data
  18.             if (!json.outputs || json.outputs.length < 1) return ({
  19.                 status: false,
  20.                 msg: `Can't generate image!`
  21.             })
  22.             resolve({
  23.                 status: true,
  24.                 data: json.outputs
  25.             })
  26.         } catch (e) {
  27.             resolve({
  28.                 status: false,
  29.                 msg: e.message
  30.             })
  31.         }
  32.     })
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement