Image Generation
Generate images with 15+ AI models through a single OpenAI-compatible endpoint.
The image generation endpoint accepts a text prompt and returns one or more generated images. All image models use the same request format β switch models by changing one parameter.
Requires authentication via Bearer token. See Authentication.
Send a JSON body with the following parameters:
The text description of the image to generate.
"prompt": "A dragon perched on a neon-lit Tokyo rooftop at midnight, cinematic lighting, 8K"
- β’Maximum length: 4,000 characters (model-dependent β some models support longer prompts)
- β’Supports English and multilingual prompts (model-dependent β
qwen-image-3-6-plushas strong multilingual support) - β’More descriptive prompts generally produce better results
The model to use for generation. See Supported Models below.
"model": "flux-1.1-pro"
- β’Defaults to
flux-1.1-proif omitted - β’Each model has different capabilities, speeds, and costs
- β’See the full model list: Models Reference
The dimensions of the generated image. Format: WIDTHxHEIGHT.
"size": "1024x1024"
Default: 1024x1024
Supported sizes vary by model:
| Model | Supported Sizes | Default |
|---|---|---|
| flux-1.1-pro | 512x512, 768x768, 1024x1024, 1024x1536, 1536x1024, 1024x2048, 2048x1024, 2048x2048 | 1024x1024 |
| qwen-image-3-6-plus | 512x512, 768x768, 1024x1024, 1024x1536, 1536x1024, 2048x2048 | 1024x1024 |
| sdxl-1.0 | 512x512, 768x768, 1024x1024 | 1024x1024 |
| ideogram-2.0 | 512x512, 1024x1024, 1024x1536, 1536x1024, 2048x2048 | 1024x1024 |
| playground-v3 | 512x512, 1024x1024, 1024x1536, 1536x1024 | 1024x1024 |
- β’Requesting an unsupported size for a model returns a
422error - β’Larger sizes cost more β see Pricing
The format of the returned image.
| Value | Description |
|---|---|
| url | Returns a temporary URL to the generated image (default). URL expires after 1 hour. |
| b64_json | Returns the image as a base64-encoded JSON string. |
Default: url
"response_format": "url"
- β’Use
b64_jsonwhen you need to process the image immediately without a second HTTP request - β’
urlresponses are faster (smaller payload) - β’URLs expire after 1 hour β download or store images promptly
| Parameter | Type | Default | Description |
|---|---|---|---|
| n | integer | 1 | Number of images to generate. Max 4. Not all models support n > 1. |
| negative_prompt | string | null | What to exclude from the image. Supported by SDXL, Playground v3. Ignored by unsupported models. |
| steps | integer | model default | Number of inference steps. Higher = more detail, slower. Range: 1β100. |
| guidance_scale | float | model default | How closely to follow the prompt. Higher = more literal. Range: 1.0β20.0. |
| seed | integer | random | Seed for reproducible generation. Same seed + same prompt + same model = same output. |
| style_preset | string | null | Style hint. Supported values vary by model. Examples: "photographic", "anime", "digital-art", "pixel-art". |
| image | string | null | Input image for img2img generation (URL or base64). See Image-to-Image. |
| strength | float | 0.75 | For img2img: how much to transform the input. 0.0 = no change, 1.0 = ignore input. Range: 0.0β1.0. |
Not all parameters are supported by all models. Unsupported parameters are silently ignored. See Models Reference for per-model parameter support.
Image generation models available through the endpoint. Prices are per generation at default resolution.
| Model ID | Provider | Max Resolution | Speed | Cost | Strengths |
|---|---|---|---|---|---|
| flux-1.1-pro | Black Forest Labs | 2048Γ2048 | ~3s | $0.03 | Best overall quality. Photorealism. Prompt adherence. |
| qwen-image-3-6-plus | Alibaba Qwen | 2048Γ2048 | ~4s | $0.02 | Asian aesthetics. Text rendering. Multilingual. |
| sdxl-1.0 | Stability AI | 1024Γ1024 | ~2s | $0.01 | Fast. Cheap. Large ecosystem. ControlNet support. |
| ideogram-2.0 | Ideogram | 2048Γ2048 | ~5s | $0.04 | Best text-in-image rendering. Typography. |
| playground-v3 | Playground AI | 1536Γ1536 | ~4s | $0.02 | Design-oriented. Clean compositions. |
More models are added regularly. See the full list at Models Hub or check the Changelog for new additions.
A successful request returns a JSON object containing the generated image(s).
Response with response_format: "url":
{
"created": 1719835200,
"data": [
{
"url": "https://cdn.fluxpool.ai/generations/img_abc123.png",
"revised_prompt": null
}
],
"model": "flux-1.1-pro",
"usage": {
"credits_used": 3,
"credits_remaining": 47
}
}
Field descriptions:
createdβ Unix timestamp of generationdataβ Array of generated image objectsdata[].urlβ Temporary URL to the image. Expires in 1 hour. Download promptly.data[].revised_promptβ The prompt as modified by the model, if applicable. Most models returnnull.modelβ The model usedusage.credits_usedβ Credits consumed by this generationusage.credits_remainingβ Your remaining credit balance
Response with response_format: "b64_json":
{
"created": 1719835200,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"model": "flux-1.1-pro",
"usage": {
"credits_used": 3,
"credits_remaining": 47
}
}
Most image models respond synchronously β the response includes the completed image. For large batches or high-resolution requests, you can use async mode to avoid timeouts.
Set the X-Fluxpool-Async: true header on your request. You'll receive a generation ID immediately. Poll for results or use Webhooks to receive a callback when complete.
Async request:
import requests
response = requests.post(
"https://api.fluxpool.ai/v1/images/generations",
headers={
"Authorization": "Bearer fp_your_api_key",
"Content-Type": "application/json",
"X-Fluxpool-Async": "true"
},
json={
"model": "flux-1.1-pro",
"prompt": "A dragon on a neon-lit Tokyo rooftop, 8K",
"size": "2048x2048"
}
)
generation = response.json()
print(generation["id"]) # "gen_xyz789"
print(generation["status"]) # "processing"
Async response:
{
"id": "gen_xyz789",
"status": "processing",
"model": "flux-1.1-pro",
"created": 1719835200
}
Polling for result:
curl https://api.fluxpool.ai/v1/generations/gen_xyz789 \
-H "Authorization: Bearer fp_your_api_key"
Completed response:
{
"id": "gen_xyz789",
"status": "completed",
"model": "flux-1.1-pro",
"created": 1719835200,
"data": [
{
"url": "https://cdn.fluxpool.ai/generations/img_abc123.png"
}
],
"usage": {
"credits_used": 5,
"credits_remaining": 42
}
}
Status values:
| Status | Description |
|---|---|
| processing | Generation is in progress |
| completed | Generation finished β data array contains results |
| failed | Generation failed β error object contains details |
For production pipelines, use Webhooks instead of polling.
Receive a POST callback when an async generation completes. Eliminates polling.
Set the X-Fluxpool-Webhook header to your callback URL:
curl https://api.fluxpool.ai/v1/images/generations \
-H "Authorization: Bearer fp_your_api_key" \
-H "Content-Type: application/json" \
-H "X-Fluxpool-Async: true" \
-H "X-Fluxpool-Webhook: https://your-app.com/api/webhook" \
-d '{
"model": "flux-1.1-pro",
"prompt": "A dragon on a neon-lit Tokyo rooftop, 8K",
"size": "2048x2048"
}'
Webhook payload (delivered to your URL):
{
"event": "generation.completed",
"id": "gen_xyz789",
"status": "completed",
"model": "flux-1.1-pro",
"data": [
{
"url": "https://cdn.fluxpool.ai/generations/img_abc123.png"
}
],
"usage": {
"credits_used": 5
},
"signature": "sha256=a1b2c3d4..."
}
Verify the signature field to confirm the webhook is from Fluxpool. See Webhooks documentation for signature verification details and retry logic.
Errors return a JSON object with an error field.
{
"error": {
"code": "invalid_model",
"message": "Model 'flux-9.9-ultra' is not available. See /docs/models for supported models.",
"type": "invalid_request_error"
}
}
Common errors:
| HTTP Status | Code | Description | Fix |
|---|---|---|---|
| 400 | invalid_request | Malformed JSON or missing required fields | Check request body format |
| 401 | unauthorized | Invalid or missing API key | Check your API key in Authentication |
| 402 | insufficient_credits | Not enough credits for this generation | Top up credits |
| 422 | invalid_parameter | Unsupported size, parameter value, or model | Check parameter constraints above |
| 422 | invalid_model | Model ID not found | See Supported Models |
| 429 | rate_limited | Too many requests | Wait and retry with exponential backoff |
| 500 | internal_error | Server error | Retry after a few seconds. If persistent, check Status |
| 503 | model_unavailable | Model temporarily unavailable | Retry or use an alternative model |
All errors include a human-readable message. Log these for debugging. Rate limits vary by plan β see Authentication for details.
Complete code examples. Copy, paste, generate.
from openai import OpenAI
client = OpenAI(
base_url="https://api.fluxpool.ai/v1",
api_key="fp_your_api_key"
)
response = client.images.generate(
model="flux-1.1-pro",
prompt="A dragon perched on a neon-lit Tokyo rooftop at midnight, cinematic lighting, 8K",
size="1024x1024"
)
print(response.data[0].url)
Switch models by changing the model parameter. Everything else stays the same.
# Qwen β great for Asian aesthetics and multilingual prompts
response = client.images.generate(
model="qwen-image-3-6-plus",
prompt="ζ°΄ε’¨η»ι£ζ Όηε±±ζ°΄η»οΌδΊιΎηΌη»ηε±±ε³°οΌδΌ η»δΈε½η»",
size="1024x1536"
)
# SDXL β fast and cheap, ControlNet compatible
response = client.images.generate(
model="sdxl-1.0",
prompt="Isometric RPG village with tavern and market, pixel art style",
size="1024x1024"
)
# Ideogram β best text rendering in images
response = client.images.generate(
model="ideogram-2.0",
prompt='A neon sign that reads "OPEN 24/7" on a rainy city street',
size="1024x1024"
)
response = client.images.generate(
model="flux-1.1-pro",
prompt="Product photo of white sneakers on marble surface, studio lighting, clean background",
size="1536x1024", # Landscape
)
# With advanced parameters (pass via extra_body)
response = client.images.generate(
model="sdxl-1.0",
prompt="Fantasy castle on a cliff at sunset, epic cinematic lighting",
size="1024x1024",
extra_body={
"negative_prompt": "blurry, low quality, distorted, watermark",
"steps": 40,
"guidance_scale": 7.5,
"seed": 42
}
)
The extra_body parameter passes additional fields through the OpenAI SDK. If using raw HTTP requests, include these fields directly in the JSON body.
Specify what to exclude from the generated image. Supported by SDXL, Playground v3.
curl https://api.fluxpool.ai/v1/images/generations \
-H "Authorization: Bearer fp_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "sdxl-1.0",
"prompt": "Professional portrait photo of a woman, natural lighting",
"size": "1024x1024",
"negative_prompt": "blurry, distorted, extra limbs, watermark, text, low quality"
}'
Models that don't support negative_prompt will silently ignore it. No error is returned.
Set n to generate multiple images from one prompt. Max 4 per request.
response = client.images.generate(
model="sdxl-1.0",
prompt="Concept art for a sci-fi weapon, clean design, white background",
size="1024x1024",
n=4
)
for i, image in enumerate(response.data):
print(f"Image {i+1}: {image.url}")
- β’Not all models support
n > 1. Check Models Reference for per-model support. - β’Cost is multiplied by n (4 images = 4Γ the per-generation cost).
- β’If a model doesn't support
n > 1, it will return a 422 error.
Transform an existing image using a text prompt. Pass the source image as a URL or base64 string.
response = client.images.generate(
model="sdxl-1.0",
prompt="Same scene but in cyberpunk style, neon lights, rain",
size="1024x1024",
extra_body={
"image": "https://example.com/your-source-image.jpg",
"strength": 0.7 # 0.0 = keep original, 1.0 = ignore original
}
)
- β’
imageβ URL or base64-encoded source image - β’
strengthβ How much to transform. 0.7 is a good starting point. Lower values preserve more of the original. - β’Supported models:
sdxl-1.0,playground-v3. Other models may add support β check Models Reference.
- β Video Generation β Generate video with the same API pattern
- β Models Reference β Full parameter support per model
- β Webhooks β Receive callbacks for async generations
- β SDKs & Libraries β Python, Node.js, and OpenAI SDK usage
- β Pricing β Per-model generation costs
- β Playground β Try image generation in the browser
Was this page helpful?
How can we improve this page?
Thanks for your feedback! π