Skip to main content
The frontend asks for a registered name such as products.page; the host decides what that name means inside an authenticated context. This keeps storage, tenancy, and authorization on the server.
This guide follows the 0.1 API. The package requires Node.js 20 or newer. Confirm the latest published version and migration notes before installing a newer 0.x release.

Preserve authority

You need:
  • A Node.js 20 or newer application using Fetch Request and Response objects.
  • Existing authentication and tenancy resolution in the host route layer.
  • A read service that accepts an AbortSignal.
  • A frontend cache representation that can consume the returned JSON payload.

Register a resource

The registry is an allowlist, not a router. This example validates the page and derives the account from authenticated context:
Validation runs before prediction.accepted. The resolver receives authenticated context, validated parameters, request metadata, the host cache key, and a deadline-aware signal. The executor measures serialized bytes when bytes is omitted; materialWork defaults to true.

Mount the operations

Cogni defines operations, not paths. Mount all three behind the host’s authentication middleware:
Build AppContext from the same account, permissions, and read services as the foreground route. All operations use POST; predictions stream NDJSON when requested and otherwise return JSON.

Connect the client

Initialize the client with the same route map:
The client defaults to credentials: "same-origin". Cross-origin authentication and extra headers remain host decisions.

Continue