typetext
{
"prompt": "a wildlife photography photo of a red panda using a laptop in a snowy forest",
"size": "1365x1024",
"style": "any"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_bis**********************************
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-v3 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
prompt: "a wildlife photography photo of a red panda using a laptop in a snowy forest",
size: "1365x1024",
style: "any"
};
const output = await replicate.run("recraft-ai/recraft-v3", { 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_bis**********************************
This is your API token. Keep it to yourself.
import replicate
Run recraft-ai/recraft-v3 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"recraft-ai/recraft-v3",
input={
"prompt": "a wildlife photography photo of a red panda using a laptop in a snowy forest",
"size": "1365x1024",
"style": "any"
}
)
# 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_bis**********************************
This is your API token. Keep it to yourself.
Run recraft-ai/recraft-v3 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 wildlife photography photo of a red panda using a laptop in a snowy forest",
"size": "1365x1024",
"style": "any"
}
}' \
https://api.replicate.com/v1/models/recraft-ai/recraft-v3/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "0j1q9mjh81rga0cjvvdv5b3jdr",
"model": "recraft-ai/recraft-v3",
"version": "hidden",
"input": {
"prompt": "a wildlife photography photo of a red panda using a laptop in a snowy forest",
"size": "1365x1024",
"style": "any"
},
"logs": "Running prediction... \nStarting image generation...\nGenerated image in 8.53sec",
"output": "https://replicate.delivery/czjl/eTxDZunLeFulD0734CMCIuhP6llmZbgtbxfjzyfi4hxAAOwOB/output.webp",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-10-30T19:16:08.128Z",
"started_at": "2024-10-30T19:16:08.13524Z",
"completed_at": "2024-10-30T19:16:16.95991Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/0j1q9mjh81rga0cjvvdv5b3jdr/cancel",
"get": "https://api.replicate.com/v1/predictions/0j1q9mjh81rga0cjvvdv5b3jdr",
"stream": "https://stream.replicate.com/v1/files/fddq-7326dxea6ozw4hqyed6qj6xjgzl3jfvkfswh4a3otrx3h5f2wrgq",
"web": "https://replicate.com/p/0j1q9mjh81rga0cjvvdv5b3jdr"
},
"metrics": {
"image_count": 1,
"predict_time": 8.824670026,
"total_time": 8.83191
}
}