Image generation

Image generation

POST /v1/images/generations turns a text prompt into one or more images, OpenAI-style. It works with any image model — sdxl, flux-schnell, qwen-image.

Images are returned as base64 PNGs (b64_json). Hosted url responses are not supported yet.

Generate an image

from openai import OpenAI
import base64
 
client = OpenAI(api_key="sk-crustoff-...", base_url="https://api.crustoff.app/v1")
 
img = client.images.generate(
    model="sdxl",
    prompt="a red fox in the snow, golden hour, highly detailed",
    size="1024x1024",
)
 
with open("fox.png", "wb") as f:
    f.write(base64.b64decode(img.data[0].b64_json))

Request parameters

FieldTypeDefaultNotes
modelstringAn image model id
promptstringRequired, non-empty
nint1Number of images, 14
sizestring"1024x1024"WxH; each side 2561536, a multiple of 8
response_formatstring"b64_json"Only b64_json is supported
negative_promptstringWhat to avoid (ignored by FLUX, which is guidance-distilled)
seedintrandomSet for reproducible output
stepsintper-modelDenoising steps. Clamped to 160; defaults to 30 (SDXL) / 4 (FLUX schnell)

Response

{
  "created": 1718900000,
  "data": [
    { "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..." }
  ]
}

Each data[i].b64_json is a base64-encoded PNG. The response header x-prox-request-id correlates the request with your usage and billing.

Choosing a model

ModelSpeedNotes
sdxlFastGreat all-rounder, broad style range
flux-schnellFastestModern 12B quality in 1–4 steps
qwen-imageSlowerFlagship 20B quality, excellent text rendering

Billing

Images are billed per megapixel of output — the actual pixels, with no rounding 1024×1024 up to 2 MP like some providers. The cost is fully known before generation:

megapixels = width × height × n ÷ 1,000,000
cost       = megapixels × model_rate

A single 1024x1024 image is 1.05 MP. On sdxl ($0.0015/MP) that’s about $0.0016. See Pricing & billing for all rates.

⚠️

If generation fails on our side, you are not charged — the credit hold is released in full. A cold model may take longer on the first request while a GPU spins up.