v1

latestOpenAPI 3.1.0MIT2026-07-262861121.0 KB

Creates an image generation for the provided prompt (OpenAI-compatible). For unauthenticated accountless x402 quote requests, include x-x402: true.

post/v1/images/generations

Headers

x-x402'true'

Set to true on unauthenticated accountless x402 quote requests. Without this header, unauthenticated requests return 401 missing_api_key.

Request body

modelstring

The model to use for generation

promptstring required

The text prompt to generate an image from

ninteger

Number of images to generate

sizestring

Requested output size or model-specific resolution value. Use GET /api/v1/image-models?detailed=true and read supported_parameters.resolutions for the selected model's supported values.

response_format'url' | 'b64_json'

The format in which the generated images are returned. Use "b64_json" (default) to receive base64-encoded image bytes in data[i].b64_json, or "url" to receive a time-limited, signed download URL in data[i].url (expires after a short period, currently ~1 hour). Note: When requesting "url", the API may still return "b64_json" if URL generation (upload/presign) fails, as a fallback.

userstring

A unique identifier representing your end-user

imageDataUrlstring

Base64-encoded image data URL for img2img generation. Single image input for models that support image-to-image transformation. Format: data:image/[type];base64,[data]. Note: Direct URL input is not supported - images must be converted to base64 data URLs before submission.

imageDataUrlsstring[]

Array of base64-encoded image data URLs for models supporting multiple image inputs (e.g., flux-kontext, gpt-4o-image, gpt-image-1). Each URL must follow the format: data:image/[type];base64,[data]

maskDataUrlstring

Base64-encoded mask image data URL for inpainting models (e.g., flux-lora/inpainting). White areas indicate regions to edit. Format: data:image/[type];base64,[data]

strengthnumber

Controls how much the output differs from the input image in img2img mode. Lower values produce outputs closer to the input.

guidance_scalenumber

How closely the model follows the text prompt. Higher values result in images more closely aligned with the prompt.

num_inference_stepsinteger

Number of denoising steps. More steps generally produce higher quality but take longer.

seedinteger

Optional model-specific seed that may improve reproducibility where supported by the model/provider route. Identical results are not guaranteed. Check the selected model's supported_parameters metadata before using this field.

kontext_max_modeboolean

Enable enhanced context mode for flux-kontext model. Provides better understanding of input images.

Example request

{
  "size": "1024x1024",
  "imageDataUrl": "data:image/jpeg;base64,/9j/4AAQ...",
  "imageDataUrls": [
    "data:image/jpeg;base64,/9j/4AAQ...",
    "data:image/png;base64,iVBORw0KGgo..."
  ],
  "maskDataUrl": "data:image/png;base64,iVBORw0KGgo...",
  "seed": 42
}

Response

Image generation response. Each data[i] contains either { url } or { b64_json }. When requesting response_format: "url", the API may fall back to returning { b64_json } if URL generation (upload/presign) fails.

createdinteger

Unix timestamp of when the image was created

costnumber

Cost of the generation

paymentSourcestring

Payment source used

remainingBalancenumber

Remaining balance after the generation

Example response

{
  "data": [
    {
      "url": "https://...signed-url..."
    }
  ]
}