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(seesrc/types.tsfor full schema)file: The mask image file (must be aFileorBlobin the browser, orBuffer/Readablein 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
isMaskflag and handles the correct Content-Type for uploads. - In the browser, only
FileorBlobtypes are accepted for the mask. - In Node.js, you may use
Bufferor a readable stream. - The API endpoint is
/api/v1/upload. - The returned
UploadImageResponsenow has the following structure:
export type UploadImageResponse = {
success: boolean;
message: string;
data: {
id: string;
image_url: string;
run_id: string;
created_at: string;
};
};
- See the API Reference for more details on input/output types.