typetext
{
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/N5aGRw0RvD6NwrlvPjxf2UniUptMlUT8hJIAY7rwP2LBtUvD/34c783b5-6aa2-4019-839b-8fa7a41fbb6d.jpg",
"prompt": "Change the text in the sunglasses to be \"FLUX\" and \"Kontrast\""
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_csz**********************************
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/N5aGRw0RvD6NwrlvPjxf2UniUptMlUT8hJIAY7rwP2LBtUvD/34c783b5-6aa2-4019-839b-8fa7a41fbb6d.jpg",
prompt: "Change the text in the sunglasses to be \"FLUX\" and \"Kontrast\""
};
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_csz**********************************
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/N5aGRw0RvD6NwrlvPjxf2UniUptMlUT8hJIAY7rwP2LBtUvD/34c783b5-6aa2-4019-839b-8fa7a41fbb6d.jpg",
"prompt": "Change the text in the sunglasses to be \"FLUX\" and \"Kontrast\""
}
)
# 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_csz**********************************
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/N5aGRw0RvD6NwrlvPjxf2UniUptMlUT8hJIAY7rwP2LBtUvD/34c783b5-6aa2-4019-839b-8fa7a41fbb6d.jpg",
"prompt": "Change the text in the sunglasses to be \\"FLUX\\" and \\"Kontrast\\""
}
}' \
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": "066zmn9m89rma0cq31xvfqxckm",
"model": "black-forest-labs/flux-kontext-pro",
"version": "hidden",
"input": {
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/N5aGRw0RvD6NwrlvPjxf2UniUptMlUT8hJIAY7rwP2LBtUvD/34c783b5-6aa2-4019-839b-8fa7a41fbb6d.jpg",
"prompt": "Change the text in the sunglasses to be \"FLUX\" and \"Kontrast\""
},
"logs": "Using seed: 1428177381\nGenerating...\nGenerated image in 5.1sec\nDownloading 1850558 bytes\nDownloaded 1.76MB in 1.38sec",
"output": "https://replicate.delivery/xezq/ciuGVzooEOquOdFbShoelKkPJGMkjoFRcab4GXzbFn6r6oYKA/tmpuxoqul4e.png",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-05-28T20:00:16.962Z",
"started_at": "2025-05-28T20:00:16.970771Z",
"completed_at": "2025-05-28T20:00:23.579003Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/066zmn9m89rma0cq31xvfqxckm/cancel",
"get": "https://api.replicate.com/v1/predictions/066zmn9m89rma0cq31xvfqxckm",
"stream": "https://stream.replicate.com/v1/files/bcwr-lutexeyjm7tistydtoylgtec5am37c7dihtnrkomhrgihr2qz43q",
"web": "https://replicate.com/p/066zmn9m89rma0cq31xvfqxckm"
},
"metrics": {
"image_count": 1,
"predict_time": 6.608232059,
"total_time": 6.617003
}
}
