Edit an Area API
Change one area of an image and keep every other pixel: send the area as a mask, say what it becomes in words, or give a reference picture of it.
From $0.054 per image · 1 credit on the standard tier
How it works
1. Create an API key
Sign up and create a key in your profile, under API. It starts with
tnb_live_and goes in theAuthorizationheader. Creating a key needs no plan.2. Send the request
One
POST /v1/generatewith the workflowretouch-v1and your pictures as public HTTPS URLs. Every value below is one this endpoint accepts.curl -X POST https://thenewblack.ai/api/v1/generate \ -H "Authorization: Bearer tnb_live_XXXXXXXXXXXX" \ -H "Content-Type: application/json" \ --data-binary @- <<'JSON' { "workflow": "retouch-v1", "prompt": "A denim collar, same shape", "source_image": "https://example.com/image.jpg", "reference_image": "https://example.com/reference.jpg", "ratio": "auto", "tier": "standard" } JSONconst res = await fetch("https://thenewblack.ai/api/v1/generate", { method: "POST", headers: { Authorization: `Bearer ${process.env.TNB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "workflow": "retouch-v1", "prompt": "A denim collar, same shape", "source_image": "https://example.com/image.jpg", "reference_image": "https://example.com/reference.jpg", "ratio": "auto", "tier": "standard" }), }); const { generation_id, poll } = await res.json();import os, requests res = requests.post( "https://thenewblack.ai/api/v1/generate", headers={"Authorization": f"Bearer {os.environ['TNB_API_KEY']}"}, json={ "workflow": "retouch-v1", "prompt": "A denim collar, same shape", "source_image": "https://example.com/image.jpg", "reference_image": "https://example.com/reference.jpg", "ratio": "auto", "tier": "standard", }, ) generation_id = res.json()["generation_id"]npx @thenewblack/cli generate retouch \ --source_image ./image.jpg \ --reference_image ./reference.jpg \ --prompt 'A denim collar, same shape' \ --ratio auto \ --tier standard \ --wait --out results/
3. Get the result
The call answers at once with a
generation_id. PollGET /v1/generations/{id}until the status settles, or send awebhook_urland we POST the outcome to it.// 202 Accepted { "generation_id": "3f1c9a6e-...", "status": "running", "poll": "/api/v1/generations/3f1c9a6e-..." } // GET /v1/generations/3f1c9a6e-... → 200 OK { "generation_id": "3f1c9a6e-...", "workflow": "retouch", "status": "succeeded", "result": { "type": "image", "url": "https://.../result.webp", "thumbnail": "https://.../thumb.webp" } }Results stay 48 hours on our URL: copy them to your own storage. Authentication, errors and webhooks are documented in the full API reference.
Parameters
/v1/generateworkflow: retouch-v1One endpoint serves every workflow; this page documents retouch-v1, the current version. Earlier versions, if any, keep being served under their own names.
| Parameter | Value for this workflow |
|---|---|
| workflow | "retouch-v1" required |
| prompt | Describe the creation or the change — English works best. |
| source_image | Your image — one public HTTPS URL.required |
| reference_image | Reference — one public HTTPS URL. |
| fields.mask | Area. A PNG the size of source_image, white where the picture changes and black where it stays; outside the white the original is kept to the pixel. Without it, the whole picture is edited. |
| fields.colors | Colors. Optional — the new color of the area: hex codes (#0F4C81) or Pantone TCX codes (19-4052 TCX), all of one kind, up to three, separated by commas. With several, say in prompt where each goes. Not with reference_image. |
| ratio | auto |
| tier | "standard" (1 cr), "pro" (3 cr) |
| webhook_url | Optional — we POST the outcome here when the generation settles. Without it, poll the URL returned in the response until the status settles. |
Pricing
| Tier | Credits | What it makes | From |
|---|---|---|---|
| standard | 1 cr | 1K resolution image + fast generation | $0.054 |
| pro | 3 cr | 2K resolution image + thinking process before generating | $0.16 |
Credits are debited when the request is accepted, a fixed price per generation; a failed generation is refunded automatically. Dollar prices are at the best credit price, $0.054 a credit (Enterprise, billed yearly). Credits come with plans and packs; new accounts start with free credits.
From Claude and from the terminal
The same workflow is the retouch tool of our MCP server for Claude, and tnb generate retouch in our command line (the CLI tab above), with the same parameters and the same prices.
Frequently asked questions
How do I say which area to change?
Send fields.mask: a PNG the size of source_image, white where the picture should change and black where it must stay. Everything outside the white area is put back to the pixel. Without a mask, the edit applies to the picture as a whole.
Can I show what the area should become instead of describing it?
Yes: add reference_image, a picture of the print, fabric, collar or garment the area should become. The prompt is then optional.
How much does it cost?
1 credit per generation on the standard tier, 3 on pro: a fixed price per generation. At $0.054 a credit (Enterprise, billed yearly), that is $0.054 per image on standard. Credits come with plans and packs; a failed generation is always refunded.
Other endpoints: Virtual Try-On API · AI Fashion Models API · Fashion Design API · Reimagine Model API · Swap Model API · AI Stylist API · all endpoints