Image Generation

Generate images with curated 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.

Endpoint

POST https://api.fluxpool.ai/v1/images/generations

Requires authentication via Bearer token. See Authentication.

Request Body

Send a JSON body with the following parameters:

prompt string required

The text description of the image to generate.

json
"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-family models have strong multilingual support)
  • •More descriptive prompts generally produce better results

model string required

The model to use for generation. See Supported Models below.

json
"model": "flux-2-pro"
  • •Defaults to flux-2-pro if omitted
  • •Each model has different capabilities, speeds, and costs
  • •See the full model list: Models Reference

size string optional

The dimensions of the generated image. Format: WIDTHxHEIGHT.

json
"size": "1024x1024"

Default: 1024x1024

  • •Common values: 512x512, 1024x1024, 1024x1536, 1536x1024. Some models accept up to 2048x2048.
  • •Fluxpool maps size to the provider's aspect-ratio input when appropriate. You can also pass an explicit parameters.aspect_ratio for finer control.
  • •Requesting an unsupported size for a model returns a 400 error
  • •Larger sizes cost more — see Pricing

Return: presigned URL

Every image generation returns an S3 presigned URL in data[0].url. This is the canonical delivery method — Fluxpool does not currently support inline base64 responses.

  • •Presigned URLs are valid for 1 hour. Download or persist the image before it expires.
  • •The URL becomes fetchable once the generation completes — see Async & polling below.
  • •To check readiness cheaply, do GET the URL with header Range: bytes=0-0 (S3 presigned GET URLs reject HEAD).

Additional Parameters

Parameter Type Default Description
parameters.aspect_ratiostringnullExplicit aspect ratio override (e.g. "16:9", "1:1"). Takes precedence over size when both are provided.
parameters.negative_promptstringnullWhat to exclude from the image. Passed through to models that support it; ignored otherwise.
parameters.seedintegerrandomSeed for reproducible output when the underlying model supports seeding.
inputsobject[]nullPreferred shape. Each item is {type, source, value}. source: "url" for hosted images, source: "data" for base64 data-URIs (server uploads them inline; ~4.5MB decoded cap per item). See Image-to-Image.
input_imagesstring[]nullLegacy. Prefer inputs. Array of https:// URLs for image-to-image workflows, kept for backwards compatibility.
edit_modestringnullEditing mode flag for supported edit-capable models.

Not all parameters are supported by all models. Unsupported parameters are silently ignored. See Models Reference for per-model parameter support.

Supported Models

The live catalog of image models is served by the API. Call GET /v1/models to see everything you can call today and pick a model whose id to pass in the model parameter.

Model ID Notes
flux-2-proVerified example — safe default for testing the endpoint.
seedream-5.0, seedream-5.0-flash, flux-2-max, flux-2-klein, qwen-image-2.0-pro, qwen-image-maxAlso available; fetch GET /v1/models for the authoritative list.

More models are added regularly. See Models Reference for the up-to-date catalog and the Changelog for new additions.

Response

A successful request returns a JSON object with a generation id, a top-level status, and a data[] array containing at least one presigned S3 URL.

json
{
  "created": 1785845810,
  "id": "6dcc89ce-964e-466e-8100-ba2bdfb6d07c",
  "status": "pending",
  "model": "flux-2-pro",
  "type": "image",
  "data": [
    {
      "url": "https://fluxpool-output.s3.ap-southeast-1.amazonaws.com/...?X-Amz-...",
      "generation_id": "6dcc89ce-964e-466e-8100-ba2bdfb6d07c",
      "status": "pending",
      "model": "flux-2-pro",
      "revised_prompt": null
    }
  ]
}

Field descriptions:

  • id — Generation ID. Use this to poll GET /v1/generations/{id}.
  • status — One of pending, processing, completed, failed.
  • created — Unix timestamp the generation was accepted.
  • type — image for this endpoint.
  • data[].url — Presigned S3 URL. Becomes fetchable once the generation completes; expires 1 hour after issue.
  • data[].revised_prompt — Prompt as revised by the model, if applicable. Usually null.

Async Generation

Image generations on Fluxpool are always asynchronous. The POST returns immediately with a generation id, a top-level status, and a presigned S3 URL that becomes fetchable once the image is ready.

You have two ways to check completion — poll the presigned URL directly, or poll the structured status endpoint.

Option 1 — poll the generation status endpoint:

bash
curl https://api.fluxpool.ai/v1/generations/6dcc89ce-964e-466e-8100-ba2bdfb6d07c \
  -H "Authorization: Bearer fp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Option 2 — poll the presigned S3 URL directly (cheapest with a byte-range GET):

bash
curl -I --range 0-0 "https://fluxpool-output.s3.ap-southeast-1.amazonaws.com/...?X-Amz-..."

Note: S3 presigned GET URLs reject HEAD with a 403. Use GET with Range: bytes=0-0 for a cheap readiness probe.

Status values:

Status Description
processingGeneration is in progress
completedGeneration finished — data array contains results
failedGeneration failed — error object contains details

Webhook delivery is on the roadmap — see Async & polling. Until then, poll one of the two endpoints above.

Error Handling

Errors return a JSON object with an error field.

json
{
  "error": {
    "code": "invalid_model",
    "message": "Model 'flux-9.9-ultra' is not available.",
    "type": "invalid_request_error"
  }
}
HTTP Status Code Description Fix
400invalid_requestMalformed JSON or missing required fieldsCheck request body format
401unauthorizedInvalid or missing API keyCheck your API key in Authentication
402insufficient_creditsNot enough credits for this generationTop up credits
422invalid_parameterUnsupported size, parameter value, or modelCheck parameter constraints above
429CONCURRENCY_LIMIT_REACHEDAll of your plan's generations are runningWait for one to finish, then retry with exponential backoff
500internal_errorServer errorRetry after a few seconds with exponential backoff
503model_unavailableModel temporarily unavailableRetry or use an alternative model

All errors include a human-readable message. How many generations can run at once depends on your plan — see Limits.

Examples

Complete code examples. Copy, paste, generate.

Basic Image Generation

from openai import OpenAI

client = OpenAI(base_url="https://api.fluxpool.ai/v1", api_key="fp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

response = client.images.generate(
    model="flux-2-pro",
    prompt="A dragon perched on a neon-lit Tokyo rooftop at midnight, cinematic lighting, 8K",
    size="1024x1024"
)
print(response.data[0].url)

Image-to-Image (img2img)

Transform an existing image using a text prompt.

python
response = client.images.generate(
    model="flux-2-pro",
    prompt="Same scene but in cyberpunk style, neon lights, rain",
    size="1024x1024",
    extra_body={"input_images": ["https://your-cdn.com/source-image.jpg"]}
)

Inline images (no upload step)

Skip the upload step by passing a base64 data URI in the new inputs field. The server decodes it and stores the file for the generation. Cap is ~4.5 MB decoded per item; larger images should be resized client-side or uploaded via the two-step flow.

python
import base64

with open("source.png", "rb") as f:
    data_uri = f"data:image/png;base64,{base64.b64encode(f.read()).decode()}"

response = client.images.generate(
    model="flux-2-pro",
    prompt="Same scene but in cyberpunk style, neon lights, rain",
    extra_body={"inputs": [{"type": "image", "source": "data", "value": data_uri}]}
)

Payloads over ~13 MB (encoded) are refused by the gateway before they reach us. Between ~6 MB and 13 MB encoded, our own HTTP 413 fires with a message pointing at the two-step upload path.

Next Steps

Was this page helpful?