Send a photo to the Magnt image editing API
An editing request needs two things: the photo you want to work from and a clear description of what should change. Magnt accepts both in one JSON request. There is no asset upload endpoint to call first and no previous image automatically carried into the edit.
Start with the right source
Use a clear source image in a supported format. When the request is about a real person or product, the source is the reference for details you want preserved. A text-only prompt can generate a concept, but it cannot establish what a particular customer’s face or inventory item looks like.
Decide which change you want before encoding the file. Lighting, colour balance and background are different editing goals. A focused request is easier to review than an instruction to improve everything. Keep the original available to compare with the result.
Encode the bytes with their actual MIME type
For a JPEG, the data URL begins with data:image/jpeg;base64, followed by the encoded file bytes. PNG and WebP use their own MIME types. Changing a filename extension or the prefix does not convert an image: the declared type must match the actual file.
The following Node.js fragment builds a payload for a JPEG named portrait.jpg. Use the authenticated fetch and response handling from the JavaScript guide to send body. It remains a single POST request to /api/v1/images/generations.
import { readFile } from "node:fs/promises";
const bytes = await readFile("portrait.jpg");
if (bytes.length > 2 * 1024 * 1024) {
throw new Error("Choose a JPEG smaller than 2 MiB");
}
const payload = {
model: "magnt-image-1",
prompt: "Soften the lighting. Preserve facial features and natural skin texture.",
images: [`data:image/jpeg;base64,${bytes.toString("base64")}`],
aspect_ratio: "4:5",
response_format: "image",
};
const body = JSON.stringify(payload);
if (Buffer.byteLength(body, "utf8") > 4 * 1024 * 1024) {
throw new Error("The complete request exceeds 4 MiB");
}
// Send body using the authenticated fetch in the JavaScript guide.Check the whole request, not just each photo
The API accepts up to three images, but that does not mean three files at the per-image maximum will fit. Base64 expands the data, and the request also contains JSON and your prompt. Measure the final UTF-8 body and keep it under 4 MiB.
Animated files, corrupt data and MIME mismatches are rejected. Each decoded image is also limited to 25 megapixels. Reducing dimensions and encoding the source more compactly can help it fit, but inspect the resized version so you do not remove details the edit depends on.
Describe what should stay as well as what should change
For a portrait, name the lighting change and ask to preserve facial features, expression and natural texture. For a product, name the new setting and ask to preserve geometry, colour and labels. These instructions guide generation; they do not guarantee pixel-exact preservation.
Review the result before publishing it. The endpoint is not a mask-based editor, a segmentation service or a guarantee of identity consistency. If a detail matters to the task, compare that detail against the source instead of accepting a result only because the overall image looks polished.
Make the next edit self-contained
A second request does not remember the first. To refine a result, explicitly attach the image you want to use as the next source, along with the new prompt. To start over, attach the original again. Your interface should make that choice visible.
Magnt returns the output directly and does not maintain an image history or a saved face profile. Your app can keep an accepted result if its product needs require it, but the API does not retrieve old photos for context.
Bring image generation into your app.
Create a Magnt API key, test a prompt and receive the image directly. Your existing plan allowance or credits apply.
Create an API key →