Skip to main content
POST
/
v1
/
flux-tools
/
outpainting-v1
Outpaint or extend an image
curl --request POST \
  --url https://api.bfl.ai/v1/flux-tools/outpainting-v1 \
  --header 'Content-Type: application/json' \
  --header 'x-key: <api-key>' \
  --data '
{
  "input_image": "<string>",
  "width": 65,
  "height": 65,
  "auto_crop": false,
  "safety_tolerance": 2,
  "output_format": "png",
  "prompt": "<string>",
  "reference_offset_x": 123,
  "reference_offset_y": 123,
  "mode": "high"
}
'
import requests

url = "https://api.bfl.ai/v1/flux-tools/outpainting-v1"

payload = {
"input_image": "<string>",
"width": 65,
"height": 65,
"auto_crop": False,
"safety_tolerance": 2,
"output_format": "png",
"prompt": "<string>",
"reference_offset_x": 123,
"reference_offset_y": 123,
"mode": "high"
}
headers = {
"x-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input_image: '<string>',
width: 65,
height: 65,
auto_crop: false,
safety_tolerance: 2,
output_format: 'png',
prompt: '<string>',
reference_offset_x: 123,
reference_offset_y: 123,
mode: 'high'
})
};

fetch('https://api.bfl.ai/v1/flux-tools/outpainting-v1', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.bfl.ai/v1/flux-tools/outpainting-v1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'input_image' => '<string>',
'width' => 65,
'height' => 65,
'auto_crop' => false,
'safety_tolerance' => 2,
'output_format' => 'png',
'prompt' => '<string>',
'reference_offset_x' => 123,
'reference_offset_y' => 123,
'mode' => 'high'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.bfl.ai/v1/flux-tools/outpainting-v1"

payload := strings.NewReader("{\n \"input_image\": \"<string>\",\n \"width\": 65,\n \"height\": 65,\n \"auto_crop\": false,\n \"safety_tolerance\": 2,\n \"output_format\": \"png\",\n \"prompt\": \"<string>\",\n \"reference_offset_x\": 123,\n \"reference_offset_y\": 123,\n \"mode\": \"high\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.bfl.ai/v1/flux-tools/outpainting-v1")
.header("x-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"input_image\": \"<string>\",\n \"width\": 65,\n \"height\": 65,\n \"auto_crop\": false,\n \"safety_tolerance\": 2,\n \"output_format\": \"png\",\n \"prompt\": \"<string>\",\n \"reference_offset_x\": 123,\n \"reference_offset_y\": 123,\n \"mode\": \"high\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.bfl.ai/v1/flux-tools/outpainting-v1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input_image\": \"<string>\",\n \"width\": 65,\n \"height\": 65,\n \"auto_crop\": false,\n \"safety_tolerance\": 2,\n \"output_format\": \"png\",\n \"prompt\": \"<string>\",\n \"reference_offset_x\": 123,\n \"reference_offset_y\": 123,\n \"mode\": \"high\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "polling_url": "<string>",
  "cost": 123,
  "input_mp": 123,
  "output_mp": 123
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

x-key
string
header
required

Body

application/json

Public contract for /v1/flux-tools/outpainting-v1.

input_image
string
required

Base64-encoded input (reference) image or HTTP(S) image URL.

width
integer
required

Target output width.

Required range: x >= 64
height
integer
required

Target output height.

Required range: x >= 64
auto_crop
boolean
default:false

If True, crop the input image to the canvas bounds when it extends beyond the edges. If False, an error is raised instead.

safety_tolerance
integer
default:2

Tolerance level for input and output moderation. Between 0 and 5, 0 being most strict, 5 being least strict. If you wish to increase the safety_tolerance beyond these levels please reach out to the team.

Required range: 0 <= x <= 5
output_format
enum<string> | null
default:png
Available options:
jpeg,
png,
webp
prompt
string | null

Experimental: optional text guidance for the outpainted region. The model may not strictly follow this prompt; the visual content of the input image is the primary signal. Leave unset for default behavior.

reference_offset_x
integer | null

Left offset (px) of the reference image's top-left corner on the output canvas. Negative values are allowed. None = center horizontally.

reference_offset_y
integer | null

Top offset (px) of the reference image's top-left corner on the output canvas. Negative values are allowed. None = center vertically.

mode
enum<string>
default:high

Quality/speed trade-off. 'high' (default): highest-fidelity results, recommended whenever fine detail, prompt adherence, or consistency with complex content in the source image matters; slower. 'fast': significantly faster and well-suited for naturally extending most scenes (landscapes, backgrounds, textures, products); may produce lower fidelity in the extended region than 'high'.

Available options:
high,
fast

Response

Successful Response

id
string
required
polling_url
string
required
cost
number | null

Cost in credits for this request

input_mp
number | null

Input megapixels (2 decimal places)

output_mp
number | null

Output megapixels (2 decimal places)