View as /docs.md
Inference

Image generation

Text-to-image and image-to-image generation through the OpenAI-shape /v1/images/generations endpoint. Swap models by ID — Black Forest Labs Flux, DALL-E 3, Google Imagen 3, Stable Diffusion XL, Ideogram, Recraft. Cheap edge models return inline; the heaviest frontier models use async jobs.

Generate an image

POST /v1/images/generations
{
  "model": "bfl/flux-2-klein-9b",
  "prompt": "a neon ramen shop in the rain, cinematic, 35mm",
  "size": "1024x1024",
  "n": 1,
  "response_format": "url"
}
// → { "created": ..., "data": [{ "url": "https://media.aigateway.sh/..." }] }

Picking a model

ModelStrength
bfl/flux-2-klein-9bFast, photorealistic, cheap — great default.
bfl/flux-2-proTop-quality Flux, slower, higher cost.
openai/dall-e-3Strong prompt adherence, good typography.
google/imagen-3Best hands + anatomy, photorealism.
stability-ai/sdxlOpen-weight, tune with custom LoRAs via BYOK.
ideogram/ideogram-v3Best-in-class text rendering in images.

Response formats

response_format accepts "url" (default — 24h-signed URL from media.aigateway.sh) or "b64_json" (inline base64, ideal for serverless).

Image-to-image + edits

/v1/images/edits takes a source image file + optional mask. Supported on Flux, SDXL, and DALL-E — the gateway translates to each provider's native editing API.

Async / long-running models

High-quality text-to-video models and the heaviest Flux variants run on the async-job pattern — submit returns 202, poll or webhook on completion. The body shape is the same; the gateway auto-detects which pattern a given model needs.