POST/v1/instantid
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/instantid";
13
14const data = {
15  "prompt": "photo of a man",
16  "face_image": "toB64('https://segmind-sd-models.s3.amazonaws.com/outputs/instantid_input.jpg')",
17  "pose_image": "toB64('undefined')",
18  "negative_prompt": "lowquality, badquality, sketches",
19  "style": "Vibrant Color",
20  "samples": 1,
21  "num_inference_steps": 10,
22  "guidance_scale": 5,
23  "seed": 354849415,
24  "identity_strength": 0.8,
25  "adapter_strength": 0.8,
26  "enhance_face_region": true,
27  "base64": false
28};
29
30(async function() {
31    try {
32        const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
33        console.log(response.data);
34    } catch (error) {
35        console.error('Error:', error.response.data);
36    }
37})();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing
Expand

Attributes


promptstr *

Prompt to render


face_imageimage *

Face Image.


pose_imageimage ( default: 1 )

Pose Image.


negative_promptstr ( default: None )

Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'


stylestr ( default: 1 )

Style to apply


samplesint ( default: 1 ) Affects Pricing

Number of samples to generate.

min : 1,

min : 4


num_inference_stepsint ( default: 10 ) Affects Pricing

Number of denoising steps.

min : 4,

min : 100


guidance_scalefloat ( default: 5 )

Scale for classifier-free guidance

min : 1,

min : 25


seedint ( default: -1 )

Seed for image generation.

min : -1,

min : 999999999999999


identity_strengthfloat ( default: 0.8 )

Identity Strength

min : 0,

min : 1


adapter_strengthfloat ( default: 0.8 )

Adapter Strength

min : 0,

min : 1


enhance_face_regionboolean ( default: true )

Enhance Face region


base64boolean ( default: 1 )

Base64 encoding of the output image.

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.

InstantID

InstantID presents a revolutionary method for identity-preserving image generation, enabling the transformation of a single reference ID image into a diverse array of customized images. This innovative solution is underpinned by a novel face encoder and IdentityNet, which work in tandem to ensure the faithful preservation of the original identity across all generated images. The face encoder meticulously captures the intricate details of the reference image, thereby upholding high fidelity in the resulting images. Meanwhile, IdentityNet leverages strong semantic and weak spatial conditions, integrating facial and landmark images with textual prompts to steer the image generation process. This powerful diffusion model-based tool is ideal for users seeking to personalize images in various poses or styles while safeguarding the integrity of the original identity. InstantID's exceptional performance and efficiency make it highly advantageous for real-world applications where identity preservation is paramount.

This groundbreaking approach to image generation has significant implications for diverse fields, including personalized image synthesis, creative applications, and identity-sensitive scenarios. By enabling the generation of customized images from a single reference ID image, InstantID streamlines the image personalization process, eliminates the need for multiple reference images, and upholds the integrity of the original identity. Its versatility and effectiveness underscore its potential for various creative and practical applications.

Applications:

1. Photography and Portraiture: Create varied portraits from a single photograph, exploring different styles and poses.

2. Fashion and Design: Visualize how a person would look in different outfits or settings.

3. Entertainment and Media: Generate diverse character images for media production.

4. Personalization and Branding: Customize marketing materials with personalized images.