Image Generation

POST /v1/images/generations

Generate images with the OpenAI-compatible images endpoint. Four models are available: two FLUX models billed per megapixel, and two GPT Image models billed per image at a fixed quality × size price. See Models & Pricing for the full price tables.

Requests are non-streaming: one POST, one JSON response.

$curl https://api.singularityapi.dev/v1/images/generations \
> -H "Authorization: Bearer $SINGULARITY_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "flux-1-schnell",
> "prompt": "a lighthouse at dawn, minimalist",
> "size": "1024x1024"
> }'

Response shape

FLUX models return hosted URLs (JPEG); GPT Image models return base64 (b64_json). The response follows the OpenAI images schema:

1{
2 "created": 1756600000,
3 "data": [
4 { "url": "https://v3b.fal.media/files/..." }
5 ],
6 "usage": { "input_tokens": 0, "output_tokens": 0, "total_tokens": 0 }
7}

The usage block is not meaningful for image generation — images are billed per megapixel or per image, never by tokens. The exact charge for every request is on its receipt.

Parameters

ParameterFLUX modelsGPT Image models
modelrequiredrequired
promptrequired, 1–32,000 charactersrequired, 1–32,000 characters
sizeany WIDTHxHEIGHT — each side 256–2560 px, area at most 4 megapixels (1792x1024 and 1024x1792 are not available)1024x1024, 1024x1536, or 1536x1024
qualitynot supported — the model’s default always applieslow, medium, or high
n1 only1–4 (each image billed at the grid price)
response_formaturl only (the default)not applicable — always b64_json
output_formatpng (default), jpeg, or webp
output_compression0–100; requires output_format jpeg or webp
backgroundauto, opaque, or transparent (transparent cannot combine with jpeg)
moderationauto or low
useroptional string, 1–256 characters

Omitted size and quality (and the literal value "auto") resolve to 1024x1024 and high on GPT Image models; the substitution is recorded in the request’s transformed_fields on its receipt.

stream is not supported on this endpoint. Unknown or unsupported parameters are rejected with a 400 before any charge is reserved.

Billing

Image generation charges are deterministic: the price is fixed by the request itself at admission, before the provider is called, and the receipt settles at exactly that amount.

  • FLUX models bill ceil(width × height / 2²⁰) megapixels per image at the model’s per-megapixel rate — a 1024x1024 image is 1 MP, a 1600x1024 image rounds up to 2 MP.
  • GPT Image models bill the fixed per-image price for the requested quality × size cell, multiplied by n.

The route receipt for an image request shows the surface images_generations and the exact prepaid charge; token usage is shown as not applicable.