1const axios = require('axios');
2
3const fs = require('fs');
4const path = require('path');
5
6async function toB64(imgPath) {
7 const data = fs.readFileSync(path.resolve(imgPath));
8 return Buffer.from(data).toString('base64');
9}
10
11const api_key = "YOUR API-KEY";
12const url = "https://api.segmind.com/v1/sd1.5-inpainting";
13
14const data = {
15 "prompt": "mecha robot sitting on a bench",
16 "negative_prompt": "Disfigured, cartoon, blurry, nude",
17 "samples": 1,
18 "image": "toB64('https://segmind.com/inpainting-input-image.jpeg')",
19 "mask": "toB64('https://segmind.com/inpainting-input-mask.jpeg')",
20 "scheduler": "DDIM",
21 "num_inference_steps": 25,
22 "guidance_scale": 7.5,
23 "strength": 1,
24 "seed": 17123564234,
25 "img_width": 512,
26 "img_height": 512
27};
28
29(async function() {
30 try {
31 const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
32 console.log(response.data);
33 } catch (error) {
34 console.error('Error:', error.response.data);
35 }
36})();
Prompt to render
Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'
Number of samples to generate.
min : 1,
min : 4
Input Image.
Mask Image
Type of scheduler.
Allowed values:
Number of denoising steps.
min : 20,
min : 100
Scale for classifier-free guidance
min : 0.1,
min : 25
How much to transform the reference image
min : 0.1,
min : 1
Seed for image generation.
Image resolution.
Allowed values:
Image resolution.
Allowed values:
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.