typefile
{
"aspect_ratio": "match_input_image",
"gender": "none",
"impossible_scenario": "Floating in space as an astronaut",
"input_image": "https://replicate.delivery/pbxt/N5r0L7Cv9vSvsrRe73caYcmcj273A7LGH7oAck8y31xf1ixy/Screenshot%202025-05-02%20at%2015.21.27.png"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_acs**********************************
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/impossible-scenarios using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
aspect_ratio: "match_input_image",
gender: "none",
impossible_scenario: "Floating in space as an astronaut",
input_image: "https://replicate.delivery/pbxt/N5r0L7Cv9vSvsrRe73caYcmcj273A7LGH7oAck8y31xf1ixy/Screenshot%202025-05-02%20at%2015.21.27.png"
};
const output = await replicate.run("flux-kontext-apps/impossible-scenarios", { 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_acs**********************************
This is your API token. Keep it to yourself.
import replicate
Run flux-kontext-apps/impossible-scenarios using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"flux-kontext-apps/impossible-scenarios",
input={
"aspect_ratio": "match_input_image",
"gender": "none",
"impossible_scenario": "Floating in space as an astronaut",
"input_image": "https://replicate.delivery/pbxt/N5r0L7Cv9vSvsrRe73caYcmcj273A7LGH7oAck8y31xf1ixy/Screenshot%202025-05-02%20at%2015.21.27.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_acs**********************************
This is your API token. Keep it to yourself.
Run flux-kontext-apps/impossible-scenarios 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",
"gender": "none",
"impossible_scenario": "Floating in space as an astronaut",
"input_image": "https://replicate.delivery/pbxt/N5r0L7Cv9vSvsrRe73caYcmcj273A7LGH7oAck8y31xf1ixy/Screenshot%202025-05-02%20at%2015.21.27.png"
}
}' \
https://api.replicate.com/v1/models/flux-kontext-apps/impossible-scenarios/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "63ekgs91ksrme0cq3hsvyv2m98",
"model": "flux-kontext-apps/impossible-scenarios",
"version": "hidden",
"input": {
"aspect_ratio": "match_input_image",
"gender": "none",
"impossible_scenario": "Floating in space as an astronaut",
"input_image": "https://replicate.delivery/pbxt/N5r0L7Cv9vSvsrRe73caYcmcj273A7LGH7oAck8y31xf1ixy/Screenshot%202025-05-02%20at%2015.21.27.png"
},
"logs": "Prompt: Change the background and setting to: Floating in space as an astronaut. Keep the person in the exact same position, pose, scale, camera angle, and framing. Preserve them exact facial features, hairstyle, eye color, and facial expression. Add appropriate protective gear or outfit if needed for the scenario while maintaining them identity. Only replace the environment around them. Make it look realistic and dramatic as if them is actually in this extreme situation.\nUsing seed: 77999200\nGenerating...\nGenerated image in 5.4sec\nDownloading 1394648 bytes\nDownloaded 1.33MB in 1.28sec",
"output": "https://replicate.delivery/xezq/PTE2MLNyLOpLAl0bA4O6OCZlyEcJVJpUllHtP1LiJX7ahYMF/tmpb_svj4zf.png",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-05-29T14:29:56.766Z",
"started_at": "2025-05-29T14:29:56.780597Z",
"completed_at": "2025-05-29T14:30:03.569936Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/63ekgs91ksrme0cq3hsvyv2m98/cancel",
"get": "https://api.replicate.com/v1/predictions/63ekgs91ksrme0cq3hsvyv2m98",
"stream": "https://stream.replicate.com/v1/files/bcwr-zlzdeemciz3pebkwwi3mhrrlhoslspnnbst2gdrpyis3ctbgdilq",
"web": "https://replicate.com/p/63ekgs91ksrme0cq3hsvyv2m98"
},
"metrics": {
"predict_time": 6.789339493,
"total_time": 6.803936
}
}
