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
| Field | Type | Default | Notes |
|---|---|---|---|
model | string | — | An image model id |
prompt | string | — | Required, non-empty |
n | int | 1 | Number of images, 1–4 |
size | string | "1024x1024" | WxH; each side 256–1536, a multiple of 8 |
response_format | string | "b64_json" | Only b64_json is supported |
negative_prompt | string | — | What to avoid (ignored by FLUX, which is guidance-distilled) |
seed | int | random | Set for reproducible output |
steps | int | per-model | Denoising steps. Clamped to 1–60; 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
| Model | Speed | Notes |
|---|---|---|
sdxl | Fast | Great all-rounder, broad style range |
flux-schnell | Fastest | Modern 12B quality in 1–4 steps |
qwen-image | Slower | Flagship 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_rateA 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.