Skip to content

TypeScript and JavaScript SDK

Terminal window
npm install remodeled-ai

Runs on Node 20+, Bun, Deno, Cloudflare Workers and Vercel Edge. No dependencies: it uses the platform’s fetch and WebCrypto. ESM, with full types made from the OpenAPI document.

import Remodeled from 'remodeled-ai';
const client = new Remodeled(); // reads REMODELED_API_KEY
const photo = await client.uploads.create('./living-room.jpg');
const design = await client.designs.createAndWait({
mode: 'remodel',
inputAssetId: photo.id,
room: 'Living room',
style: 'Japandi',
});
console.log(design.images[0]!.asset.url);
const client = new Remodeled({
apiKey: process.env.REMODELED_API_KEY, // default: REMODELED_API_KEY
baseURL: 'https://api.remodeled.ai', // default: REMODELED_BASE_URL, then this
timeout: 60_000, // per request, in ms (a held wait adds its own time)
maxRetries: 2, // for 429, 5xx and network errors
fetch: customFetch, // optional
defaultHeaders: {}, // sent with every request
});
await client.uploads.create('./photo.jpg'); // a path (Node, Bun, Deno)
await client.uploads.create(file); // a Blob or File, such as from a form
await client.uploads.create(bytes, { contentType: 'image/heic' }); // Uint8Array or ArrayBuffer
await client.uploads.fromUrl('https://example.com/photo.jpg'); // the API fetches it

The type is read from the bytes when you don’t give one.

Method What it does
designs.create(params, options?) Starts a design. options.idempotencyKey, options.wait (seconds, or true for 60).
designs.createAndWait(params, options?) Starts one and waits until it is final. Throws DesignFailedError if it failed.
designs.get(id, { wait? }) One design, optionally held until it finishes.
designs.wait(id, { waitTimeout?, throwOnFailure? }) Waits for a design you started earlier. waitTimeout in ms, default 5 minutes.
designs.list({ limit?, cursor? }) One page, newest first.
designs.listAll({ limit? }) Every design, as an async iterator over all pages.
designs.delete(id) Deletes a design.

params is the StartDesign object, fully typed: your editor completes modes, fields and enums.

const catalog = await client.catalog.get(); // rooms, styles, models, prices
const account = await client.account.get(); // credits, this key's limit and use
import { APIError, DesignFailedError, InsufficientCreditsError, RateLimitError } from 'remodeled-ai';
try {
await client.designs.createAndWait({ mode: 'remodel', inputAssetId: photo.id });
} catch (err) {
if (err instanceof InsufficientCreditsError) notifyBilling(err.details);
else if (err instanceof DesignFailedError) console.log(err.design.error?.code);
else if (err instanceof APIError) console.log(err.status, err.code, err.requestId);
else throw err;
}

Every API error is an APIError with status, code, message, details, requestId and headers. Subclasses: InvalidRequestError, AuthenticationError, InsufficientCreditsError, PermissionDeniedError, NotFoundError, ConflictError, RateLimitError, InternalServerError. Without an answer: APIConnectionError or TimeoutError. See all error codes.

429, 5xx and network errors are retried maxRetries times with backoff, honouring Retry-After. Design starts always carry an Idempotency-Key (yours, or a random one), so a retry never starts a second design.

import { webhooks } from 'remodeled-ai';
const event = await webhooks.verify(rawBody, request.headers.get('Remodeled-Signature'), secret);

Pass the raw body as received. verify throws WebhookVerificationError when the signature is wrong or more than 5 minutes old ({ tolerance } in seconds). webhooks.sign(payload, secret) makes a valid header for your own tests. See Webhooks.

Every object is exported as a type: Design, DesignImage, Asset, StartDesign, Catalog, Account, WebhookEvent and the rest.

import type { Design, StartDesign } from 'remodeled-ai';