Run InstantID with an API

With Replicate, you can run InstantID in the cloud with one line of code.

  • For higher similarity, increase the weight of controlnet_conditioning_scale (IdentityNet) and ip_adapter_scale (Adapter).
  • For over-saturation, decrease the ip_adapter_scale. If not work, decrease controlnet_conditioning_scale.
  • For higher text control ability, decrease ip_adapter_scale.
  • For specific styles, choose corresponding base model makes differences.
  • We have not supported multi-person yet, will only use the largest face as reference pose.

You can run InstantID with our official JavaScript client:

npm install replicate

Set the REPLICATE_API_TOKEN environment variable:

export REPLICATE_API_TOKEN=<your-api-token>

Import and set up the client:

import Replicate from "replicate";

const replicate = new Replicate({
  auth: process.env.REPLICATE_API_TOKEN,
});

Run zsxkib/instant-id using Replicate’s API:

const output = await replicate.run(
  "zsxkib/instant-id:491ddf5be6b827f8931f088ef10c6d015f6d99685e6454e6f04c8ac298979686",
  {
    input: {
		"image": "https://replicate.delivery/pbxt/KIIutO7jIleskKaWebhvurgBUlHR6M6KN7KHaMMWSt4OnVrF/musk_resize.jpeg",
		"width": 640,
		"height": 640,
		"prompt": "analog film photo of a man. faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage, masterpiece, best quality",
		"sdxl_weights": "protovision-xl-high-fidel",
		"guidance_scale": 5,
		"negative_prompt": "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured (lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch,deformed, mutated, cross-eyed, ugly, disfigured",
		"ip_adapter_scale": 0.8,
		"num_inference_steps": 30,
		"disable_safety_checker": False,
		"controlnet_conditioning_scale": 0.8
    }
  }
);
console.log(output);

Note that InstandID takes an image as input. You can provide URLs or base 64 strings as values for the image.

To learn more, take a look at the guide on getting started with Node.js.

You can run InstantID with our official Python client:

pip install replicate

Set the REPLICATE_API_TOKEN environment variable:

export REPLICATE_API_TOKEN=<your-api-token>

Run zsxkib/instant-id using Replicate’s API:

import replicate

output = replicate.run(
    "zsxkib/instant-id:491ddf5be6b827f8931f088ef10c6d015f6d99685e6454e6f04c8ac298979686",
    input={
		"image": "https://replicate.delivery/pbxt/KIIutO7jIleskKaWebhvurgBUlHR6M6KN7KHaMMWSt4OnVrF/musk_resize.jpeg",
		"width": 640,
		"height": 640,
		"prompt": "analog film photo of a man. faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage, masterpiece, best quality",
		"sdxl_weights": "protovision-xl-high-fidel",
		"guidance_scale": 5,
		"negative_prompt": "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured (lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch,deformed, mutated, cross-eyed, ugly, disfigured",
		"ip_adapter_scale": 0.8,
		"num_inference_steps": 30,
		"disable_safety_checker": False,
		"controlnet_conditioning_scale": 0.8
    }
)
print(output)

Note that InstandID takes an image as input. You can provide URLs or base 64 strings as values for the image.

To learn more, take a look at the guide on getting started with Python.

You can call the HTTP API directly with tools like cURL:

Set the REPLICATE_API_TOKEN environment variable:

export REPLICATE_API_TOKEN=<your-api-token>

Run zsxkib/instant-id using Replicate’s API:

curl -s -X POST \
  -H "Authorization: Token $REPLICATE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d $'{
    "version": "c98b2e7a196828d00955767813b81fc05c5c9b294c670c6d147d545fed4ceecf",
    "input": {
		"image": "https://replicate.delivery/pbxt/KIIutO7jIleskKaWebhvurgBUlHR6M6KN7KHaMMWSt4OnVrF/musk_resize.jpeg",
		"width": 640,
		"height": 640,
		"prompt": "analog film photo of a man. faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage, masterpiece, best quality",
		"sdxl_weights": "protovision-xl-high-fidel",
		"guidance_scale": 5,
		"negative_prompt": "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured (lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch,deformed, mutated, cross-eyed, ugly, disfigured",
		"ip_adapter_scale": 0.8,
		"num_inference_steps": 30,
		"disable_safety_checker": False,
		"controlnet_conditioning_scale": 0.8
    }
  }' \
  https://api.replicate.com/v1/models/zsxkib/instant-id/predictions

Note that InstandID takes an image as input. You can provide URLs or base 64 strings as values for the image.

To learn more, take a look at Replicate’s HTTP API reference docs.

You can also run InstantID using other Replicate client libraries for Golang, Swift, Elixir, and others