Image generation

Generate an image from a text prompt. RelayX serves the result from its own R2 bucket — your code never sees an upstream URL.

POST /v1/images/generations

Try it

curl https://relayx.timor419.com/v1/images/generations \
  -H "Authorization: Bearer $RELAYX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "rx-image-flux",
  "prompt": "A serene mountain lake at dusk, watercolor style",
  "size": "1024x1024"
}'

GPT Image

The rx-image-gpt SKUs are one model reached through two endpoints: a request carrying image_urls is reference-conditioned editing, one without is text-to-image. There is no separate -edit SKU. Quality is a per-SKU choice because it moves the price ~15x: rx-image-gpt-draft is the cheapest tier and exists for searching compositions, rx-image-gpt is the default, and rx-image-gpt-pro is for a final render.

{
  "model": "rx-image-gpt",
  "prompt": "...",
  "size": "1024x1536",
  "image_urls": ["https://.../reference.png"]
}

Only three shapes render: 1024x1024, 1536x1024 and 1024x1536. Any other size is snapped to the nearest ASPECT rather than rejected, so a 9:16 request lands on 2:3 portrait instead of going square — crop the result if you need an exact ratio. seed has no counterpart upstream and is not forwarded, so repeated calls vary.

Reliability & fallback

By default RelayX serves exactly the model you request and never silently substitutes a backend. If the upstream fails you get a clean, retryable error (429 upstream_capacity with Retry-After, or 502) and decide what to do next. To opt into automatic failover, pass an ordered fallback_models list — each SKU is tried in turn when the primary fails. The image is billed at the price of whichever SKU actually served it; since you listed the fallback yourself, its price is known up front. For a reliable, low-latency tier on its own, call rx-image-z-pro directly.

{
  "model": "rx-image-z",
  "prompt": "...",
  "fallback_models": ["rx-image-z-pro"]
}

On success x_relayx reports served_model (the SKU that produced the image — equal to model when no fallback was used), served_by (the actual backend), fallback_used, and cost_usd priced by served_model.