create static method

Future<Engine> create(
  1. EngineConfig config
)

Loads config.modelPath — a URL the page can fetch (blob:, https:) — on config.backend: WebGPU for Backend.gpu, WebAssembly for Backend.cpu (whose threadCount becomes the runtime's number_of_threads). One attempt, no fallback. Pass Backend.gpu for Gemma 4's GPU export: the default Backend.cpu fails it at the first send (0.19.0: "Environment was not initialized during streaming.").

Throws UnsupportedError for what does not run on the web (see the library comment), StateError when the page did not load @litert-lm/core or loaded one without what this release calls, and LiteRtLmEngineCreateException with the runtime's message when it refuses the model.

Implementation

static Future<Engine> create(EngineConfig config) => createWebEngine(config);