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:
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",
})

# Save the video
with open("output.mp4", "wb") as f:
    f.write(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:
# Using a file path
with open("image.jpg", "rb") as image_file:
    result = await client.process({
        "model": models.video("lucy-pro-i2v"),
        "prompt": "Animate with gentle motion and wind",
        "data": image_file,
        "seed": 123,
        "resolution": "1080p",
    })
Parameters:
  • prompt (required) - Text description of the animation style
  • data (required) - Input image (file object, bytes, or URL)
  • 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:
# Using a file path
with open("video.mp4", "rb") as video_file:
    result = await client.process({
        "model": models.video("lucy-pro-v2v"),
        "prompt": "Convert to anime style with vibrant colors",
        "data": video_file,
        "enhance_prompt": True,
        "num_inference_steps": 50,
    })
You can also use URLs as input:
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 object, bytes, or URL string)
  • 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:
with open("start.jpg", "rb") as start_image, open("end.jpg", "rb") as end_image:
    result = await client.process({
        "model": models.video("lucy-pro-flf2v"),
        "prompt": "Smooth cinematic transition with natural motion",
        "start": start_image,
        "end": end_image,
        "resolution": "1080p",
    })
Parameters:
  • prompt (required) - Text description of the transition
  • start (required) - First frame image (file object, bytes, or URL)
  • 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:
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",
})

# Save the image
with open("output.png", "wb") as f:
    f.write(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:
with open("image.jpg", "rb") as image_file:
    result = await client.process({
        "model": models.image("lucy-pro-i2i"),
        "prompt": "Oil painting style with impressionist brushstrokes",
        "data": image_file,
        "enhance_prompt": True,
        "seed": 123,
    })
Parameters:
  • prompt (required) - Text description of the style transformation
  • data (required) - Input image (file object, bytes, or URL)
  • 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:
from typing import Union, BinaryIO

FileInput = Union[BinaryIO, bytes, str]
Examples:
# File object from open()
with open("image.jpg", "rb") as file:
    result = await client.process({
        "model": models.video("lucy-pro-i2v"),
        "prompt": "Animate this",
        "data": file,
    })

# Bytes
with open("image.jpg", "rb") as f:
    image_bytes = f.read()

result = await client.process({
    "model": models.video("lucy-pro-i2v"),
    "prompt": "Animate this",
    "data": image_bytes,
})

# URL string
result = await client.process({
    "model": models.video("lucy-pro-v2v"),
    "prompt": "Transform this video",
    "data": "https://example.com/video.mp4",
})

Cancellation

Cancel long-running operations using asyncio.Event:
import asyncio

cancel_token = asyncio.Event()

try:
    result = await client.process({
        "model": models.video("lucy-pro-t2v"),
        "prompt": "Epic fantasy landscape with dragons",
        "cancel_token": cancel_token,
    })
except asyncio.CancelledError:
    print("Generation cancelled")

# Cancel the request from another coroutine
cancel_token.set()
You can use this to implement cancel buttons in your UI:
import asyncio

current_cancel_token: asyncio.Event | None = None

async def generate_video(prompt: str):
    global current_cancel_token
    
    # Cancel previous request if any
    if current_cancel_token:
        current_cancel_token.set()
    
    current_cancel_token = asyncio.Event()
    
    result = await client.process({
        "model": models.video("lucy-pro-t2v"),
        "prompt": prompt,
        "cancel_token": current_cancel_token,
    })
    
    return result

def cancel_generation():
    if current_cancel_token:
        current_cancel_token.set()

Error Handling

The SDK raises specific exceptions for different failure scenarios:
from decart_sdk import create_decart_client, DecartSDKError

try:
    with open("image.jpg", "rb") as image_file:
        result = await client.process({
            "model": models.video("lucy-pro-i2v"),
            "prompt": "Animate this image",
            "data": image_file,
        })
except DecartSDKError as error:
    if error.code == "INVALID_INPUT":
        print(f"Invalid input: {error.message}")
    elif error.code == "INVALID_API_KEY":
        print("Invalid API key")
    elif error.code == "PROCESSING_ERROR":
        print(f"Processing failed: {error.message}")
    else:
        print(f"Unknown error: {error.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: dict - Configuration dictionary with model and inputs:
    • model - Model from models.video() or models.image()
    • cancel_token: asyncio.Event - Optional event for cancellation
    • Additional fields depend on the model (see below)
Returns: bytes - The generated/transformed media Inputs by Model:
  • prompt: str - Text description (required)
  • seed: int - Random seed for reproducibility
  • resolution: str - Output resolution (e.g., “720p”, “1080p”)
  • orientation: str - Output orientation (“landscape”, “portrait”)
  • prompt: str - Text description (required)
  • data: FileInput - Input image (required)
  • seed: int - Random seed
  • resolution: str - Output resolution
  • prompt: str - Style description (required)
  • data: FileInput - Input video (required)
  • seed: int - Random seed
  • resolution: str - Output resolution
  • enhance_prompt: bool - Auto-enhance prompt
  • num_inference_steps: int - Number of inference steps (pro only)
  • prompt: str - Transition description (required)
  • start: FileInput - First frame image (required)
  • end: FileInput - Last frame image (required)
  • seed: int - Random seed
  • resolution: str - Output resolution
  • prompt: str - Text description (required)
  • seed: int - Random seed
  • resolution: str - Output resolution
  • orientation: str - Output orientation
  • prompt: str - Style description (required)
  • data: FileInput - Input image (required)
  • seed: int - Random seed
  • resolution: str - Output resolution
  • enhance_prompt: bool - Auto-enhance prompt

Next Steps

I