typetext
{
"guidance_scale": 7.5,
"height": 512,
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "hands",
"prompt_strength": 0.8,
"width": 512
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_bXn**********************************
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:be04660a5b93ef2aff61e3668dedb4cbeb14941e62a3fd5998364a32d613e35e",
{
input: {
guidance_scale: 7.5,
height: 512,
num_inference_steps: 50,
num_outputs: "1",
prompt: "hands",
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_bXn**********************************
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:be04660a5b93ef2aff61e3668dedb4cbeb14941e62a3fd5998364a32d613e35e",
input={
"guidance_scale": 7.5,
"height": 512,
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "hands",
"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_bXn**********************************
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:be04660a5b93ef2aff61e3668dedb4cbeb14941e62a3fd5998364a32d613e35e",
"input": {
"guidance_scale": 7.5,
"height": 512,
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "hands",
"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": "jkxehemsk5hb3kiluxze2sz4cu",
"model": "stability-ai/stable-diffusion",
"version": "be04660a5b93ef2aff61e3668dedb4cbeb14941e62a3fd5998364a32d613e35e",
"input": {
"guidance_scale": 7.5,
"height": 512,
"num_inference_steps": 50,
"num_outputs": "1",
"prompt": "hands",
"prompt_strength": 0.8,
"width": 512
},
"logs": "Using seed: 2317\n\n0it [00:00, ?it/s]\n2it [00:00, 12.89it/s]\n4it [00:00, 12.68it/s]\n6it [00:00, 13.06it/s]\n8it [00:00, 13.38it/s]\n10it [00:00, 13.40it/s]\n12it [00:00, 13.17it/s]\n14it [00:01, 13.45it/s]\n16it [00:01, 13.45it/s]\n18it [00:01, 13.49it/s]\n20it [00:01, 13.57it/s]\n22it [00:01, 13.63it/s]\n24it [00:01, 13.49it/s]\n26it [00:01, 13.48it/s]\n28it [00:02, 13.62it/s]\n30it [00:02, 13.57it/s]\n32it [00:02, 13.45it/s]\n34it [00:02, 13.57it/s]\n36it [00:02, 13.69it/s]\n38it [00:02, 13.58it/s]\n40it [00:02, 13.70it/s]\n42it [00:03, 13.41it/s]\n44it [00:03, 13.41it/s]\n46it [00:03, 13.53it/s]\n48it [00:03, 13.61it/s]\n50it [00:03, 13.29it/s]\n50it [00:03, 13.44it/s]",
"output": [
"https://replicate.delivery/mgxm/fa99df04-54e8-48b4-be94-659610400917/out-0.png"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-08-29T18:44:04.864663Z",
"started_at": "2022-08-29T18:44:05.059445Z",
"completed_at": "2022-08-29T18:44:09.583733Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/jkxehemsk5hb3kiluxze2sz4cu/cancel",
"get": "https://api.replicate.com/v1/predictions/jkxehemsk5hb3kiluxze2sz4cu"
},
"metrics": {
"predict_time": 4.524288,
"total_time": 4.71907
}
}