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 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.
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.
size works as it does for a text prompt: Mynth asks the model for the
closest shape it serves. Some editors keep the shape of the first input image
instead, and the provider picks the exact pixels, so an edit can come back a
few pixels off both your input and the requested ratio. Each returned image
carries its real dimensions in size.
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.
Models that charge for inputs list per_input 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 per_input
charges nothing for inputs. Pricing has the
formula.