remagicaDocs home

Generate images

Make and edit images with any image model, from a prompt and reference images.

Needs generations:submit to create and generations:read to poll. GET /models needs models:list.

Pick a model

GET /models lists every model. Image models have kind: "image". Each one's capabilities say what it accepts (aspect ratios, resolutions, how many reference images) and pricing says what it costs.

curl https://api.remagica.com/api/v1/models -H "x-api-key: $REMAGICA_API_KEY"

Models are named by what they are, like google/nano-banana-pro. Remagica picks which provider serves each request.

Generate from a prompt

curl https://api.remagica.com/api/v1/generations/images \
  -H "x-api-key: $REMAGICA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/nano-banana-pro",
    "prompt": "Product photo of a ceramic mug on oak, soft window light",
    "aspectRatio": "4:5",
    "count": 2
  }'

Only model and prompt are required. count makes several images in one request. The other fields (aspectRatio, resolution, quality, seed, ...) depend on the model; its capabilities list what it takes, and the reference lists every field.

Edit or compose from images

Pass reference images by storage key. Use an upload's key, or an output key of an earlier generation:

{
  "model": "google/nano-banana-pro",
  "prompt": "Put this mug on a marble kitchen counter",
  "references": [{ "key": "uploads/…/mug.png" }]
}

With references, the model edits or combines them as the prompt says.

Get the result

The request answers 202 Accepted with the generation. Its status goes queued → running → completed, or ends failed (error says why) or cancelled. Images take seconds.

Poll GET /generations/{generationId} every couple of seconds, or listen for the generation.succeeded webhook. When it's completed, outputs lists the files:

{
  "id": "7a1c9e42-…",
  "status": "completed",
  "credits": 8,
  "outputs": [
    {
      "kind": "image",
      "role": "output",
      "contentType": "image/png",
      "width": 1024,
      "height": 1280,
      "key": "generations/…/0.png",
      "url": "https://…"
    }
  ]
}

url downloads the file; it expires, so fetch the generation again for a fresh one. key feeds the file into another generation.

Other kinds

The same pattern works for every kind of generation:

  • POST /generations/background-removals: a cutout of an image.
  • POST /generations/speech: text read by a voice.
  • POST /generations/sound-effects: a sound from a prompt.
  • POST /generations/music: a track from a prompt, with or without lyrics.

Stop one that's still going with POST /generations/{generationId}/cancel (generations:cancel). One that hasn't started yet, here or in its provider's queue, ends cancelled and its credits come back. One the provider is already rendering can't be stopped without being billed, so it's kept: the response has stopRequested: true, and it finishes and is charged.

On this page