typefile
{
"aspect_ratio": "match_input_image",
"blur_effect": "golden hour lighting with background blur",
"gender": "none",
"input_image": "https://replicate.delivery/pbxt/N5stdYnAreOgjBq6k40fyLDBl1tvcLFh6TZJErsQwofp1SRp/image.png"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_dzo**********************************
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 flux-kontext-apps/depth-of-field using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
aspect_ratio: "match_input_image",
blur_effect: "golden hour lighting with background blur",
gender: "none",
input_image: "https://replicate.delivery/pbxt/N5stdYnAreOgjBq6k40fyLDBl1tvcLFh6TZJErsQwofp1SRp/image.png"
};
const output = await replicate.run("flux-kontext-apps/depth-of-field", { 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_dzo**********************************
This is your API token. Keep it to yourself.
import replicate
Run flux-kontext-apps/depth-of-field using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"flux-kontext-apps/depth-of-field",
input={
"aspect_ratio": "match_input_image",
"blur_effect": "golden hour lighting with background blur",
"gender": "none",
"input_image": "https://replicate.delivery/pbxt/N5stdYnAreOgjBq6k40fyLDBl1tvcLFh6TZJErsQwofp1SRp/image.png"
}
)
# 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_dzo**********************************
This is your API token. Keep it to yourself.
Run flux-kontext-apps/depth-of-field 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",
"blur_effect": "golden hour lighting with background blur",
"gender": "none",
"input_image": "https://replicate.delivery/pbxt/N5stdYnAreOgjBq6k40fyLDBl1tvcLFh6TZJErsQwofp1SRp/image.png"
}
}' \
https://api.replicate.com/v1/models/flux-kontext-apps/depth-of-field/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "vz7zcrjxtxrm80cq3kbrrrzyfw",
"model": "flux-kontext-apps/depth-of-field",
"version": "hidden",
"input": {
"aspect_ratio": "match_input_image",
"blur_effect": "golden hour lighting with background blur",
"gender": "none",
"input_image": "https://replicate.delivery/pbxt/N5stdYnAreOgjBq6k40fyLDBl1tvcLFh6TZJErsQwofp1SRp/image.png"
},
"logs": "Prompt: Add golden hour lighting with background blur while keeping the person in the exact same position and pose. Preserve them facial features, hairstyle, clothing, and expression. Only blur the background dramatically around them.\nUsing seed: 1457176305\nGenerating...\nGenerated image in 4.7sec\nDownloading 1339123 bytes\nDownloaded 1.28MB in 0.46sec",
"output": "https://replicate.delivery/xezq/rLamPlHtB0pYLRJ1GugJhyx2fEnol11syuLj4sr73opJ2xYKA/tmp9bbhsz1x.png",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-05-29T16:19:25.783Z",
"started_at": "2025-05-29T16:19:25.792872Z",
"completed_at": "2025-05-29T16:19:31.092875Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/vz7zcrjxtxrm80cq3kbrrrzyfw/cancel",
"get": "https://api.replicate.com/v1/predictions/vz7zcrjxtxrm80cq3kbrrrzyfw",
"stream": "https://stream.replicate.com/v1/files/bcwr-vmgqnfv7g43qbrmmmroicckngfz7twlqi4a37sgciuuest3ybbpa",
"web": "https://replicate.com/p/vz7zcrjxtxrm80cq3kbrrrzyfw"
},
"metrics": {
"image_count": 1,
"predict_time": 5.300002794,
"total_time": 5.309875
}
}
