Set up CE.SDK engine with license keys, asset base URLs, user IDs, and configuration options for server-side processing.
CreativeEngine.init() initializes the CE.SDK engine for headless operations in Node.js environments. The configuration object controls license validation, asset loading, user tracking, and logging behavior.
This guide covers required and optional configuration properties, and runtime APIs for server-side CE.SDK usage.
License Key#
CE.SDK is a commercial product and a license is required for production use. Without a license, CE.SDK runs in evaluation mode, which watermarks exports.
| Property | Type | Purpose |
|---|---|---|
license |
string |
License key that removes export watermarks |
Request a license through IMG.LY Contact Sales.
const config = { license: process.env.CESDK_LICENSE || ''};
const engine = await CreativeEngine.init(config);Optional Configuration#
These properties customize engine behavior and are all optional.
| Property | Type | Default | Purpose |
|---|---|---|---|
baseURL |
string |
The package’s assets folder |
Location of the engine assets, such as the fallback fonts and emoji |
userId |
string |
— | User identifier for MAU tracking |
logger |
function |
Console | Custom logging function |
role |
'Creator' | 'Adopter' | 'Viewer' | 'Presenter' |
'Creator' |
User role for feature access |
engine |
'auto' | 'native' | 'wasm' |
'auto' |
Engine to start. 'native' throws instead of starting the WASM engine |
featureFlags |
object |
— | Experimental feature toggles |
With engine: 'auto', CreativeEngine.init() starts the native engine. It starts the WASM engine when the host has no native binary, the binary does not load or the license does not cover the native engine. It logs the reason once per process, through your logger or on stderr. The level is Warning when the native engine is installed on a host that it supports but does not load or start, or cannot reach the license server for an API key, and Info otherwise. The native engine reads its own resources, such as fonts and ICU data, from the @cesdk/node package, so baseURL can point at your own assets, on the local disk or remote. Without the engine option, the CESDK_ENGINE environment variable chooses the engine, so a deployment can change it without a code change. The WASM engine has no video export on Node.js, so pass engine: 'native' when your pipeline needs video export.
An API key has no claims that 'auto' can read before the start, so the native engine activates the key first. With a key that covers only the WASM engine, this adds about 0.7 seconds on macOS and 0.9 seconds on Windows to the first start in each process. Behind a proxy that only Node.js knows, such as one that you set in code, the first two starts in each process wait for the timeout of the native HTTP client: about 60 seconds on macOS, 30 seconds on Windows and 10 seconds on Linux. Pass engine: 'wasm', or set CESDK_ENGINE=wasm, to skip the native attempt.
Configuration Properties#
License Key#
The license key validates your CE.SDK subscription and removes watermarks from exports. Without a valid license, exports include a watermark.
// License key removes watermarks from exports// Request a license at https://img.ly/forms/contact-sales/const license = process.env.CESDK_LICENSE ?? '';Asset Base URL#
The baseURL property specifies the location of the engine assets, such as the fallback fonts and emoji. By default, @cesdk/node reads them from its own assets folder, so it works offline. To serve them from another location, copy node_modules/@cesdk/node/assets there and set baseURL to it.
The server package does not include asset source plugins. Content assets like stickers and filters are only available in browser builds.
// Location of core engine assets (WASM, data files)// For production, host assets yourself instead of using the IMG.LY CDN:// const baseURL = 'https://your-cdn.com/cesdk-assets/';User ID#
Provide a unique user identifier for accurate Monthly Active User (MAU) tracking. This helps count users correctly when processing requests from different sources.
// User ID for accurate MAU trackingconst userId = 'server-process-' + process.pid;Custom Logger#
Replace the default console logging with a custom logger function. The logger receives a message string and an optional log level ('Info', 'Warning', or 'Error').
/** * Custom logger that prefixes messages with timestamp and level */function createLogger(prefix: string) { return (message: string, level = 'Info') => { const timestamp = new Date().toISOString(); console.log(`[${timestamp}] [${prefix}] [${level}] ${message}`); };}Initialization#
Pass the configuration object to CreativeEngine.init() to start the engine.
// Initialize CE.SDK engine in headless modeconst engine = await CreativeEngine.init(initConfig);Runtime Settings#
After initialization, configure engine behavior using engine.editor.setSetting() and engine.editor.getSetting(). Settings control features like double-click crop behavior and highlight colors.
/** * Demonstrate runtime settings */function demonstrateRuntimeSettings(engine: CreativeEngine): void { console.log('\n=== Runtime Settings ===\n');
// Configure engine settings using setSetting/getSetting engine.editor.setSetting('doubleClickToCropEnabled', false); const cropEnabled = engine.editor.getSetting('doubleClickToCropEnabled'); console.log(`doubleClickToCropEnabled: ${cropEnabled}`);
engine.editor.setSetting('highlightColor', { r: 0, g: 0.5, b: 1, a: 1 }); const highlightColor = engine.editor.getSetting('highlightColor'); console.log(`highlightColor: ${JSON.stringify(highlightColor)}`);}Exporting Results#
After processing a scene, export the result to a file. The engine’s block.export() method returns a Blob that you can convert to a Buffer for file system operations.
/** * Export the result to output directory */async function exportResult( engine: CreativeEngine, page: number): Promise<string> { // Create output directory if (!existsSync('output')) { mkdirSync('output', { recursive: true }); }
// Export as PNG const blob = await engine.block.export(page, { mimeType: 'image/png' }); const buffer = Buffer.from(await blob.arrayBuffer()); const outputPath = 'output/configuration-demo.png'; writeFileSync(outputPath, buffer); console.log(`\nExported to ${outputPath}`);
return outputPath;}Engine Disposal#
Clean up engine resources when done processing by calling engine.dispose(). Place this in a finally block to ensure cleanup even if errors occur.
// Clean up engine resourcesengine.dispose();API Reference#
| Method | Category | Purpose |
|---|---|---|
CreativeEngine.init() |
Initialization | Initialize headless engine with config |
engine.editor.setSetting() |
Runtime | Set engine setting |
engine.editor.getSetting() |
Runtime | Get engine setting |
engine.block.export() |
Export | Export block to image format |
engine.dispose() |
Lifecycle | Clean up engine resources |