Image edit

POST/v1/images/edits

An edit is a generation with references: the same handler, a JSON body only.

Request

modelstringbodyrequired
an image model id — the same catalog as generation
promptstringbodyrequired
what to change; we check it is there, the model checks length (EMPTY_PROMPT)
imagestring|arraybody
the image being edited: a URL, a data-URL or base64; an array for several

Responses

200

{
  "created": 0,
  "cost_usd": "0.027",
  "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAA…" } ]
}

202

{ "id": "img_9f2c1b7e…", "status": "processing", "estimated_cost_usd": "0.027" }

the body is not JSON (SDK multipart included), no prompt, or a reference over 80 MB

FILE_DOWNLOAD_FAILED — the submit was rejected: the provider's 4xx is echoed with its code, the hold released

no key in the request, or the key is not ours

the balance does not cover this request's worst-case price

the provider accepted the job and the generation failed; its code is in error.code

the submit failed on a 5xx or the network: whether the job was accepted is unknown

Details

Needs a key in Authorization: Bearer or x-api-key.

There is no separate code behind this route: it delegates to POST /v1/images/generations, because an edit is a generation with references attached. Every parameter, reply, error code and billing rule is the same.

⚠️ The body is parsed **as JSON only**, so references must arrive in JSON fields (image / images / image_url), with the bytes themselves as a data-URL or a base64 string in the value. A real multipart upload — which is exactly what images.edit sends from the OpenAI SDK — fails with 400 "Invalid JSON". That is a gateway limitation, not a provider one: until multipart is parsed here, SDK compatibility cannot be claimed for this route. From requests/curl, send JSON with the image as a data-URL or a base64 string.

Reference images (image-to-image, same character or style) go in the body as image — a string or an array; images, image_url, image_urls, input_image, init_image and ref_images are accepted too. A value may be a public URL, a data-URL or bare base64, and mixing the forms in one request is fine: a URL is not fetched by us and reaches the provider as a link, while base64 is decoded and sent as bytes. The gateway recognises bytes by their signature (PNG, JPEG, GIF, WebP) and caps each input at 80 MB — anything larger is a 400 before the provider is called. An input that passed our cap may still be refused by the model under its own rules: its code then arrives in error.codeFILE_TOO_LARGE for size, FILE_TYPE_NOT_ALLOWED for type. The gateway puts no limit on the number of references; how many the model actually uses is up to it. A value that parses neither as a URL nor as base64 is dropped silently: the request goes out without that reference and without an error.

Code examples
curl https://api.teamtoken.store/v1/images/edits \
  -H "Authorization: Bearer sk-…" \
  -H "Content-Type: application/json" \
  -d '{ "model": "nano-banana-pro",
        "prompt": "replace the background with a snowy street at night",
        "image": "data:image/png;base64,iVBORw0KGgo..." }'
Request
https://api.teamtoken.store/v1

The panel calls this domain; in your own code use the address above.

The key is never stored: it lives in this tab until you reload the page.

an image model id — the same catalog as generation

what to change; we check it is there, the model checks length (EMPTY_PROMPT)

the image being edited: a URL, a data-URL or base64; an array for several

This request really goes out. A generation is billed, and its price is reserved the moment the job is queued.

Response

Press “Send request” above and the answer shows up here.