Skip to main content
Use POST /image/upload (or mynth.image.upload()) when you need Mynth-hosted URLs for input images. Pass those URLs — or any public image URL — in inputs on POST /image/generate. If your images are already publicly reachable over HTTP(S), skip upload and put the URLs in inputs directly. This page is not about delivering generated images to your own storage — that is the optional destination field on generate (see Image Generation Request).

Pricing

Upload is free. Mynth does not charge for POST /image/upload. Generation still bills per successful output image. Some models also charge per input image on each successful output (perImage + perInput × inputs.length). Check the model page for perInput pricing.

Pass a public URL (no upload)

The simplest path: put a URL string in inputs.
const task = await mynth.image.generate({
  prompt: "Restyle this photo as a cinematic still",
  model: "xai/grok-imagine-image",
  inputs: ["https://example.com/input-image.jpg"],
});
String entries are shorthand for structured image inputs. Equivalent form:
inputs: [
  {
    type: "image",
    source: { type: "url", url: "https://example.com/input-image.jpg" },
  },
];

Upload local files with the SDK

mynth.image.upload() accepts a File / Blob, or an array of them, and returns CDN URLs.
const { urls } = await mynth.image.upload(file);

const task = await mynth.image.generate({
  prompt: "Luxury watch campaign shot with dramatic reflections",
  model: "xai/grok-imagine-image",
  inputs: urls,
});
You can also pass File / Blob values in inputs on generate. The SDK uploads them first, then sends URL inputs to the API:
const task = await mynth.image.generate({
  prompt: "Restyle this photo as a cinematic still",
  model: "xai/grok-imagine-image",
  inputs: [file], // File or Blob — uploaded automatically
});
Structured client inputs can keep a role while uploading a local file:
inputs: [
  {
    type: "image",
    as: "source",
    source: { type: "file", file },
  },
];

Upload with REST

Multipart form field name: images (repeated) or images[].
curl https://api.mynth.io/image/upload \
  -X POST \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -F "images=@./reference-1.png" \
  -F "images=@./reference-2.jpg"
Success (200):
{
  "data": {
    "urls": [
      "https://cdn.example.com/inputs/img_....png",
      "https://cdn.example.com/inputs/img_....jpg"
    ]
  }
}
Use the returned URLs in generate:
curl https://api.mynth.io/image/generate \
  -X POST \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Restyle this photo as a cinematic still",
    "model": "xai/grok-imagine-image",
    "inputs": [
      "https://cdn.example.com/inputs/img_....png"
    ]
  }'
Creating a task does not return images immediately. Wait in the SDK, poll task endpoints, or use webhooks — see Async and polling.

Upload limits

ConstraintLimit
FormatsJPEG, PNG, WebP (image/jpeg, image/png, image/webp)
Minimum file size1 KB (1024 bytes)
Maximum file size10 MB per file
Maximum files per request10
Maximum request body100 MB
Validation failures return HTTP 400 with code: "VALIDATION_ERROR". Examples:
ConditionMessage
No filesAt least one image is required
More than 10 filesCannot upload more than 10 images
Unsupported MIME typeOnly JPEG, PNG, and WEBP images are supported
File smaller than 1 KBImage must be at least 1024 bytes
File larger than 10 MBImage cannot exceed 10485760 bytes
Bytes are not a valid imageInvalid image file
Request body over 100 MB returns HTTP 413:
{
  "code": "VALIDATION_ERROR",
  "message": "Upload body is too large"
}

Set input roles (as)

Most models treat inputs as generic references. Some need roles. Set optional as on each structured input:
asTypical use
autoDefault when omitted. Let Mynth resolve the role (try-on, source/reference).
personSubject for virtual try-on
garmentClothing for virtual try-on
posePose reference (must be explicit when the model supports it)
sourcePrimary image to edit (for example Luma UNI)
referenceStyle or composition guidance
const task = await mynth.image.generate({
  prompt: "Product hero on marble, studio lighting",
  model: "luma/uni-1",
  inputs: [
    {
      type: "image",
      as: "source",
      source: { type: "url", url: "https://example.com/product.png" },
    },
    {
      type: "image",
      as: "reference",
      source: { type: "url", url: "https://example.com/style.png" },
    },
  ],
});
For role-based models such as Luma UNI, if you omit as, Mynth assigns the first undeclared input as source and the rest as reference. For try-on models, undeclared visual roles can be classified by the worker when the model allows it; pose must be declared when you use it.

Per-model input rules

Support is model-specific:
  • whether inputs are allowed at all
  • maximum count (and per-role min/max)
  • which roles are accepted
The generate request schema allows up to 20 inputs entries. Individual models enforce lower caps (for example 1, 3, 10, or 16). If the model does not support inputs, or the roles/counts do not match its contract, the request fails validation (VALIDATION_ERROR), for example:
{
  "code": "VALIDATION_ERROR",
  "message": "This model does not support inputs"
}
Check the Inputs section on each model page for exact limits and examples.

How inputs fit generation

  1. Obtain public HTTP(S) URLs for each input (upload local files, or use URLs you already host).
  2. Send them in inputs on POST /image/generate (URL strings or structured objects).
  3. Mynth validates inputs against the selected model’s contract, then runs image-to-image (or role-based) generation.
  4. Successful outputs are billed with any model-specific per-input charge.
Upload only hosts input files on the Mynth CDN path (/inputs/...). It does not start generation, create a task, or reserve balance.