Skip to main content
Version: 1.11.0-beta

uploadMask

Uploads an image to be used specifically as a mask for inpainting or editing workflows.

Signature:

client.images.uploadMask(input: UploadImageRequest): Promise<UploadImageResponse>
  • input: UploadImageRequest (see src/types.ts for full schema)
    • file: The mask image file (must be a File or Blob in the browser, or Buffer/Readable in Node.js)
    • description (optional): A description or label for the mask
  • Returns: UploadImageResponse (see below for new structure)
  • Throws: On validation, network, or API error.

Example (Browser)

const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const maskFile = new File([maskBlob], 'mask.png', { type: 'image/png' });
const result = await client.images.uploadMask({ file: maskFile, description: 'Foreground mask' });
if (result.success) {
console.log(result.data.image_url);
}

Example (Node.js)

const fs = require('fs');
const { ImagineoAIClient } = require('@imagineoai/javascript/server');
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const maskBuffer = fs.readFileSync('./mask.png');
const result = await client.images.uploadMask({ file: maskBuffer, description: 'Foreground mask' });
if (result.success) {
console.log(result.data.image_url);
}

Notes

  • The SDK automatically sets the isMask flag and handles the correct Content-Type for uploads.
  • In the browser, only File or Blob types are accepted for the mask.
  • In Node.js, you may use Buffer or a readable stream.
  • The API endpoint is /api/v1/upload.
  • The returned UploadImageResponse now has the following structure:
export type UploadImageResponse = {
success: boolean;
message: string;
data: {
id: string;
image_url: string;
run_id: string;
created_at: string;
};
};