typetext
{
"guidance_scale": 7.5,
"height": 512,
"negative_prompt": "green",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "multicolor hyperspace",
"prompt_strength": 0.8,
"scheduler": "K-LMS",
"width": 512
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_3Ds**********************************
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:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
{
input: {
guidance_scale: 7.5,
height: 512,
negative_prompt: "green",
num_inference_steps: 50,
num_outputs: "1",
prompt: "multicolor hyperspace",
prompt_strength: 0.8,
scheduler: "K-LMS",
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_3Ds**********************************
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:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
input={
"guidance_scale": 7.5,
"height": 512,
"negative_prompt": "green",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "multicolor hyperspace",
"prompt_strength": 0.8,
"scheduler": "K-LMS",
"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_3Ds**********************************
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:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
"input": {
"guidance_scale": 7.5,
"height": 512,
"negative_prompt": "green",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "multicolor hyperspace",
"prompt_strength": 0.8,
"scheduler": "K-LMS",
"width": 512
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "uu3pugtcofbn3cgac6k4aymef4",
"model": "stability-ai/stable-diffusion",
"version": "27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
"input": {
"guidance_scale": 7.5,
"height": 512,
"negative_prompt": "green",
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "multicolor hyperspace",
"prompt_strength": 0.8,
"scheduler": "K-LMS",
"width": 512
},
"logs": "Using seed: 63632\n 0%| | 0/50 [00:00<?, ?it/s]\n 4%|▍ | 2/50 [00:00<00:03, 13.41it/s]\n 8%|▊ | 4/50 [00:00<00:03, 13.57it/s]\n 12%|█▏ | 6/50 [00:00<00:03, 13.48it/s]\n 16%|█▌ | 8/50 [00:00<00:03, 13.60it/s]\n 20%|██ | 10/50 [00:00<00:02, 13.67it/s]\n 24%|██▍ | 12/50 [00:00<00:02, 13.68it/s]\n 28%|██▊ | 14/50 [00:01<00:02, 13.71it/s]\n 32%|███▏ | 16/50 [00:01<00:02, 13.68it/s]\n 36%|███▌ | 18/50 [00:01<00:02, 13.62it/s]\n 40%|████ | 20/50 [00:01<00:02, 13.47it/s]\n 44%|████▍ | 22/50 [00:01<00:02, 13.56it/s]\n 48%|████▊ | 24/50 [00:01<00:01, 13.62it/s]\n 52%|█████▏ | 26/50 [00:01<00:01, 13.53it/s]\n 56%|█████▌ | 28/50 [00:02<00:01, 13.54it/s]\n 60%|██████ | 30/50 [00:02<00:01, 13.55it/s]\n 64%|██████▍ | 32/50 [00:02<00:01, 13.49it/s]\n 68%|██████▊ | 34/50 [00:02<00:01, 13.46it/s]\n 72%|███████▏ | 36/50 [00:02<00:01, 13.52it/s]\n 76%|███████▌ | 38/50 [00:02<00:00, 13.57it/s]\n 80%|████████ | 40/50 [00:02<00:00, 13.59it/s]\n 84%|████████▍ | 42/50 [00:03<00:00, 13.33it/s]\n 88%|████████▊ | 44/50 [00:03<00:00, 13.40it/s]\n 92%|█████████▏| 46/50 [00:03<00:00, 13.36it/s]\n 96%|█████████▌| 48/50 [00:03<00:00, 13.50it/s]\n100%|██████████| 50/50 [00:03<00:00, 13.57it/s]\n100%|██████████| 50/50 [00:03<00:00, 13.54it/s]",
"output": [
"https://replicate.delivery/pbxt/2zVI7LtEO0aeKSruhERO0PQCVEsbFivhEyXyR0LDMSg3cYBIA/out-0.png"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-11-22T23:34:03.421109Z",
"started_at": "2022-11-22T23:34:03.456987Z",
"completed_at": "2022-11-22T23:34:08.104586Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/uu3pugtcofbn3cgac6k4aymef4/cancel",
"get": "https://api.replicate.com/v1/predictions/uu3pugtcofbn3cgac6k4aymef4"
},
"metrics": {
"predict_time": 4.647599,
"total_time": 4.683477
}
}