typetext
{
"aspect_ratio": "3:2",
"go_fast": true,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "jpg",
"output_quality": 80,
"prompt": "a raccoon holding up a sign that says \"replicate + vercel\""
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_F8s**********************************
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: "3:2",
go_fast: true,
megapixels: "1",
num_inference_steps: 4,
num_outputs: 1,
output_format: "jpg",
output_quality: 80,
prompt: "a raccoon holding up a sign that says \"replicate + vercel\""
};
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_F8s**********************************
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": "3:2",
"go_fast": True,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "jpg",
"output_quality": 80,
"prompt": "a raccoon holding up a sign that says \"replicate + vercel\""
}
)
# 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_F8s**********************************
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": "3:2",
"go_fast": true,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "jpg",
"output_quality": 80,
"prompt": "a raccoon holding up a sign that says \\"replicate + vercel\\""
}
}' \
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": "5jvjt6cw05rm60cjjxbr6xcpb0",
"model": "black-forest-labs/flux-schnell",
"version": "hidden",
"input": {
"aspect_ratio": "3:2",
"go_fast": true,
"megapixels": "1",
"num_inference_steps": 4,
"num_outputs": 1,
"output_format": "jpg",
"output_quality": 80,
"prompt": "a raccoon holding up a sign that says \"replicate + vercel\""
},
"logs": "Using seed: 44156\nrunning quantized prediction\nUsing seed: 44156\n 0%| | 0/4 [00:00<?, ?it/s]\n 50%|█████ | 2/4 [00:00<00:00, 19.21it/s]\n100%|██████████| 4/4 [00:00<00:00, 14.01it/s]\n100%|██████████| 4/4 [00:00<00:00, 14.59it/s]\nTotal safe images: 1 out of 1",
"output": [
"https://replicate.delivery/yhqm/fZcuCqWdjrw2USf0yUqRpkw6f8e2cRDmlz4lR5IRE7fWm07cC/out-0.jpg"
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-10-16T21:59:14.177Z",
"started_at": "2024-10-16T21:59:14.185129Z",
"completed_at": "2024-10-16T21:59:14.69039Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/5jvjt6cw05rm60cjjxbr6xcpb0/cancel",
"get": "https://api.replicate.com/v1/predictions/5jvjt6cw05rm60cjjxbr6xcpb0",
"stream": "https://stream.replicate.com/v1/files/wcdb-rpl2krthemfhlifz44bdpog2wvl36rv54thrwdalxl2xxawazlia",
"web": "https://replicate.com/p/5jvjt6cw05rm60cjjxbr6xcpb0"
},
"metrics": {
"image_count": 1,
"predict_time": 0.50526082,
"total_time": 0.51339
}
}