Image to image
Send input images with a generation to edit or reference them. Input roles, which models accept them, uploading local files, and what inputs cost.
An edit is the same POST /image/generate as a text prompt, plus inputs.
Pass a model whose catalog entry lists img->img, and check its
inputs.rules for how many images it takes.
import Mynth from "@mynthio/sdk";
const mynth = new Mynth();
const task = await mynth.image.generate({
model: "black-forest-labs/flux.2-pro",
prompt: "The same lighthouse, now in heavy fog",
inputs: ["https://cdn.example.com/lighthouse.png"],
});Inputs and roles#
inputs takes up to 20 entries. A string is a public image URL. The object
form sets a role:
{
"type": "image",
"as": "reference",
"source": { "type": "url", "url": "https://cdn.example.com/lighthouse.png" }
}as | Meaning |
|---|---|
source | The image to edit |
reference | An image to take style or content from |
auto | Let Mynth assign a role the model accepts. The default |
The catalog entry's inputs.rules says which roles the model has and how many
images each allows. A rule with no kind accepts any image. In the CLI, set a
role with a prefix: -i source:./photo.png or -i reference:https://....
An input URL must be reachable from the public internet. An image Mynth cannot
fetch or read fails with INVALID_INPUT.
Pass a model that edits#
With an explicit model, inputs are checked when the task is created. A model
that cannot take them, or too many of them, answers 400 VALIDATION_ERROR and
nothing is queued.
auto does not look at inputs. An edit sent with auto can be accepted and
then fail with CAPABILITY_NOT_SUPPORTED when it lands on a model that cannot
edit. The model field has the details.
Local files#
The SDK and the CLI upload local files for you. In the SDK, put a File or
Blob in inputs. In the CLI, pass a path to -i.
const task = await mynth.image.generate({
model: "black-forest-labs/flux.2-pro",
prompt: "The same lighthouse, at noon",
inputs: [file],
});Over REST, upload first with POST /image/upload and pass the returned URLs:
curl https://api.mynth.io/image/upload \
-H "Authorization: Bearer $MYNTH_API_KEY" \
-F "images=@./lighthouse.png"{ "data": { "urls": ["https://cdn.mynth.io/inputs/img_3f9a0c1d2e4b5a6978c0d1e2f3a4b5c6.png"] } }An upload takes up to 10 JPEG, PNG, or WEBP files, each between 1 KB and 10 MB. It is free, and the URLs are served for 1 day. The SDK and the CLI send all local files of one request in a single upload, so the same 10-file limit applies to them.
Price#
Models that charge for inputs list perInput in the catalog. It is charged
once per input image for each successful output, so two inputs at count: 4
add eight input charges to the four image charges. A model without perInput
charges nothing for inputs. Pricing has the
formula.
Next steps#
- Generate images: the rest of the request.
- Choosing an image model: finding a model that edits.
- Remove background: a cutout without a prompt.