Documentation Index Fetch the complete documentation index at: https://docs.platform.decart.ai/llms.txt
Use this file to discover all available pages before exploring further.
The Process API enables you to transform existing images with style transfer and edits. Perfect for building content creation tools, media processing pipelines, batch transformations, and creative applications.
For video processing (video editing, motion control), use the Queue API which provides asynchronous job-based processing.
Image
Image Editing
Transform and restyle existing images:
const imageFile = document . querySelector ( 'input[type="file"]' ). files [ 0 ];
const result = await client . process ({
model: models . image ( "lucy-image-2" ),
prompt: "Oil painting style with impressionist brushstrokes" ,
data: imageFile ,
enhance_prompt: true ,
seed: 123 ,
});
You can also provide a reference image to guide the edit — for example, to add a specific item:
const imageFile = document . querySelector ( 'input[type="file"]' ). files [ 0 ];
const referenceImage = document . querySelector ( '#reference-input' ). files [ 0 ];
const result = await client . process ({
model: models . image ( "lucy-image-2" ),
prompt: "Add these sunglasses to the person's face" ,
data: imageFile ,
reference_image: referenceImage ,
});
Parameters:
prompt (required) - Text description of the style transformation
data (required) - Input image (File, Blob, URL, or ReadableStream)
reference_image (optional) - Reference image to guide the edit (File, Blob, URL, or ReadableStream)
seed (optional) - Random seed for reproducible results
resolution (optional) - Output resolution
enhance_prompt (optional) - Auto-enhance the prompt for better results
Model: lucy-image-2
The data, reference_image, start, and end parameters accept flexible input types:
type FileInput = File | Blob | ReadableStream | URL | string ;
Examples:
// Browser file input
const file = document . querySelector ( 'input[type="file"]' ). files [ 0 ];
// Blob
const blob = new Blob ([ arrayBuffer ], { type: 'image/jpeg' });
// URL string
const url = "https://example.com/image.jpg" ;
// URL object
const urlObj = new URL ( "https://example.com/video.mp4" );
// ReadableStream (advanced)
const stream = response . body ;
Cancellation
Cancel long-running operations using AbortController:
const controller = new AbortController ();
try {
const result = await client . process ({
model: models . image ( "lucy-image-2" ),
prompt: "Transform into epic fantasy landscape with dragons" ,
data: imageFile ,
signal: controller . signal ,
});
} catch ( error ) {
if ( error . name === 'AbortError' ) {
console . log ( 'Generation cancelled' );
}
}
// Cancel the request
controller . abort ();
You can use this to implement cancel buttons in your UI:
let currentController : AbortController | null = null ;
async function editImage ( prompt : string ) {
// Cancel previous request if any
currentController ?. abort ();
currentController = new AbortController ();
const result = await client . process ({
model: models . image ( "lucy-image-2" ),
prompt ,
data: imageFile ,
signal: currentController . signal ,
});
return result ;
}
function cancelGeneration () {
currentController ?. abort ();
}
Error Handling
The SDK throws specific errors for different failure scenarios:
import { createDecartClient , type DecartSDKError } from "@decartai/sdk" ;
try {
const result = await client . process ({
model: models . image ( "lucy-image-2" ),
prompt: "Oil painting style with impressionist brushstrokes" ,
data: imageFile ,
});
} catch ( error ) {
const sdkError = error as DecartSDKError ;
switch ( sdkError . code ) {
case "INVALID_INPUT" :
console . error ( "Invalid input:" , sdkError . message );
break ;
case "INVALID_API_KEY" :
console . error ( "Invalid API key" );
break ;
case "PROCESSING_ERROR" :
console . error ( "Processing failed:" , sdkError . message );
break ;
default :
console . error ( "Unknown error:" , sdkError . message );
}
}
If you provide invalid inputs, you’ll get clear error messages:
// Missing required field
await client . process ({
model: models . image ( "lucy-image-2" ),
prompt: "test" ,
// Missing 'data' field
});
// Error: Invalid inputs for lucy-image-2: data is required
API Reference
client.process(options)
Generate or transform images.
Parameters:
options - Configuration object with model and inputs:
model - Model from models.image()
signal? - Optional AbortSignal for cancellation
Additional fields depend on the model (see below)
Returns: Promise<Blob> - The generated/transformed image
Inputs by Model:
Image Editing (lucy-image-2)
prompt: string - Style description (required)
data: FileInput - Input image (required)
reference_image?: FileInput - Reference image to guide the edit
seed?: number - Random seed
resolution?: string - Output resolution
enhance_prompt?: boolean - Auto-enhance prompt
Next Steps
Queue API Asynchronous video processing with job-based queue
Realtime API Transform video streams in realtime with WebRTC