kyuurzy

Text To Image

Oct 9th, 2025
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.67 KB | Source Code | 0 0
  1. const axios = require("axios")
  2.  
  3. async function easypic(prompt) {
  4.   const postRes = await axios.post(
  5.     'https://api.aieasypic.com/api/inference_jobs/',
  6.     {
  7.       model: 694648,
  8.       can_split: false,
  9.       parameters: {
  10.         batch_size: 2,
  11.         prompt: prompt,
  12.         controlnet_parameters: [],
  13.         width: 768,
  14.         height: 768,
  15.         cfg_scale: "1.0",
  16.         steps: 6,
  17.         sampler_name: "Euler",
  18.         lora_models: [774008],
  19.         extra_json: {
  20.           loras: [
  21.             {
  22.               id: 774008,
  23.               weight: 0.125,
  24.             },
  25.           ],
  26.         },
  27.       },
  28.     },
  29.     {
  30.       headers: {
  31.         'Accept': 'application/json, text/plain, */*',
  32.         'Content-Type': 'application/json',
  33.         'x-current-url': 'https://aieasypic.com/inspire/models/detail/aodai_sd_chiasedamme_v02-full-v20-121093',
  34.       },
  35.     }
  36.   );
  37.  
  38.   const jobId = postRes.data.id;
  39.   let result = null;
  40.  
  41.   for (let i = 0; i < 20; i++) {
  42.     await new Promise(res => setTimeout(res, 3000));
  43.  
  44.     const getRes = await axios.get(
  45.       `https://api.aieasypic.com/api/inference_jobs/${jobId}/success_detail/`,
  46.       {
  47.         headers: {
  48.           'Accept': 'application/json, text/plain, */*',
  49.           'x-current-url': 'https://aieasypic.com/inspire/models/detail/aodai_sd_chiasedamme_v02-full-v20-121093',
  50.         },
  51.       }
  52.     );
  53.  
  54.     if (getRes.data.status === 'S' && getRes.data.prediction_images.length > 0) {
  55.       result = getRes.data.prediction_images.map(img => img.image);
  56.       break;
  57.     }
  58.   }
  59.  
  60.   return result;
  61. }
  62.  
  63. //use
  64. const xxx = await easypic("a cute girl")
  65. console.log(JSON.stringify(xxx, null, 2));
Advertisement
Add Comment
Please, Sign In to add comment