A worked pipeline, end to end
Six product photos arrive from a supplier. They need to be catalogue-ready. This is the whole run — check, batch, chain, compress — with nothing held in memory.
const api = "https://api.imagemcpserver.com";
const auth = { Authorization: `Bearer ${key}`,
"Content-Type": "application/json" };
// 1 — free call: can we afford this?
const { user } = await post("/auth/user-data");
if (user.credits < 6 * 24) {
throw new Error("not enough credits");
}
// 2 — batch the cutouts, in parallel
const { results } = await post("/playground/multicall", {
requests: photos.map((p) => ({
tool: "remove_background",
args: { image: p.url },
})),
});
// 3 — chain: each cutout feeds the upscale
const upscaled = await post("/playground/multicall", {
requests: results.map((r) => ({
tool: "upscale_image",
args: { image: r.url, scale: "4x" },
})),
});
// 4 — ship it light
const final = await post("/playground/multicall", {
requests: upscaled.results.map((r) => ({
tool: "compress_image",
args: { image: r.url, quality: 80,
targetFormat: "webp" },
})),
});
3 round trips, not 18
Each stage is one batched request instead of six sequential ones.
0 bytes in memory
Only URLs move between stages. The agent never buffers an image.
144 credits, known in advance
6 × (8 + 15 + 1). Checked against the balance before anything ran.
18 log entries
Every call recorded with its tool and exact cost, auditable afterwards.