Skip to main content
POST
/
images
/
generations
Image Generation
curl --request POST \
  --url https://api.siliconflow.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "black-forest-labs/FLUX.2-pro",
  "prompt": "A serene landscape with mountains and a lake at sunset",
  "image_size": "512x512"
}
'
import requests

url = "https://api.siliconflow.com/v1/images/generations"

payload = {
"model": "black-forest-labs/FLUX.2-pro",
"prompt": "A serene landscape with mountains and a lake at sunset",
"image_size": "512x512"
}
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: 'black-forest-labs/FLUX.2-pro',
prompt: 'A serene landscape with mountains and a lake at sunset',
image_size: '512x512'
})
};

fetch('https://api.siliconflow.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
{
  "images": [
    {
      "url": "<string>"
    }
  ],
  "timings": {
    "inference": 123
  },
  "seed": 123
}
{
"code": 20012,
"message": "<string>",
"data": "<string>"
}
"Invalid token"
"404 page not found"
{
"message": "Request was rejected due to rate limiting. If you want more, please contact contact@siliconflow.com. Details:TPM limit reached.",
"data": "<string>"
}
{
"code": 50505,
"message": "Model service overloaded. Please try again later.",
"data": "<string>"
}
"<string>"

Authorizations

Authorization
string
header
required

Use the following format for authentication: Bearer

Body

application/json
model
enum<string>
default:black-forest-labs/FLUX.2-pro
required

Corresponding Model Name. To better enhance service quality, we will make periodic changes to the models provided by this service, including but not limited to model on/offlining and adjustments to model service capabilities. We will notify you of such changes through appropriate means such as announcements or message pushes where feasible.

Available options:
black-forest-labs/FLUX.2-pro
prompt
string
required

The text prompt describing the image to generate.

Example:

"A serene landscape with mountains and a lake at sunset"

image_size
enum<string>
default:512x512

Image resolution in "widthxheight" format. Supported resolutions:

  • "512x512" (1:1)
  • "768x1024" (3:4)
  • "1024x768" (4:3)
  • "576x1024" (9:16)
  • "1024x576" (16:9)
Available options:
512x512,
768x1024,
1024x768,
576x1024,
1024x576
seed
integer

Random seed for reproducible generation. If not specified, a random seed will be used.

Required range: 0 <= x <= 9999999999
output_format
enum<string>
default:png

Output format for the generated image.

Available options:
png,
jpeg

Response

200

images
object[]
timings
object
seed
integer