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": "hi hi hihi hi",
"prompt_strength": 0.8
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_Cls**********************************
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: "hi hi hihi hi",
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_Cls**********************************
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": "hi hi hihi hi",
"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_Cls**********************************
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": "hi hi hihi hi",
"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": "f9paxh23mdrm40cj8tb820h35c",
"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": "hi hi hihi hi",
"prompt_strength": 0.8
},
"logs": "Using seed: 55652\nrunning quantized prediction\nUsing seed: 55652\n 0%| | 0/28 [00:00<?, ?it/s]\n 7%|▋ | 2/28 [00:00<00:01, 17.84it/s]\n 14%|█▍ | 4/28 [00:00<00:01, 12.75it/s]\n 21%|██▏ | 6/28 [00:00<00:01, 11.72it/s]\n 29%|██▊ | 8/28 [00:00<00:01, 11.29it/s]\n 36%|███▌ | 10/28 [00:00<00:01, 10.98it/s]\n 43%|████▎ | 12/28 [00:01<00:01, 10.64it/s]\n 50%|█████ | 14/28 [00:01<00:01, 10.62it/s]\n 57%|█████▋ | 16/28 [00:01<00:01, 10.62it/s]\n 64%|██████▍ | 18/28 [00:01<00:00, 10.64it/s]\n 71%|███████▏ | 20/28 [00:01<00:00, 10.60it/s]\n 79%|███████▊ | 22/28 [00:02<00:00, 10.53it/s]\n 86%|████████▌ | 24/28 [00:02<00:00, 10.49it/s]\n 93%|█████████▎| 26/28 [00:02<00:00, 10.51it/s]\n100%|██████████| 28/28 [00:02<00:00, 10.56it/s]\n100%|██████████| 28/28 [00:02<00:00, 10.85it/s]\nTotal safe images: 1 out of 1",
"output": [
"https://replicate.delivery/yhqm/HV9AYOH2iQ6GJxYANZtrozLrLdMfk5ufSUFVnfP5eJaQNPJOB/out-0.webp"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-10-01T05:38:25.827Z",
"started_at": "2024-10-01T05:38:25.836148Z",
"completed_at": "2024-10-01T05:38:28.732749Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/f9paxh23mdrm40cj8tb820h35c/cancel",
"get": "https://api.replicate.com/v1/predictions/f9paxh23mdrm40cj8tb820h35c",
"web": "https://replicate.com/p/f9paxh23mdrm40cj8tb820h35c"
},
"metrics": {
"image_count": 1,
"predict_time": 2.8966006760000003,
"total_time": 2.905749
}
}