Search Docs
Loading...
Skip to content

Configuration

Set up CE.SDK engine with license keys, user IDs, and configuration options for server-side processing using the native engine of @cesdk/node.

CreativeEngine.init() initializes the CE.SDK engine for headless operations in Node.js environments.

import CreativeEngine from '@cesdk/node';
const config = {
license: process.env.CESDK_LICENSE || '',
};
const engine = await CreativeEngine.init(config);

This guide covers required and optional configuration properties, and runtime APIs for server-side CE.SDK usage with the native engine.

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
userId string — User identifier for MAU tracking
logger function Console Custom logging function
role 'Creator' | 'Adopter' | 'Viewer' | 'Presenter' 'Creator' User role for feature access
baseURL string Bundled assets Base URL or directory for resolving engine and content assets. init rejects a URL that the engine cannot parse, such as one with [ in its path
device 'auto' | 'gpu' | 'cpu' 'auto' Render device selection (native engine only)
engine 'auto' | 'native' | 'wasm' 'auto' Engine to start. 'auto' starts the WASM engine where the native engine cannot run
featureFlags object — Feature flag overrides

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.

const config = {
license: 'YOUR_CESDK_LICENSE_KEY',
};
const engine = await CreativeEngine.init(config);

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.

const config = {
license: 'YOUR_CESDK_LICENSE_KEY',
userId: 'user-123',
};
const engine = await CreativeEngine.init(config);

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').

const config = {
license: 'YOUR_CESDK_LICENSE_KEY',
logger: (message, level) => {
if (level === 'Error') {
console.error('[CE.SDK]', message);
}
},
};
const engine = await CreativeEngine.init(config);

Render Device#

The native engine renders on the platform’s GPU by default (Metal on macOS, EGL on Linux, Direct3D 12 on Windows) and automatically falls back to CPU rendering when no compatible GPU is available. Use the device property to override this behavior: 'gpu' fails initialization if no GPU context can be created, and 'cpu' forces CPU rendering.

On Windows, the GPU must run Direct3D 12 at feature level 11_0. A server without a GPU has only a software adapter, so there 'auto' renders on the CPU and 'gpu' fails. The first GPU render of a scene compiles its shaders, which can take a few seconds for scenes with blurs, shadows and effects. The engine keeps the compiled shaders in the temporary folder of the user, so later processes on the same machine skip that step.

const config = {
license: 'YOUR_CESDK_LICENSE_KEY',
device: 'cpu',
};
const engine = await CreativeEngine.init(config);

Engine Selection#

The engine property chooses the engine that CreativeEngine.init() starts:

  • 'auto' (default) starts the native engine. It starts the WASM engine when this host has no native binary, the binary does not load or the license does not cover the native engine.
  • 'native' starts the native engine, or throws an error when the native engine cannot start.
  • 'wasm' starts the WASM engine.

When 'auto' starts the WASM engine, it logs why. 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. If the license covers only the WASM engine, the WASM engine unlocks with the license that the native engine already fetched, so there is no second activation. An instance keeps its engine until you dispose it.

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.

The WASM engine has no video export, and attachCanvas, getFrameInfo and editor.supportsP3 throw on it. In a video pipeline, pass engine: 'native' so that initialization fails instead of starting the WASM engine:

const config = {
license: 'YOUR_CESDK_LICENSE_KEY',
engine: 'native',
};
const engine = await CreativeEngine.init(config);

Licensed Codec Pack on Linux#

Download the Linux x86_64 codec pack from your licensing dashboard. The pack is a codec module, which CE.SDK starts as a separate process. Extract it into a folder of its own, such as /srv/cesdk-codec-modules, and set the environment variable CESDK_CODEC_MODULES to that folder before loading CE.SDK. Without the variable, CE.SDK uses no licensed codecs.

On Linux x64 and Windows, the @cesdk/node platform package also contains open-source codec modules in a codec-modules folder next to the engine binary. CE.SDK starts them without any configuration. It reads the CESDK_CODEC_MODULES directory first, so a module there replaces a bundled module of the same name. Keep the licensed pack outside node_modules, because a reinstall replaces that folder.

Set it in the shell:

Terminal window
CESDK_CODEC_MODULES="/srv/cesdk-codec-modules" node index.mjs

Or set it in Node.js using process.env before importing CE.SDK:

process.env.CESDK_CODEC_MODULES = '/srv/cesdk-codec-modules';
const { default: CreativeEngine } = await import('@cesdk/node');

Use a dynamic import here so the assignment runs first. With CommonJS, set the variable before require('@cesdk/node'). Restart the process after changing the path. See the Node Native setup guide for download and extraction instructions.

Runtime Settings#

After initialization, configure engine behavior using type-specific setting methods. Settings control features like double-click crop behavior and highlight colors.

engine.editor.setSettingBool('page/title/show', false);
const value = engine.editor.getSettingBool('page/title/show');

Exporting Results#

After processing a scene, export the result to a file. The engine’s block.export() method returns a Blob on both engines. Convert it to a Buffer before writing it to the file system.

import fs from 'fs/promises';
const blob = await engine.block.export(page, { mimeType: 'image/png' });
await fs.writeFile('./output.png', Buffer.from(await blob.arrayBuffer()));

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.

try {
// ... processing logic
} finally {
engine.dispose();
}

API Reference#

Method Category Purpose
CreativeEngine.init() Initialization Initialize headless engine with config
engine.editor.setSettingBool() Runtime Set boolean engine setting
engine.editor.setSettingString() Runtime Set string engine setting
engine.editor.setSettingEnum() Runtime Set enum engine setting
engine.block.export() Export Export block to image format (returns Blob)
engine.dispose() Lifecycle Clean up engine resources