InstantID Serverless API
InstantID aims to generate customized images with various poses or styles from only a single reference ID image while ensuring high fidelity
1import requests
2import json
3
4url = "https://api.segmind.com/v1/instantid"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "photo of a man",
12 "face_image": "https://segmind-sd-models.s3.amazonaws.com/outputs/instantid_input.jpg",
13 "negative_prompt": "lowquality, badquality, sketches",
14 "style": "Vibrant Color",
15 "samples": 1,
16 "num_inference_steps": 10,
17 "guidance_scale": 5,
18 "seed": 354849415,
19 "identity_strength": 0.8,
20 "adapter_strength": 0.8,
21 "enhance_face_region": true,
22 "base64": false
23}
24
25response = requests.post(url, headers=headers, json=data)
26
27if response.status_code == 200:
28 result = response.json()
29 print(json.dumps(result, indent=2))
30else:
31 print(f"Error: {response.status_code}")
32 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/instantid"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "photo of a man",
12 "face_image": "https://segmind-sd-models.s3.amazonaws.com/outputs/instantid_input.jpg",
13 "negative_prompt": "lowquality, badquality, sketches",
14 "style": "Vibrant Color",
15 "samples": 1,
16 "num_inference_steps": 10,
17 "guidance_scale": 5,
18 "seed": 354849415,
19 "identity_strength": 0.8,
20 "adapter_strength": 0.8,
21 "enhance_face_region": true,
22 "base64": false
23}
24
25response = requests.post(url, headers=headers, json=data)
26
27if response.status_code == 200:
28 result = response.json()
29 print(json.dumps(result, indent=2))
30else:
31 print(f"Error: {response.status_code}")
32 print(response.text)API Endpoint
https://api.segmind.com/v1/instantidParameters
face_imagerequiredstring (uri)Face Image.
promptrequiredstringPrompt to render
adapter_strengthoptionalnumberAdapter Strength
0.8Range: 0 - 1base64optionalbooleanBase64 encoding of the output image.
falseenhance_face_regionoptionalbooleanEnhance Face region
trueguidance_scaleoptionalnumberScale for classifier-free guidance
5Range: 1 - 25identity_strengthoptionalnumberIdentity Strength
0.8Range: 0 - 1negative_promptoptionalstringPrompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'
num_inference_stepsoptionalintegerNumber of denoising steps.
10Range: 4 - 100pose_imageoptionalstring (uri)Pose Image.
samplesoptionalintegerNumber of samples to generate.
1Range: 1 - 4seedoptionalintegerSeed for image generation.
-1Range: -1 - 999999999999999styleoptionalstringStyle to apply
"(No style)""Watercolor""Film Noir""Neon""Jungle""Mars""Vibrant Color""Snow""Line art""Art Nouveau"+19 moreResponse Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out