生成图片
curl --request POST \
--url https://ai.alad.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-flex",
"prompt": "一只可爱的北极熊宝宝",
"n": 1,
"size": "1024x1024",
"inference_steps": 25,
"guidance_scale": 5.75,
"output_format": "jpeg",
"seed": 123
}
'import requests
url = "https://ai.alad.com/v1/images/generations"
payload = {
"model": "flux-2-flex",
"prompt": "一只可爱的北极熊宝宝",
"n": 1,
"size": "1024x1024",
"inference_steps": 25,
"guidance_scale": 5.75,
"output_format": "jpeg",
"seed": 123
}
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-flex',
prompt: '一只可爱的北极熊宝宝',
n: 1,
size: '1024x1024',
inference_steps: 25,
guidance_scale: 5.75,
output_format: 'jpeg',
seed: 123
})
};
fetch('https://ai.alad.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://ai.alad.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-flex',
'prompt' => '一只可爱的北极熊宝宝',
'n' => 1,
'size' => '1024x1024',
'inference_steps' => 25,
'guidance_scale' => 5.75,
'output_format' => 'jpeg',
'seed' => 123
]),
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://ai.alad.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"flux-2-flex\",\n \"prompt\": \"一只可爱的北极熊宝宝\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"inference_steps\": 25,\n \"guidance_scale\": 5.75,\n \"output_format\": \"jpeg\",\n \"seed\": 123\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://ai.alad.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"flux-2-flex\",\n \"prompt\": \"一只可爱的北极熊宝宝\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"inference_steps\": 25,\n \"guidance_scale\": 5.75,\n \"output_format\": \"jpeg\",\n \"seed\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.alad.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-flex\",\n \"prompt\": \"一只可爱的北极熊宝宝\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"inference_steps\": 25,\n \"guidance_scale\": 5.75,\n \"output_format\": \"jpeg\",\n \"seed\": 123\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"b64_json": "<string>"
}
]
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Black Forest Labs
flux-2-flex
使用 FLUX.2 [flex] 根据文本描述生成图片。提供精细的采样步数和引导系数控制。接口为同步调用,直接返回 Base64 编码的图片数据。
POST
/
v1
/
images
/
generations
生成图片
curl --request POST \
--url https://ai.alad.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-flex",
"prompt": "一只可爱的北极熊宝宝",
"n": 1,
"size": "1024x1024",
"inference_steps": 25,
"guidance_scale": 5.75,
"output_format": "jpeg",
"seed": 123
}
'import requests
url = "https://ai.alad.com/v1/images/generations"
payload = {
"model": "flux-2-flex",
"prompt": "一只可爱的北极熊宝宝",
"n": 1,
"size": "1024x1024",
"inference_steps": 25,
"guidance_scale": 5.75,
"output_format": "jpeg",
"seed": 123
}
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-flex',
prompt: '一只可爱的北极熊宝宝',
n: 1,
size: '1024x1024',
inference_steps: 25,
guidance_scale: 5.75,
output_format: 'jpeg',
seed: 123
})
};
fetch('https://ai.alad.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://ai.alad.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-flex',
'prompt' => '一只可爱的北极熊宝宝',
'n' => 1,
'size' => '1024x1024',
'inference_steps' => 25,
'guidance_scale' => 5.75,
'output_format' => 'jpeg',
'seed' => 123
]),
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://ai.alad.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"flux-2-flex\",\n \"prompt\": \"一只可爱的北极熊宝宝\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"inference_steps\": 25,\n \"guidance_scale\": 5.75,\n \"output_format\": \"jpeg\",\n \"seed\": 123\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://ai.alad.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"flux-2-flex\",\n \"prompt\": \"一只可爱的北极熊宝宝\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"inference_steps\": 25,\n \"guidance_scale\": 5.75,\n \"output_format\": \"jpeg\",\n \"seed\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.alad.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-flex\",\n \"prompt\": \"一只可爱的北极熊宝宝\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"inference_steps\": 25,\n \"guidance_scale\": 5.75,\n \"output_format\": \"jpeg\",\n \"seed\": 123\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"b64_json": "<string>"
}
]
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
模型 ID
可用选项:
flux-2-flex 示例:
"flux-2-flex"
图片描述文字。
示例:
"一只可爱的北极熊宝宝"
生成图片数量。
必填范围:
1 <= x <= 4输出图片尺寸,如 1024x1024。支持最高 4MP 分辨率。
示例:
"1024x1024"
采样步数。低步数(6–20)用于快速原型,高步数(40–50)用于极致保真。
必填范围:
1 <= x <= 50引导缩放系数。控制模型对 Prompt 的遵循程度,数值越高越忠实于提示词。
必填范围:
1.5 <= x <= 10输出图片格式。
可用选项:
jpeg, png 示例:
"jpeg"
随机种子,用于复现生成结果。
⌘I

