typetext
{
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/7e0ffe6c-04fd-4440-92b2-e4376b4620a5/out-0_1.png",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "eye",
"prompt_strength": 0.8,
"width": 512
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_LYT**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
import fs from "node:fs";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run stability-ai/stable-diffusion using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"stability-ai/stable-diffusion:3080f37ef32771c9984d65033cbe71caa96c69680008bae64cf691724a6df04c",
{
input: {
guidance_scale: 7.5,
height: 512,
init_image: "https://replicate.delivery/mgxm/7e0ffe6c-04fd-4440-92b2-e4376b4620a5/out-0_1.png",
num_inference_steps: 50,
num_outputs: "1",
prompt: "eye",
prompt_strength: 0.8,
width: 512
}
}
);
// To access the file URL:
console.log(output[0].url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output[0]);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_LYT**********************************
This is your API token. Keep it to yourself.
import replicate
Run stability-ai/stable-diffusion using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"stability-ai/stable-diffusion:3080f37ef32771c9984d65033cbe71caa96c69680008bae64cf691724a6df04c",
input={
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/7e0ffe6c-04fd-4440-92b2-e4376b4620a5/out-0_1.png",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "eye",
"prompt_strength": 0.8,
"width": 512
}
)
# To access the file URL:
print(output[0].url())
#=> "http://example.com"
# To write the file to disk:
with open("my-image.png", "wb") as file:
file.write(output[0].read())
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_LYT**********************************
This is your API token. Keep it to yourself.
Run stability-ai/stable-diffusion using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "stability-ai/stable-diffusion:3080f37ef32771c9984d65033cbe71caa96c69680008bae64cf691724a6df04c",
"input": {
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/7e0ffe6c-04fd-4440-92b2-e4376b4620a5/out-0_1.png",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "eye",
"prompt_strength": 0.8,
"width": 512
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "sqyie5bdmrewdoxi6ehhxlesfe",
"model": "stability-ai/stable-diffusion",
"version": "3080f37ef32771c9984d65033cbe71caa96c69680008bae64cf691724a6df04c",
"input": {
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/7e0ffe6c-04fd-4440-92b2-e4376b4620a5/out-0_1.png",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "eye",
"prompt_strength": 0.8,
"width": 512
},
"logs": "Using seed: 2494\n\n0it [00:00, ?it/s]\n2it [00:00, 13.33it/s]\n4it [00:00, 13.49it/s]\n6it [00:00, 13.57it/s]\n8it [00:00, 13.75it/s]\n10it [00:00, 13.87it/s]\n12it [00:00, 14.01it/s]\n14it [00:01, 14.07it/s]\n16it [00:01, 14.11it/s]\n18it [00:01, 14.08it/s]\n20it [00:01, 13.88it/s]\n22it [00:01, 13.72it/s]\n24it [00:01, 13.70it/s]\n26it [00:01, 13.66it/s]\n28it [00:02, 13.73it/s]\n30it [00:02, 13.78it/s]\n32it [00:02, 13.83it/s]\n34it [00:02, 13.78it/s]\n36it [00:02, 13.86it/s]\n38it [00:02, 13.91it/s]\n40it [00:02, 13.96it/s]\n42it [00:03, 14.01it/s]\n44it [00:03, 14.07it/s]\n46it [00:03, 14.10it/s]\n48it [00:03, 14.07it/s]\n49it [00:03, 13.89it/s]",
"output": [
"https://replicate.delivery/mgxm/4ee3ab76-7864-4604-8897-9d330214d225/out-0.png"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-08-25T20:07:46.549858Z",
"started_at": "2022-08-25T20:07:46.727494Z",
"completed_at": "2022-08-25T20:07:51.275348Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/sqyie5bdmrewdoxi6ehhxlesfe/cancel",
"get": "https://api.replicate.com/v1/predictions/sqyie5bdmrewdoxi6ehhxlesfe"
},
"metrics": {
"predict_time": 4.547854,
"total_time": 4.72549
}
}
