curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-pro",
"prompt": "A cinematic shot of a futuristic city at sunset, 85mm lens"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "flux-2-pro",
"prompt": "A cinematic shot of a futuristic city at sunset, 85mm lens"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'flux-2-pro',
prompt: 'A cinematic shot of a futuristic city at sunset, 85mm lens'
})
};
fetch('https://api.apiyi.com/v1/images/generations', 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.apiyi.com/v1/images/generations",
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([
'model' => 'flux-2-pro',
'prompt' => 'A cinematic shot of a futuristic city at sunset, 85mm lens'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.apiyi.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"flux-2-pro\",\n \"prompt\": \"A cinematic shot of a futuristic city at sunset, 85mm lens\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.apiyi.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"flux-2-pro\",\n \"prompt\": \"A cinematic shot of a futuristic city at sunset, 85mm lens\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"flux-2-pro\",\n \"prompt\": \"A cinematic shot of a futuristic city at sunset, 85mm lens\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}텍스트-투-이미지 API 레퍼런스
FLUX 텍스트-투-이미지 API 레퍼런스와 실시간 디버거 — OpenAI 호환 드롭인 방식으로 전체 FLUX.2 [klein/pro/max/flex] 패밀리를 지원하며, 4MP 출력과 정확한 hex 색상 제어를 제공합니다
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-pro",
"prompt": "A cinematic shot of a futuristic city at sunset, 85mm lens"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "flux-2-pro",
"prompt": "A cinematic shot of a futuristic city at sunset, 85mm lens"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'flux-2-pro',
prompt: 'A cinematic shot of a futuristic city at sunset, 85mm lens'
})
};
fetch('https://api.apiyi.com/v1/images/generations', 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.apiyi.com/v1/images/generations",
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([
'model' => 'flux-2-pro',
'prompt' => 'A cinematic shot of a futuristic city at sunset, 85mm lens'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.apiyi.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"flux-2-pro\",\n \"prompt\": \"A cinematic shot of a futuristic city at sunset, 85mm lens\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.apiyi.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"flux-2-pro\",\n \"prompt\": \"A cinematic shot of a futuristic city at sunset, 85mm lens\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"flux-2-pro\",\n \"prompt\": \"A cinematic shot of a futuristic city at sunset, 85mm lens\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}Bearer sk-xxx), 모델과 크기를 선택한 다음 prompt를 입력하여 전송합니다.- 결과 URL은 10분 동안만 유효합니다 —
data[0].url는 즉시 다운로드해야 하며, 만료된 URL은 404를 반환합니다 width/height는 16의 배수여야 합니다 — 그렇지 않으면 400을 반환합니다prompt_upsampling는 FLUX.2 [klein]에서 지원되지 않습니다 — 무시되어도 별도로 알림이 표시되지 않습니다- 총 픽셀 한도는 4MP(~2048×2048) — 초과하면 400을 반환합니다
grounding search는flux-2-max에서만 지원됩니다 — 다른 모델은 시의성이 중요한 prompt라도 실시간 검색을 트리거하지 않습니다
코드 예제
Python (OpenAI SDK 드롭인)
from openai import OpenAI
import requests
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1"
)
resp = client.images.generate(
model="flux-2-pro",
prompt="A cinematic shot of a futuristic city at sunset, 85mm lens, hyper-realistic",
size="1920x1080"
)
# data[0].url is valid for only 10 minutes — download immediately
image_url = resp.data[0].url
with open("out.jpg", "wb") as f:
f.write(requests.get(image_url, timeout=30).content)
Python (네이티브 requests · width/height 문법 포함)
import requests
API_KEY = "sk-your-api-key"
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"model": "flux-2-max",
"prompt": "Score of yesterday's Champions League final, infographic style",
"width": 1920,
"height": 1080,
"safety_tolerance": 2,
"output_format": "jpeg",
"seed": 42
},
timeout=120
).json()
image_url = response["data"][0]["url"]
with open("out.jpg", "wb") as f:
f.write(requests.get(image_url, timeout=30).content)
cURL
curl -X POST "https://api.apiyi.com/v1/images/generations" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-pro",
"prompt": "Luxury eyeshadow palette with 6 pans: top row #B76E79, #E8D5B7, #8B4789; bottom row #CD7F32, #F8F6F0, #800020",
"size": "1024x1024",
"output_format": "png"
}'
Node.js (네이티브 fetch)
import fs from 'node:fs';
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'flux-2-klein-9b',
prompt: 'A serene mountain landscape at golden hour, soft diffused light',
width: 1024,
height: 1024
})
});
const { data } = await resp.json();
// Download immediately — URL expires in 10 minutes
const img = await fetch(data[0].url);
fs.writeFileSync('out.jpg', Buffer.from(await img.arrayBuffer()));
Browser JavaScript (직접 렌더링)
{/* Demo only — production should proxy via backend to avoid leaking the key. The delivery URL has CORS disabled, so server-side download to your own CDN is recommended. */}
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'flux-2-pro',
prompt: 'Watercolor aurora borealis over Nordic mountains',
size: '1536x1024'
})
});
const { data } = await resp.json();
{/* delivery URL has CORS disabled, but <img src> works for direct rendering. Server-side download is still recommended for production. */}
document.getElementById('img').src = data[0].url;
매개변수 참조
| 매개변수 | 유형 | 필수 | 기본값 | 설명 |
|---|---|---|---|---|
model | 문자열 | 예 | — | FLUX 모델 ID, 아래 표 참조 |
prompt | 문자열 | 예 | — | Prompt, 최대 32K tokens. 자연어 및 구조화된 JSON을 지원합니다 |
size | 문자열 | 아니요 | 1024x1024 | OpenAI 스타일 크기 문자열, 예: 1920x1080 |
width | 정수 | 아니요 | 1024 | BFL 네이티브, size의 대안이며 16의 배수여야 합니다 |
height | 정수 | 아니요 | 1024 | BFL 네이티브, 16의 배수여야 합니다 |
seed | 정수 | 아니요 | random | 재현성을 위해 고정합니다 |
safety_tolerance | 정수 | 아니요 | 2 | 0(가장 엄격함) – 6(가장 허용적임) |
output_format | 문자열 | 아니요 | jpeg | jpeg / png |
prompt_upsampling | 불리언 | 아니요 | false | 프롬프트 자동 확장([klein]에서는 지원하지 않음) |
steps | 정수 | 아니요 | 50 | flux-2-flex에만 해당, 최대 50 |
guidance | 숫자 | 아니요 | 4.5 | flux-2-flex에만 해당, 1.5–10 |
n | 정수 | 아니요 | 1 | 1만 지원됩니다 |
지원되는 모델 ID
| 모델 ID | 속도 | 적합한 용도 |
|---|---|---|
flux-2-max | < 15s | 플래그십 + grounding 검색 |
flux-2-pro | < 10s | 대규모 프로덕션, 최고의 가성비 |
flux-2-flex | 더 느림 | 타이포그래피 전문 |
flux-2-klein-9b | 1초 미만 | 균형형 |
flux-2-klein-4b | 1초 미만 | 가장 빠름 |
flux-pro-1.1-ultra | 약 10s | 레거시 4MP(과거 버전 참고) |
flux-pro-1.1 | 약 5s | 레거시 1.6MP |
flux-pro | 약 6s | 1세대 프로 |
flux-dev | 약 5s | 개발/테스트 |
응답 형식
{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}
data[0].url의 유효 시간은 10분입니다- URL은
delivery-eu.bfl.ai/delivery-us.bfl.ai에 호스팅되며, 서명은 10분 후 만료됩니다 - CORS는 비활성화되어 있습니다 — 브라우저
fetch는 차단되지만,<img src>렌더링은 작동합니다 - 운영 서비스는 반드시 서버 측에서 자체 OSS / CDN으로 다운로드해야 합니다
- OpenAI의
gpt-image-2는b64_json를 반환하는 것과 달리, FLUX는 URL만 반환합니다 — base64는 없습니다.
usage 필드를 반환하지 않습니다(이미지당 과금되며, token당은 아닙니다). 실제 과금은 이 사이트의 요금표를 따릅니다. 응답 헤더 x-request-id는 지원 추적용입니다.인증
API Key from the APIYI Console
본문
FLUX model ID. For FLUX.2 prefer flux-2-pro / flux-2-max; legacy versions in the Historical Versions page.
flux-2-max, flux-2-pro, flux-2-flex, flux-2-klein-9b, flux-2-klein-4b, flux-pro-1.1-ultra, flux-pro-1.1, flux-pro, flux-dev Prompt, up to 32K tokens. Supports natural language, hex codes, and structured JSON.
"A cinematic shot of a futuristic city at sunset, 85mm lens"
OpenAI-style size string. Pick either size or width+height.
Common: 1024x1024 / 1536x1024 / 1024x1536 / 1920x1080 / 1440x2048 / 2048x2048.
Custom must satisfy: multiples of 16, 64×64–4MP.
"1920x1080"
BFL-native syntax, alternative to size. Must be a multiple of 16, between 64 and 2048.
64 <= x <= 20481920
BFL-native syntax. Must be a multiple of 16, between 64 and 2048.
64 <= x <= 20481080
Fix for reproducibility — same seed + same other params yields the same result.
42
Moderation level. 0 = strictest, 6 = most permissive, default 2.
0 <= x <= 6Output format.
jpeg, png Auto-expand the prompt. Not supported on FLUX.2 [klein] (silently ignored).
Only flux-2-flex. Inference steps, max 50.
1 <= x <= 50Only flux-2-flex. Guidance scale. 1.5–10, higher = closer to prompt.
1.5 <= x <= 10Number of images. Only 1 supported.
1 이 페이지가 도움이 되었나요?