RelayDanceRelayDance
HomeModelsPricingDocsGuides
Get API Key →

Docs / API Reference / Generate Image

POST/v1/images/generations

Generate Image

OpenAI-compatible image generation. The response carries the image itself: base64 data for the GPT Image models, a download link (or base64 on request) for Seedream 4.5. No task polling is involved.

#Request body

ParameterTypeRequiredDescription
modelstringYesImage model ID: gpt-image-2 (image output free, pay only for input), gpt-image-2.6 ($0.04 per image) or seedream-4.5 ($0.05 per image produced)
promptstringYesText description of the image
nintegerNoNumber of images to generate. Default: 1
sizestringNoOutput size, model-dependent (e.g. "1024x1024")
output_formatstringNogpt-image-2.6 only: png (default), jpeg, webp, gif (animated) or svg
backgroundstringNogpt-image-2.6 only: transparent for a transparent background (png or webp)
imagestring or arrayNoseedream-4.5 only: reference pictures as public URLs or data:image/...;base64,... strings (not billed)
sequential_image_generationstringNoseedream-4.5 only: auto to allow a set of related images; disabled (default) for one
sequential_image_generation_optionsobjectNoseedream-4.5 only: {"max_images": 1 to 15}, billed per image actually returned
response_formatstringNoseedream-4.5 only: url (default, valid 24 hours) or b64_json. The GPT Image models always return b64_json
watermarkbooleanNoseedream-4.5 only: false by default (no watermark); true adds a small "AI generated" mark

#Example request

terminalbash
curl https://relaydance.com/v1/images/generations \
  -H "Authorization: Bearer $RELAYDANCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A photorealistic sunset over snow-capped mountains",
    "n": 1
  }' | jq -r '.data[0].b64_json' | base64 --decode > sunset.png

#Response

response.jsonjson
{
  "created": 1794605056,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
      "revised_prompt": "A photorealistic sunset over snow-capped mountains"
    }
  ]
}

With the GPT Image models the image is delivered inline as base64 in data[].b64_json; hosted image URLs are not provided. With gpt-image-2.6 each item also carries width and height, and the top level reports the output_format actually produced.

With seedream-4.5 each item carries a url valid for 24 hours (or b64_json if you asked for it) and its pixel size, and usage.generated_images is the number of images billed at $0.05 each. Samples for reference pictures and image sets are in the Image Generation guide.

#Edit an image

POST/v1/images/edits

Image to image with gpt-image-2.6. Send a multipart form: the source picture in the image file field, plus model and prompt; output_format is optional. The response has the same shape as above, and each image returned costs $0.04.

terminalbash
curl https://relaydance.com/v1/images/edits \
  -H "Authorization: Bearer $RELAYDANCE_API_KEY" \
  -F model=gpt-image-2.6 \
  -F [email protected] \
  -F prompt="Turn this picture into a watercolor painting" \
  | jq -r '.data[0].b64_json' | base64 --decode > edited.png
The OpenAI SDK works too: client.images.generate(...) with the base URL set to https://relaydance.com/v1. See the Image Generation guide for SDK samples.