Skip to main content
The Process API enables you to generate videos and images from text, or transform existing media with style transfer. Perfect for building content creation tools, media processing pipelines, batch transformations, and creative applications.

Video

Video Generation

Generate videos from text prompts:
const result = await client.process({
  model: models.video("lucy-pro-t2v"),
  prompt: "A serene lake at sunset with mountains in the background",
  seed: 42,
  resolution: "1080p",
  orientation: "landscape",
});

const video = document.querySelector("video");
video.src = URL.createObjectURL(result);
Parameters:
  • prompt (required) - Text description of the video to generate
  • seed (optional) - Random seed for reproducible results
  • resolution (optional) - Output resolution (e.g., “720p”, “1080p”)
  • orientation (optional) - Output orientation (“landscape”, “portrait”)
Model: lucy-pro-t2v

Image Animation

Animate static images into videos:
const fileInput = document.querySelector('input[type="file"]');
const imageFile = fileInput.files[0];

const result = await client.process({
  model: models.video("lucy-pro-i2v"),
  prompt: "Animate with gentle motion and wind",
  data: imageFile,
  seed: 123,
  resolution: "1080p",
});
Parameters:
  • prompt (required) - Text description of the animation style
  • data (required) - Input image (File, Blob, URL, or ReadableStream)
  • seed (optional) - Random seed for reproducible results
  • resolution (optional) - Output resolution
Model: lucy-dev-i2v, lucy-pro-i2v

Video Editing

Transform and restyle existing videos:
const fileInput = document.querySelector('input[type="file"]');
const videoFile = fileInput.files[0];

const result = await client.process({
  model: models.video("lucy-pro-v2v"),
  prompt: "Convert to anime style with vibrant colors",
  data: videoFile,
  enhance_prompt: true,
  num_inference_steps: 50,
});
You can also use URLs as input:
const result = await client.process({
  model: models.video("lucy-pro-v2v"),
  prompt: "Watercolor painting style",
  data: "https://example.com/video.mp4",
});
Parameters:
  • prompt (required) - Text description of the style transformation
  • data (required) - Input video (File, Blob, URL string, or ReadableStream)
  • seed (optional) - Random seed for reproducible results
  • resolution (optional) - Output resolution
  • enhance_prompt (optional) - Auto-enhance the prompt for better results
  • num_inference_steps (optional) - Number of inference steps (pro model only)
Model: lucy-dev-v2v, lucy-pro-v2v

Video Transitions

Generate smooth transitions between two frames:
const startImage = document.getElementById("start-input").files[0];
const endImage = document.getElementById("end-input").files[0];

const result = await client.process({
  model: models.video("lucy-pro-flf2v"),
  prompt: "Smooth cinematic transition with natural motion",
  start: startImage,
  end: endImage,
  resolution: "1080p",
});
Parameters:
  • prompt (required) - Text description of the transition
  • start (required) - First frame image (File, Blob, URL, or ReadableStream)
  • end (required) - Last frame image
  • seed (optional) - Random seed for reproducible results
  • resolution (optional) - Output resolution
Model: lucy-pro-flf2v

Image

Image Generation

Generate images from text prompts:
const result = await client.process({
  model: models.image("lucy-pro-t2i"),
  prompt: "A futuristic cityscape at night with neon lights",
  seed: 42,
  orientation: "portrait",
  resolution: "1080p",
});

const img = document.querySelector("img");
img.src = URL.createObjectURL(result);
Parameters:
  • prompt (required) - Text description of the image to generate
  • seed (optional) - Random seed for reproducible results
  • resolution (optional) - Output resolution
  • orientation (optional) - Output orientation (“landscape”, “portrait”)
Model: lucy-pro-t2i

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-pro-i2i"),
  prompt: "Oil painting style with impressionist brushstrokes",
  data: imageFile,
  enhance_prompt: true,
  seed: 123,
});
Parameters:
  • prompt (required) - Text description of the style transformation
  • data (required) - Input image (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-pro-i2i

Input Types

The data, 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.video("lucy-pro-t2v"),
    prompt: "Epic fantasy landscape with dragons",
    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 generateVideo(prompt: string) {
  // Cancel previous request if any
  currentController?.abort();
  
  currentController = new AbortController();
  
  const result = await client.process({
    model: models.video("lucy-pro-t2v"),
    prompt,
    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.video("lucy-pro-i2v"),
    prompt: "Animate this image",
    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.video("lucy-pro-i2v"),
  prompt: "test",
  // Missing 'data' field
});
// Error: Invalid inputs for lucy-pro-i2v: data is required

API Reference

client.process(options)

Generate or transform media. Parameters:
  • options - Configuration object with model and inputs:
    • model - Model from models.video() or models.image()
    • signal? - Optional AbortSignal for cancellation
    • Additional fields depend on the model (see below)
Returns: Promise<Blob> - The generated/transformed media Inputs by Model:
  • prompt: string - Text description (required)
  • seed?: number - Random seed for reproducibility
  • resolution?: string - Output resolution (e.g., “720p”, “1080p”)
  • orientation?: string - Output orientation (“landscape”, “portrait”)
  • prompt: string - Text description (required)
  • data: FileInput - Input image (required)
  • seed?: number - Random seed
  • resolution?: string - Output resolution
  • prompt: string - Style description (required)
  • data: FileInput - Input video (required)
  • seed?: number - Random seed
  • resolution?: string - Output resolution
  • enhance_prompt?: boolean - Auto-enhance prompt
  • num_inference_steps?: number - Number of inference steps (pro only)
  • prompt: string - Transition description (required)
  • start: FileInput - First frame image (required)
  • end: FileInput - Last frame image (required)
  • seed?: number - Random seed
  • resolution?: string - Output resolution
  • prompt: string - Text description (required)
  • seed?: number - Random seed
  • resolution?: string - Output resolution
  • orientation?: string - Output orientation
  • prompt: string - Style description (required)
  • data: FileInput - Input image (required)
  • seed?: number - Random seed
  • resolution?: string - Output resolution
  • enhance_prompt?: boolean - Auto-enhance prompt

Next Steps

I