typetext
{
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/dff721db-bf78-4e04-a3a1-c412fe6e76b0/time-surrealism-watch-oil-wallpaper-preview.jpeg",
"mask": "https://replicate.delivery/mgxm/24034da1-d461-4c60-ba7b-1e9e7184a3f1/time-surrealism-watch-oil-wallpaper-preview-mask.jpeg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "modern apple watches with colorful hd displays in a surrealist style",
"prompt_strength": 0.5,
"width": 512
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_YFY**********************************
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/dff721db-bf78-4e04-a3a1-c412fe6e76b0/time-surrealism-watch-oil-wallpaper-preview.jpeg",
mask: "https://replicate.delivery/mgxm/24034da1-d461-4c60-ba7b-1e9e7184a3f1/time-surrealism-watch-oil-wallpaper-preview-mask.jpeg",
num_inference_steps: 50,
num_outputs: "1",
prompt: "modern apple watches with colorful hd displays in a surrealist style",
prompt_strength: 0.5,
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_YFY**********************************
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/dff721db-bf78-4e04-a3a1-c412fe6e76b0/time-surrealism-watch-oil-wallpaper-preview.jpeg",
"mask": "https://replicate.delivery/mgxm/24034da1-d461-4c60-ba7b-1e9e7184a3f1/time-surrealism-watch-oil-wallpaper-preview-mask.jpeg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "modern apple watches with colorful hd displays in a surrealist style",
"prompt_strength": 0.5,
"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_YFY**********************************
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/dff721db-bf78-4e04-a3a1-c412fe6e76b0/time-surrealism-watch-oil-wallpaper-preview.jpeg",
"mask": "https://replicate.delivery/mgxm/24034da1-d461-4c60-ba7b-1e9e7184a3f1/time-surrealism-watch-oil-wallpaper-preview-mask.jpeg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "modern apple watches with colorful hd displays in a surrealist style",
"prompt_strength": 0.5,
"width": 512
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "ljnv74ftfbfvtlqrvsz5zarakm",
"model": "stability-ai/stable-diffusion",
"version": "3080f37ef32771c9984d65033cbe71caa96c69680008bae64cf691724a6df04c",
"input": {
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/dff721db-bf78-4e04-a3a1-c412fe6e76b0/time-surrealism-watch-oil-wallpaper-preview.jpeg",
"mask": "https://replicate.delivery/mgxm/24034da1-d461-4c60-ba7b-1e9e7184a3f1/time-surrealism-watch-oil-wallpaper-preview-mask.jpeg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "modern apple watches with colorful hd displays in a surrealist style",
"prompt_strength": 0.5,
"width": 512
},
"logs": "Using seed: 2463\n\n0it [00:00, ?it/s]\n1it [00:00, 6.17it/s]\n3it [00:00, 10.31it/s]\n5it [00:00, 11.95it/s]\n7it [00:00, 12.66it/s]\n9it [00:00, 13.17it/s]\n11it [00:00, 13.45it/s]\n13it [00:01, 13.53it/s]\n15it [00:01, 13.72it/s]\n17it [00:01, 13.86it/s]\n19it [00:01, 13.91it/s]\n21it [00:01, 13.95it/s]\n23it [00:01, 14.04it/s]\n25it [00:01, 14.05it/s]\n27it [00:02, 14.01it/s]\n29it [00:02, 14.08it/s]\n31it [00:02, 14.12it/s]\n33it [00:02, 14.05it/s]\n34it [00:02, 13.50it/s]",
"output": [
"https://replicate.delivery/mgxm/bb35c491-8794-43d6-81e1-41211831535d/out-0.png"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-08-25T20:16:44.657704Z",
"started_at": "2022-08-25T20:16:44.844991Z",
"completed_at": "2022-08-25T20:16:53.79384Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/ljnv74ftfbfvtlqrvsz5zarakm/cancel",
"get": "https://api.replicate.com/v1/predictions/ljnv74ftfbfvtlqrvsz5zarakm"
},
"metrics": {
"predict_time": 8.948849,
"total_time": 9.136136
}
}

