Skip to content

Example: a listing photo pipeline

This example stages every photo of a new listing. The photos are already online, so it uploads them by URL; each design carries the listing and photo ids in metadata; a webhook saves the results. A retry of the whole job never pays twice, because every design start has an idempotency key made from the listing and the photo.

import Remodeled, { RateLimitError } from 'remodeled-ai';
const client = new Remodeled();
type Photo = { id: string; url: string; room: string };
export async function stageListing(listingId: string, photos: Photo[], style = 'Modern') {
for (const p of photos) {
const upload = await client.uploads.fromUrl(p.url);
await client.designs.create(
{
mode: 'staging',
inputAssetId: upload.id,
room: p.room, // "Living room", "Bedroom", ... from the catalog
style,
model: 'gpt-image-2.5', // Standard
metadata: { listingId, photoId: p.id },
},
{ idempotencyKey: `stage-${listingId}-${p.id}-${style}` },
);
}
}
from remodeled import Remodeled
client = Remodeled()
def stage_listing(listing_id: str, photos: list[dict], style: str = "Modern") -> None:
for p in photos:
upload = client.uploads.from_url(p["url"])
client.designs.create(
mode="staging",
input_asset_id=upload["id"],
room=p["room"],
style=style,
model="gpt-image-2.5",
metadata={"listingId": listing_id, "photoId": p["id"]},
idempotency_key=f"stage-{listing_id}-{p['id']}-{style}",
)

The SDKs already retry 429 and 5xx answers with backoff (honouring Retry-After), so a burst of 30 photos needs no rate-limit code of your own.

Set the key’s webhook URL to this endpoint. metadata comes back on the design, so the handler knows where each image belongs.

import { webhooks } from 'remodeled-ai';
export async function POST(req: Request) {
const raw = await req.text();
const event = await webhooks.verify(raw, req.headers.get('Remodeled-Signature'), process.env.REMODELED_WEBHOOK_SECRET!);
if (event.type === 'design.succeeded') {
const { listingId, photoId } = event.data.design.metadata;
const url = event.data.design.images[0]!.asset.url;
await db.listingPhotos.update({ listingId, photoId }, { stagedUrl: await copyToOwnStorage(url) });
}
if (event.type === 'design.failed') {
await db.listingPhotos.update(event.data.design.metadata, { stagingFailed: event.data.design.error?.code });
}
return new Response(null, { status: 204 });
}

The catalog lists each model’s price. A listing of 25 photos at Standard is 25 × 5 = 125 credits. Check the account has them, and give the key a limit that matches your budget:

const [catalog, account] = await Promise.all([client.catalog.get(), client.account.get()]);
const perPhoto = catalog.models.find((m) => m.id === 'gpt-image-2.5')!.credits.standard;
if (account.credits.available < perPhoto * photos.length) throw new Error('Top up credits first');
  • Empty first, then stage. For furnished photos, run mode: "declutter" first, then start a staging design with the declutter image’s asset.id as inputAssetId.
  • Several styles to choose from. Start one design per style, each with its own idempotency key, and show the agent all of them.
  • Two or more images per room. count: 2 makes two takes in one design. Each image is charged.