typetext
{
"aspect_ratio": "1:1",
"go_fast": true,
"guidance": 3.5,
"megapixels": "1",
"num_inference_steps": 28,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "black forest gateau cake spelling out the words \"FLUX DEV\", tasty, food photography, dynamic shot",
"prompt_strength": 0.8
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_2O5**********************************
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-dev using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
aspect_ratio: "1:1",
go_fast: true,
guidance: 3.5,
megapixels: "1",
num_inference_steps: 28,
num_outputs: 1,
output_format: "webp",
output_quality: 80,
prompt: "black forest gateau cake spelling out the words \"FLUX DEV\", tasty, food photography, dynamic shot",
prompt_strength: 0.8
};
const output = await replicate.run("black-forest-labs/flux-dev", { input });
// To access the file URL:
console.log(output[0].url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output[0]);
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_2O5**********************************
This is your API token. Keep it to yourself.
import replicate
Run black-forest-labs/flux-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-dev",
input={
"aspect_ratio": "1:1",
"go_fast": True,
"guidance": 3.5,
"megapixels": "1",
"num_inference_steps": 28,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "black forest gateau cake spelling out the words \"FLUX DEV\", tasty, food photography, dynamic shot",
"prompt_strength": 0.8
}
)
# To access the file URL:
print(output[0].url())
#=> "http://example.com"
# To write the file to disk:
with open("my-image.png", "wb") as file:
file.write(output[0].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_2O5**********************************
This is your API token. Keep it to yourself.
Run black-forest-labs/flux-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": "1:1",
"go_fast": true,
"guidance": 3.5,
"megapixels": "1",
"num_inference_steps": 28,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "black forest gateau cake spelling out the words \\"FLUX DEV\\", tasty, food photography, dynamic shot",
"prompt_strength": 0.8
}
}' \
https://api.replicate.com/v1/models/black-forest-labs/flux-dev/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "yga9jbf0ghrma0cpycs9qvvj3w",
"model": "black-forest-labs/flux-dev",
"version": "hidden",
"input": {
"aspect_ratio": "1:1",
"go_fast": true,
"guidance": 3.5,
"megapixels": "1",
"num_inference_steps": 28,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "black forest gateau cake spelling out the words \"FLUX DEV\", tasty, food photography, dynamic shot",
"prompt_strength": 0.8
},
"logs": "Using seed: 29936\nUsing seed: 29936\nGenerating 1 images...\n 0%| | 0/28 [00:00<?, ?it/s]\n 7%|▋ | 2/28 [00:00<00:01, 15.06it/s]\n 14%|█▍ | 4/28 [00:00<00:02, 11.31it/s]\n 21%|██▏ | 6/28 [00:00<00:01, 13.78it/s]\n 29%|██▊ | 8/28 [00:00<00:01, 15.39it/s]\n 39%|███▉ | 11/28 [00:00<00:00, 19.25it/s]\n 50%|█████ | 14/28 [00:00<00:00, 21.82it/s]\n 64%|██████▍ | 18/28 [00:00<00:00, 25.81it/s]\n 75%|███████▌ | 21/28 [00:01<00:00, 25.91it/s]\n 86%|████████▌ | 24/28 [00:01<00:00, 21.91it/s]\n 96%|█████████▋| 27/28 [00:01<00:00, 17.79it/s]\n100%|██████████| 28/28 [00:01<00:00, 18.26it/s]\nGeneration took 1.691025972366333 seconds\nImage generation took 1.69 seconds\nTotal safe images: 1 out of 1\nRunning safety checker took 0.02 seconds",
"output": [
"https://replicate.delivery/xezq/pvkq4S7Nx96bCdxUEK51fDCFx1Msf5UDJWItRW9VNeByPydpA/out-0.webp"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-05-21T14:15:19.94Z",
"started_at": "2025-05-21T14:15:19.946668Z",
"completed_at": "2025-05-21T14:15:21.732657Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/yga9jbf0ghrma0cpycs9qvvj3w/cancel",
"get": "https://api.replicate.com/v1/predictions/yga9jbf0ghrma0cpycs9qvvj3w",
"stream": "https://stream.replicate.com/v1/files/bcwr-diuvnwv2bohu2mmjraoesgqpedjac7hcan7yjnkhd2qrnlt5x5aq",
"web": "https://replicate.com/p/yga9jbf0ghrma0cpycs9qvvj3w"
},
"metrics": {
"image_count": 1,
"predict_time": 1.78598932,
"total_time": 1.792657
}
}