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

~7.74s
~$0.025
 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

POSThttps://api.segmind.com/v1/instantid

Parameters

face_imagerequired
string (uri)

Face Image.

promptrequired
string

Prompt to render

adapter_strengthoptional
number

Adapter Strength

Default: 0.8Range: 0 - 1
base64optional
boolean

Base64 encoding of the output image.

Default: false
enhance_face_regionoptional
boolean

Enhance Face region

Default: true
guidance_scaleoptional
number

Scale for classifier-free guidance

Default: 5Range: 1 - 25
identity_strengthoptional
number

Identity Strength

Default: 0.8Range: 0 - 1
negative_promptoptional
string

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

num_inference_stepsoptional
integer

Number of denoising steps.

Default: 10Range: 4 - 100
pose_imageoptional
string (uri)

Pose Image.

samplesoptional
integer

Number of samples to generate.

Default: 1Range: 1 - 4
seedoptional
integer

Seed for image generation.

Default: -1Range: -1 - 999999999999999
styleoptional
string

Style to apply

Allowed values (29 total):
"(No style)""Watercolor""Film Noir""Neon""Jungle""Mars""Vibrant Color""Snow""Line art""Art Nouveau"+19 more

Response Type

Returns: Image

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out