typetext
{
"aspect_ratio": "1:1",
"go_fast": true,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "color palette of 8 colors for a china-themed site. Include opposing complementary colors."
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_1aD**********************************
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-schnell 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,
megapixels: "1",
num_inference_steps: 4,
num_outputs: 1,
output_format: "webp",
output_quality: 80,
prompt: "color palette of 8 colors for a china-themed site. Include opposing complementary colors."
};
const output = await replicate.run("black-forest-labs/flux-schnell", { 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_1aD**********************************
This is your API token. Keep it to yourself.
import replicate
Run black-forest-labs/flux-schnell using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"black-forest-labs/flux-schnell",
input={
"aspect_ratio": "1:1",
"go_fast": True,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "color palette of 8 colors for a china-themed site. Include opposing complementary colors."
}
)
# 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_1aD**********************************
This is your API token. Keep it to yourself.
Run black-forest-labs/flux-schnell 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,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "color palette of 8 colors for a china-themed site. Include opposing complementary colors."
}
}' \
https://api.replicate.com/v1/models/black-forest-labs/flux-schnell/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "zrb89ym2r1rm80ckxf1995yxcr",
"model": "black-forest-labs/flux-schnell",
"version": "hidden",
"input": {
"aspect_ratio": "1:1",
"go_fast": true,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "webp",
"output_quality": 80,
"prompt": "color palette of 8 colors for a china-themed site. Include opposing complementary colors."
},
"logs": "Using seed: 10537\nrunning quantized prediction\nUsing seed: 10537\n 0%| | 0/4 [00:00<?, ?it/s]\n 75%|███████▌ | 3/4 [00:00<00:00, 15.41it/s]\n100%|██████████| 4/4 [00:00<00:00, 13.50it/s]\nTotal safe images: 1 out of 1",
"output": [
"https://replicate.delivery/xezq/iXMnUe43lsQgdyyT94RG4geTCR9xTgxeOXvzb7vpocHd2h6nA/out-0.webp"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-12-22T00:26:53.504Z",
"started_at": "2024-12-22T00:26:53.509269Z",
"completed_at": "2024-12-22T00:26:54.130504Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/zrb89ym2r1rm80ckxf1995yxcr/cancel",
"get": "https://api.replicate.com/v1/predictions/zrb89ym2r1rm80ckxf1995yxcr",
"stream": "https://stream.replicate.com/v1/files/bcwr-msgdj55nukllf52on4q27dr6pxpeytmqcxshqnmnvlvpj6ymb3ra",
"web": "https://replicate.com/p/zrb89ym2r1rm80ckxf1995yxcr"
},
"metrics": {
"image_count": 1,
"predict_time": 0.621234488,
"total_time": 0.626504
}
}