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 Node.js bindings.

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

import CreativeEngine from '@cesdk/node-native';
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 native bindings.

Required Configuration#

The license property is the only required configuration. All other properties have sensible defaults.

Property Type Purpose
license string License key to remove export watermarks

The license key validates your CE.SDK subscription and removes watermarks from exports. Without a valid license, exports include a watermark. Get a free trial license at https://img.ly/forms/free-trial.

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
device 'auto' | 'gpu' | 'cpu' 'auto' Render device selection (native bindings only)
featureFlags object Feature flag overrides, mirrors @cesdk/node

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#

On macOS and Linux, the native bindings render on the platform’s GPU by default (Metal on macOS, EGL on Linux) and automatically fall 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.

Windows renders on the CPU only. There, 'gpu' always fails and 'auto' selects the CPU.

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

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, matching the @cesdk/node API. 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