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.

PropertyTypePurpose
licensestringLicense 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.

PropertyTypeDefaultPurpose
userIdstringUser identifier for MAU tracking
loggerfunctionConsoleCustom logging function
role'Creator' | 'Adopter' | 'Viewer' | 'Presenter''Creator'User role for feature access

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);

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 Uint8Array that you can write directly to the file system.

import fs from 'fs/promises';
const pngBuffer = await engine.block.export(page, 'image/png');
await fs.writeFile('./output.png', Buffer.from(pngBuffer));

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#

MethodCategoryPurpose
CreativeEngine.init()InitializationInitialize headless engine with config
engine.editor.setSettingBool()RuntimeSet boolean engine setting
engine.editor.setSettingString()RuntimeSet string engine setting
engine.editor.setSettingEnum()RuntimeSet enum engine setting
engine.block.export()ExportExport block to image format (returns Uint8Array)
engine.dispose()LifecycleClean up engine resources