typetext
{
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/N85DT7DeS0c7yTurCvbrQykspgMspu5E6g3ezo4ELzMe9K5C/rcc-hero2.jpg",
"output_format": "jpg",
"prompt": "Build stack several copies of this handheld video game device to a living room",
"safety_tolerance": 6
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_dcF**********************************
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-max 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/N85DT7DeS0c7yTurCvbrQykspgMspu5E6g3ezo4ELzMe9K5C/rcc-hero2.jpg",
output_format: "jpg",
prompt: "Build stack several copies of this handheld video game device to a living room",
safety_tolerance: 6
};
const output = await replicate.run("black-forest-labs/flux-kontext-max", { 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_dcF**********************************
This is your API token. Keep it to yourself.
import replicate
Run black-forest-labs/flux-kontext-max 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-max",
input={
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/N85DT7DeS0c7yTurCvbrQykspgMspu5E6g3ezo4ELzMe9K5C/rcc-hero2.jpg",
"output_format": "jpg",
"prompt": "Build stack several copies of this handheld video game device to a living room",
"safety_tolerance": 6
}
)
# 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_dcF**********************************
This is your API token. Keep it to yourself.
Run black-forest-labs/flux-kontext-max 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/N85DT7DeS0c7yTurCvbrQykspgMspu5E6g3ezo4ELzMe9K5C/rcc-hero2.jpg",
"output_format": "jpg",
"prompt": "Build stack several copies of this handheld video game device to a living room",
"safety_tolerance": 6
}
}' \
https://api.replicate.com/v1/models/black-forest-labs/flux-kontext-max/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "sm7zstngn5rma0cq7jyvdhttqm",
"model": "black-forest-labs/flux-kontext-max",
"version": "hidden",
"input": {
"aspect_ratio": "match_input_image",
"input_image": "https://replicate.delivery/pbxt/N85DT7DeS0c7yTurCvbrQykspgMspu5E6g3ezo4ELzMe9K5C/rcc-hero2.jpg",
"output_format": "jpg",
"prompt": "Build stack several copies of this handheld video game device to a living room",
"safety_tolerance": 6
},
"logs": "Using seed: 1569400216\nWarning: Setting safety tolerance to 2. 2 is the maximum allowed when input images are used.\nGenerating...\nGenerated image in 5.0sec\nDownloading 76636 bytes\nDownloaded 0.07MB in 0.12sec",
"output": "https://replicate.delivery/xezq/Mw9Zshm6D3ZfcSNmBpe5BQ8X6huFOMqxmx27LNI06DTnWmzUA/tmpc30x4mj_.jpg",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-06-04T20:59:13.961Z",
"started_at": "2025-06-04T20:59:13.975363Z",
"completed_at": "2025-06-04T20:59:19.191193Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/sm7zstngn5rma0cq7jyvdhttqm/cancel",
"get": "https://api.replicate.com/v1/predictions/sm7zstngn5rma0cq7jyvdhttqm",
"stream": "https://stream.replicate.com/v1/files/bcwr-3azsm6ecyneopxadxvjxgjqzbls7n5gdm4aei53y4dpatsapbo7q",
"web": "https://replicate.com/p/sm7zstngn5rma0cq7jyvdhttqm"
},
"metrics": {
"image_count": 1,
"predict_time": 5.215829685,
"total_time": 5.230193
}
}
