MakePhotos Docs
SDK Reference

Generate

Generate studio-quality photos with the MakePhotos SDK.

Generate

Transform images into professional studio-quality photos.

Basic usage

const result = await client.generate.create({
  imageUrl: 'https://example.com/product.jpg',
  type: 'product',
  style: 'studio',
});

console.log(result.resultUrl);

Parameters

ParameterTypeRequiredDescription
imageUrlstringYesPublic URL of the input image
typestringYesGeneration type (currently product)
stylestringYesStyle preset (see below)
promptstringNoCustom prompt (overrides style default)
aspectRatiostringNoOutput aspect ratio (default: 1:1)
resolutionstringNoOutput resolution (default: 1K)

Available styles

StyleNameDescription
studioStudioClean studio setup with controlled lighting
amazonAmazonOptimized for marketplace listings
luxuryLuxuryPremium feel with dramatic lighting
lifestyleLifestyleProduct in a real-world context

Aspect ratios

RatioDimensions
1:11024×1024
4:31024×768
3:4768×1024
16:91024×576
9:16576×1024

Resolutions

ResolutionCredit multiplier
1K1×
2K2×
4K4×

Response

interface GenerateResult {
  resultUrl: string;      // Cloudinary URL of the generated image
  creditsUsed: number;    // Credits consumed
  creditsRemaining: {
    monthly: number;
    topup: number;
    total: number;
  };
}

Full example

const result = await client.generate.create({
  imageUrl: 'https://example.com/sneaker.jpg',
  type: 'product',
  style: 'lifestyle',
  aspectRatio: '16:9',
  resolution: '2K',
  prompt: 'Outdoor setting with natural sunlight, wooden surface',
});

console.log(result.resultUrl);       // Generated image URL
console.log(result.creditsUsed);     // 2 (1 base × 2K multiplier)
console.log(result.creditsRemaining.total); // Remaining credits

Credit cost

The credit cost is calculated as:

cost = baseCost × resolutionMultiplier

For product generation: base cost is 1 credit. At 2K resolution that's 2 credits, at 4K it's 4 credits.

Error handling

If generation fails (e.g., the AI model errors out), credits are automatically refunded. The SDK throws a MakePhotosError with code generation_failed and a details.refunded flag.

import { MakePhotosError } from 'makephotos';

try {
  await client.generate.create({ ... });
} catch (err) {
  if (err instanceof MakePhotosError && err.code === 'generation_failed') {
    console.log('Generation failed, refunded:', err.details?.refunded);
  }
}

On this page