typetext
{
"guidance_scale": "11.09",
"height": 512,
"init_image": "https://replicate.delivery/mgxm/82d38644-6e62-4a7b-af6a-38278047602c/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "spooky",
"prompt_strength": 0.61,
"width": 512
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_W0S**********************************
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: "11.09",
height: 512,
init_image: "https://replicate.delivery/mgxm/82d38644-6e62-4a7b-af6a-38278047602c/kittycropped.jpg",
num_inference_steps: 50,
num_outputs: "1",
prompt: "spooky",
prompt_strength: 0.61,
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_W0S**********************************
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": "11.09",
"height": 512,
"init_image": "https://replicate.delivery/mgxm/82d38644-6e62-4a7b-af6a-38278047602c/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "spooky",
"prompt_strength": 0.61,
"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_W0S**********************************
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": "11.09",
"height": 512,
"init_image": "https://replicate.delivery/mgxm/82d38644-6e62-4a7b-af6a-38278047602c/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "spooky",
"prompt_strength": 0.61,
"width": 512
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "bmxt4naztvdsnoepheiso33yiq",
"model": "stability-ai/stable-diffusion",
"version": "a9758cbfbd5f3c2094457d996681af52552901775aa2d6dd0b17fd15df959bef",
"input": {
"guidance_scale": "11.09",
"height": 512,
"init_image": "https://replicate.delivery/mgxm/82d38644-6e62-4a7b-af6a-38278047602c/kittycropped.jpg",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "spooky",
"prompt_strength": 0.61,
"width": 512
},
"logs": "Using seed: 59006\n\n0it [00:00, ?it/s]\n2it [00:00, 12.81it/s]\n4it [00:00, 12.83it/s]\n6it [00:00, 13.10it/s]\n8it [00:00, 13.15it/s]\n10it [00:00, 13.09it/s]\n12it [00:00, 13.28it/s]\n14it [00:01, 13.37it/s]\n16it [00:01, 13.38it/s]\n18it [00:01, 13.41it/s]\n20it [00:01, 13.45it/s]\n22it [00:01, 13.42it/s]\n24it [00:01, 13.34it/s]\n26it [00:01, 13.40it/s]\n28it [00:02, 13.48it/s]\n30it [00:02, 13.47it/s]\n32it [00:02, 13.49it/s]\n34it [00:02, 13.53it/s]\n36it [00:02, 13.64it/s]\n38it [00:02, 13.68it/s]\n39it [00:02, 13.42it/s]",
"output": [
"https://replicate.com/api/models/stability-ai/stable-diffusion/files/4ba35a87-fcc5-4541-9a3b-dc10eab585af/out-0.png"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-10-03T12:50:02.230468Z",
"started_at": "2022-10-03T12:50:02.43704Z",
"completed_at": "2022-10-03T12:50:06.466795Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/bmxt4naztvdsnoepheiso33yiq/cancel",
"get": "https://api.replicate.com/v1/predictions/bmxt4naztvdsnoepheiso33yiq"
},
"metrics": {
"predict_time": 4.029755,
"total_time": 4.236327
}
}
