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
| Parameter | Type | Required | Description |
|---|---|---|---|
imageUrl | string | Yes | Public URL of the input image |
type | string | Yes | Generation type (currently product) |
style | string | Yes | Style preset (see below) |
prompt | string | No | Custom prompt (overrides style default) |
aspectRatio | string | No | Output aspect ratio (default: 1:1) |
resolution | string | No | Output resolution (default: 1K) |
Available styles
| Style | Name | Description |
|---|---|---|
studio | Studio | Clean studio setup with controlled lighting |
amazon | Amazon | Optimized for marketplace listings |
luxury | Luxury | Premium feel with dramatic lighting |
lifestyle | Lifestyle | Product in a real-world context |
Aspect ratios
| Ratio | Dimensions |
|---|---|
1:1 | 1024×1024 |
4:3 | 1024×768 |
3:4 | 768×1024 |
16:9 | 1024×576 |
9:16 | 576×1024 |
Resolutions
| Resolution | Credit multiplier |
|---|---|
1K | 1× |
2K | 2× |
4K | 4× |
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 creditsCredit cost
The credit cost is calculated as:
cost = baseCost × resolutionMultiplierFor 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);
}
}