typetext
{
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/fb38164d-da12-426e-9948-c0ebcb9fb52e/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "PUMPKIN",
"prompt_strength": 0.7,
"width": 512
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_0Wj**********************************
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:a9758cbfbd5f3c2094457d996681af52552901775aa2d6dd0b17fd15df959bef",
{
input: {
guidance_scale: 7.5,
height: 512,
init_image: "https://replicate.delivery/mgxm/fb38164d-da12-426e-9948-c0ebcb9fb52e/kittycropped.jpg",
num_inference_steps: 50,
num_outputs: "1",
prompt: "PUMPKIN",
prompt_strength: 0.7,
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_0Wj**********************************
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:a9758cbfbd5f3c2094457d996681af52552901775aa2d6dd0b17fd15df959bef",
input={
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/fb38164d-da12-426e-9948-c0ebcb9fb52e/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "PUMPKIN",
"prompt_strength": 0.7,
"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_0Wj**********************************
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:a9758cbfbd5f3c2094457d996681af52552901775aa2d6dd0b17fd15df959bef",
"input": {
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/fb38164d-da12-426e-9948-c0ebcb9fb52e/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "PUMPKIN",
"prompt_strength": 0.7,
"width": 512
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "4ypir3u26jdrlk3ght7dif4tjy",
"model": "stability-ai/stable-diffusion",
"version": "a9758cbfbd5f3c2094457d996681af52552901775aa2d6dd0b17fd15df959bef",
"input": {
"guidance_scale": 7.5,
"height": 512,
"init_image": "https://replicate.delivery/mgxm/fb38164d-da12-426e-9948-c0ebcb9fb52e/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "PUMPKIN",
"prompt_strength": 0.7,
"width": 512
},
"logs": "Using seed: 43807\n\n0it [00:00, ?it/s]\n2it [00:00, 12.83it/s]\n4it [00:00, 13.26it/s]\n6it [00:00, 13.40it/s]\n8it [00:00, 13.51it/s]\n10it [00:00, 13.56it/s]\n12it [00:00, 13.63it/s]\n14it [00:01, 13.63it/s]\n16it [00:01, 13.66it/s]\n18it [00:01, 13.67it/s]\n20it [00:01, 13.67it/s]\n22it [00:01, 13.67it/s]\n24it [00:01, 13.60it/s]\n26it [00:01, 13.60it/s]\n28it [00:02, 13.54it/s]\n30it [00:02, 13.54it/s]\n32it [00:02, 13.49it/s]\n34it [00:02, 13.47it/s]\n36it [00:02, 13.47it/s]\n38it [00:02, 13.50it/s]\n40it [00:02, 13.57it/s]\n42it [00:03, 13.55it/s]\n44it [00:03, 13.57it/s]\n44it [00:03, 13.55it/s]",
"output": [
"https://replicate.com/api/models/stability-ai/stable-diffusion/files/49345a03-4c65-43ec-bc1d-fc6461375e0c/out-0.png"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-10-03T12:31:06.894024Z",
"started_at": "2022-10-03T12:31:07.102589Z",
"completed_at": "2022-10-03T12:31:11.431608Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/4ypir3u26jdrlk3ght7dif4tjy/cancel",
"get": "https://api.replicate.com/v1/predictions/4ypir3u26jdrlk3ght7dif4tjy"
},
"metrics": {
"predict_time": 4.329019,
"total_time": 4.537584
}
}
