typetext
{
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/NEwj1vl2F1gzJfNOA5edsxmIHZqf4k7Mk70jC1ps8OHRZJge/replicate-prediction-j7z0gd39z1rme0cqm1783x26sr.jpg",
"output_format": "jpg",
"prompt": "Add giant text behind the man that spells out \"REPLICATE\" in huge aesthetic letters",
"safety_tolerance": 2
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_RfL**********************************
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 black-forest-labs/flux-kontext-pro using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
aspect_ratio: "match_input_image",
input_image: "https://replicate.delivery/pbxt/NEwj1vl2F1gzJfNOA5edsxmIHZqf4k7Mk70jC1ps8OHRZJge/replicate-prediction-j7z0gd39z1rme0cqm1783x26sr.jpg",
output_format: "jpg",
prompt: "Add giant text behind the man that spells out \"REPLICATE\" in huge aesthetic letters",
safety_tolerance: 2
};
const output = await replicate.run("black-forest-labs/flux-kontext-pro", { 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_RfL**********************************
This is your API token. Keep it to yourself.
import replicate
Run black-forest-labs/flux-kontext-pro using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"black-forest-labs/flux-kontext-pro",
input={
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/NEwj1vl2F1gzJfNOA5edsxmIHZqf4k7Mk70jC1ps8OHRZJge/replicate-prediction-j7z0gd39z1rme0cqm1783x26sr.jpg",
"output_format": "jpg",
"prompt": "Add giant text behind the man that spells out \"REPLICATE\" in huge aesthetic letters",
"safety_tolerance": 2
}
)
# 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_RfL**********************************
This is your API token. Keep it to yourself.
Run black-forest-labs/flux-kontext-pro 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": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/NEwj1vl2F1gzJfNOA5edsxmIHZqf4k7Mk70jC1ps8OHRZJge/replicate-prediction-j7z0gd39z1rme0cqm1783x26sr.jpg",
"output_format": "jpg",
"prompt": "Add giant text behind the man that spells out \\"REPLICATE\\" in huge aesthetic letters",
"safety_tolerance": 2
}
}' \
https://api.replicate.com/v1/models/black-forest-labs/flux-kontext-pro/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "5s371wrad1rme0cqm1881bs6q8",
"model": "black-forest-labs/flux-kontext-pro",
"version": "hidden",
"input": {
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/NEwj1vl2F1gzJfNOA5edsxmIHZqf4k7Mk70jC1ps8OHRZJge/replicate-prediction-j7z0gd39z1rme0cqm1783x26sr.jpg",
"output_format": "jpg",
"prompt": "Add giant text behind the man that spells out \"REPLICATE\" in huge aesthetic letters",
"safety_tolerance": 2
},
"logs": "Using seed: 2137028840\nGenerating...\nGenerated image in 4.6sec\nDownloading 125076 bytes\nDownloaded 0.12MB in 0.15sec",
"output": "https://replicate.delivery/xezq/O21OhBmmmAYOHh04awFVxStHnMg31Zpb03FiG4mfw3bXGf5UA/tmp44vqmebo.jpg",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-06-24T05:01:29.576Z",
"started_at": "2025-06-24T05:01:29.584383Z",
"completed_at": "2025-06-24T05:01:34.436867Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/5s371wrad1rme0cqm1881bs6q8/cancel",
"get": "https://api.replicate.com/v1/predictions/5s371wrad1rme0cqm1881bs6q8",
"stream": "https://stream.replicate.com/v1/files/bcwr-somhlghuz574tcgel2jekpqxprruzm733nfsfzdzoipxdlpg34cq",
"web": "https://replicate.com/p/5s371wrad1rme0cqm1881bs6q8"
},
"metrics": {
"image_count": 1,
"predict_time": 4.852484828,
"total_time": 4.860867
}
}
