POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 const axios = require('axios'); const fs = require('fs'); const path = require('path'); async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/instantid"; const data = { "prompt": "photo of a man", "face_image": "toB64('https://segmind-sd-models.s3.amazonaws.com/outputs/instantid_input.jpg')", "pose_image": "toB64('undefined')", "negative_prompt": "lowquality, badquality, sketches", "style": "Vibrant Color", "samples": 1, "num_inference_steps": 10, "guidance_scale": 5, "seed": 354849415, "identity_strength": 0.8, "adapter_strength": 0.8, "enhance_face_region": true, "base64": false }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
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

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,

max : 4


num_inference_stepsint ( default: 10 ) Affects Pricing

Number of denoising steps.

min : 4,

max : 100


guidance_scalefloat ( default: 5 )

Scale for classifier-free guidance

min : 1,

max : 25


seedint ( default: -1 )

Seed for image generation.

min : -1,

max : 999999999999999


identity_strengthfloat ( default: 0.8 )

Identity Strength

min : 0,

max : 1


adapter_strengthfloat ( default: 0.8 )

Adapter Strength

min : 0,

max : 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.