typetext
{
"prompt": "a portrait photo",
"size": "1024x1024",
"style": "realistic_image/b_and_w"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_LUq**********************************
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 recraft-ai/recraft-20b using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
prompt: "a portrait photo",
size: "1024x1024",
style: "realistic_image/b_and_w"
};
const output = await replicate.run("recraft-ai/recraft-20b", { input });
// To access the file URL:
console.log(output.url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output);
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_LUq**********************************
This is your API token. Keep it to yourself.
import replicate
Run recraft-ai/recraft-20b using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"recraft-ai/recraft-20b",
input={
"prompt": "a portrait photo",
"size": "1024x1024",
"style": "realistic_image/b_and_w"
}
)
# To access the file URL:
print(output.url())
#=> "http://example.com"
# To write the file to disk:
with open("my-image.png", "wb") as file:
file.write(output.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_LUq**********************************
This is your API token. Keep it to yourself.
Run recraft-ai/recraft-20b 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 $'{
"input": {
"prompt": "a portrait photo",
"size": "1024x1024",
"style": "realistic_image/b_and_w"
}
}' \
https://api.replicate.com/v1/models/recraft-ai/recraft-20b/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "6a284pknp5rg80ckqd9vb57t3r",
"model": "recraft-ai/recraft-20b",
"version": "hidden",
"input": {
"prompt": "a portrait photo",
"size": "1024x1024",
"style": "realistic_image/b_and_w"
},
"logs": "Running prediction... \nStarting image generation...\nModerating content...\nModeration complete in 0.20sec\nGenerated image in 4.26sec\nDownloading 276892 bytes\nDownloaded 0.26MB in 0.17sec",
"output": "https://replicate.delivery/czjl/ktMwWoliJ6K2Bx8IVQO0xAEujmdERpkAdid7ZAHCbFZqoieJA/tmpe5t63bfy.webp",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-12-12T14:43:49.297Z",
"started_at": "2024-12-12T14:43:49.305511Z",
"completed_at": "2024-12-12T14:43:53.764674Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/6a284pknp5rg80ckqd9vb57t3r/cancel",
"get": "https://api.replicate.com/v1/predictions/6a284pknp5rg80ckqd9vb57t3r",
"stream": "https://stream.replicate.com/v1/files/fddq-ildrdahs42cnzziec6luxsh5j2nunpduavth6jiv4guqkeka7wha",
"web": "https://replicate.com/p/6a284pknp5rg80ckqd9vb57t3r"
},
"metrics": {
"image_count": 1,
"predict_time": 4.459163292,
"total_time": 4.467674
}
}