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 |
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#
| 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 Uint8Array) |
engine.dispose() | Lifecycle | Clean up engine resources |