typetext
{
"aspect_ratio": "match_input_image",
"go_fast": true,
"guidance": 2.5,
"input_image": "https://replicate.delivery/pbxt/N5YURZv4ifaW2bMwU7hmrwzgtxf99DTQXpBeobLt1O7dEc3h/pexels-jmark-253096.jpg",
"num_inference_steps": 30,
"output_format": "jpg",
"output_quality": 80,
"prompt": "Change the car color to red, turn the headlights on"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_8Go**********************************
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-dev using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
aspect_ratio: "match_input_image",
go_fast: true,
guidance: 2.5,
input_image: "https://replicate.delivery/pbxt/N5YURZv4ifaW2bMwU7hmrwzgtxf99DTQXpBeobLt1O7dEc3h/pexels-jmark-253096.jpg",
num_inference_steps: 30,
output_format: "jpg",
output_quality: 80,
prompt: "Change the car color to red, turn the headlights on"
};
const output = await replicate.run("black-forest-labs/flux-kontext-dev", { 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_8Go**********************************
This is your API token. Keep it to yourself.
import replicate
Run black-forest-labs/flux-kontext-dev 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-dev",
input={
"aspect_ratio": "match_input_image",
"go_fast": True,
"guidance": 2.5,
"input_image": "https://replicate.delivery/pbxt/N5YURZv4ifaW2bMwU7hmrwzgtxf99DTQXpBeobLt1O7dEc3h/pexels-jmark-253096.jpg",
"num_inference_steps": 30,
"output_format": "jpg",
"output_quality": 80,
"prompt": "Change the car color to red, turn the headlights on"
}
)
# 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_8Go**********************************
This is your API token. Keep it to yourself.
Run black-forest-labs/flux-kontext-dev 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",
"go_fast": true,
"guidance": 2.5,
"input_image": "https://replicate.delivery/pbxt/N5YURZv4ifaW2bMwU7hmrwzgtxf99DTQXpBeobLt1O7dEc3h/pexels-jmark-253096.jpg",
"num_inference_steps": 30,
"output_format": "jpg",
"output_quality": 80,
"prompt": "Change the car color to red, turn the headlights on"
}
}' \
https://api.replicate.com/v1/models/black-forest-labs/flux-kontext-dev/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "stxx1vbb6srma0cqpa7amwfwrr",
"model": "black-forest-labs/flux-kontext-dev",
"version": "hidden",
"input": {
"aspect_ratio": "match_input_image",
"go_fast": true,
"guidance": 2.5,
"input_image": "https://replicate.delivery/pbxt/N5YURZv4ifaW2bMwU7hmrwzgtxf99DTQXpBeobLt1O7dEc3h/pexels-jmark-253096.jpg",
"num_inference_steps": 30,
"output_format": "jpg",
"output_quality": 80,
"prompt": "Change the car color to red, turn the headlights on"
},
"logs": "Starting generate image\nUsing seed: 16326\nTotal safe images: 1 out of 1\ngenerate image took 4.09 seconds",
"output": "https://replicate.delivery/xezq/jqLBwXkoF7JSKVMLOeTmUSxSW3fYe4SSEwHHl3Dyq9hb2R2pA/output.jpg",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-06-27T18:02:47.478Z",
"started_at": "2025-06-27T18:02:49.413874Z",
"completed_at": "2025-06-27T18:02:53.587934Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/stxx1vbb6srma0cqpa7amwfwrr/cancel",
"get": "https://api.replicate.com/v1/predictions/stxx1vbb6srma0cqpa7amwfwrr",
"stream": "https://stream.replicate.com/v1/files/bcwr-s3sagqprgkqqgfcqn37xe3awdtfzf27os4koqitn3out6ukwgwiq",
"web": "https://replicate.com/p/stxx1vbb6srma0cqpa7amwfwrr"
},
"metrics": {
"image_count": 1,
"predict_time": 4.174059952,
"total_time": 6.109934
}
}
