typetext
{
"aspect_ratio": "1:1",
"prompt": "Close-up macro photograph of a fresh strawberry on a white background, water droplets on the surface, vibrant red color, sharp detail on seeds and texture, clean food photography with soft diffused lighting"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_ALW**********************************
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-v4 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
aspect_ratio: "1:1",
prompt: "Close-up macro photograph of a fresh strawberry on a white background, water droplets on the surface, vibrant red color, sharp detail on seeds and texture, clean food photography with soft diffused lighting"
};
const output = await replicate.run("recraft-ai/recraft-v4", { 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_ALW**********************************
This is your API token. Keep it to yourself.
import replicate
Run recraft-ai/recraft-v4 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"recraft-ai/recraft-v4",
input={
"aspect_ratio": "1:1",
"prompt": "Close-up macro photograph of a fresh strawberry on a white background, water droplets on the surface, vibrant red color, sharp detail on seeds and texture, clean food photography with soft diffused lighting"
}
)
# 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_ALW**********************************
This is your API token. Keep it to yourself.
Run recraft-ai/recraft-v4 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": {
"aspect_ratio": "1:1",
"prompt": "Close-up macro photograph of a fresh strawberry on a white background, water droplets on the surface, vibrant red color, sharp detail on seeds and texture, clean food photography with soft diffused lighting"
}
}' \
https://api.replicate.com/v1/models/recraft-ai/recraft-v4/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "1ryfjv4t1xrmr0cwe6vrzdqr0w",
"model": "recraft-ai/recraft-v4",
"version": "hidden",
"input": {
"aspect_ratio": "1:1",
"prompt": "Close-up macro photograph of a fresh strawberry on a white background, water droplets on the surface, vibrant red color, sharp detail on seeds and texture, clean food photography with soft diffused lighting"
},
"logs": "Moderating content...\nWarning: Moderation check failed\nStarting image generation...\nGenerated image in 40.37sec\nDownloading 1375792 bytes\nDownloaded 1.31MB in 0.14sec",
"output": "https://replicate.delivery/xezq/4cruQdIZtlalOJw26lYVpY6zlIgyYzTSgdrQrs6qiGOujOiF/tmpl929pvrx.webp",
"data_removed": false,
"error": null,
"source": "api",
"status": "succeeded",
"created_at": "2026-02-18T17:06:23.887Z",
"started_at": "2026-02-18T17:06:23.897344Z",
"completed_at": "2026-02-18T17:07:04.693319Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/1ryfjv4t1xrmr0cwe6vrzdqr0w/cancel",
"get": "https://api.replicate.com/v1/predictions/1ryfjv4t1xrmr0cwe6vrzdqr0w",
"stream": "https://stream.replicate.com/v1/files/jbxs-mi3ralc5rygefnftmokhzxy77muxgplj6smugdwcxzhfm3d7f3ha",
"web": "https://replicate.com/p/1ryfjv4t1xrmr0cwe6vrzdqr0w"
},
"metrics": {
"predict_time": 40.795974719,
"total_time": 40.806319022
}
}