Skip to main content

Initializing

Single-phase and async. There is no separate services phase to await, unlike Swift and Kotlin.

Reading state

Capabilities

Generated from live backend and runtime probes, never from namespace presence alone. An unavailable modality is reported honestly in unavailable rather than failing with a generic error the first time you use it. Read this before offering a feature in your interface.

Storage

The browser needs a persistence story the native SDKs do not have, and this namespace is it.
chooseDirectory() requires a user gesture. Calling it outside a click handler is rejected by the browser.
After a reload, a previously granted directory has to be re-acquired with restore(), and a lapsed permission needs requestAccess(). Neither happens automatically.

Models

list, get, and register are synchronous on Web and async on every other SDK. Code ported from Swift or React Native will not need await here.
You rarely need load directly. Generation auto-loads what it needs and downloads when options.model names a model that is absent.

Hugging Face token

Needed for gated or private repositories.

Events

Resetting

Unloads models, closes sessions, and clears state.