Skip to main content

Install the package

Import paths

The SDK exposes two separate entry points. @gatelit/sdk — the main client for making AI requests from your frontend or backend:
@gatelit/sdk/sign — backend-only token signing helper:
@gatelit/sdk/sign is a separate import so that the Web Crypto token-signing code is never bundled into browser builds. Only import it from server-side code (Node.js, edge functions, API routes).

TypeScript support

The package ships its own TypeScript declarations — no @types package needed. All public types (GatelitClientConfig, ChatMessage, ChatResponse, StreamChunk, etc.) are exported from @gatelit/sdk.

Minimal end-to-end setup

The typical flow is:
  1. Your backend signs a short-lived token with signToken.
  2. Your frontend fetches that token and passes it to GatelitClient.
  3. The client attaches the token to every request and the gateway enforces your policy.
Backend — issue a signed token (e.g. a Next.js API route):
Frontend — create a client and send a message:
getToken is called before every request. Cache the token in your own variable and only re-fetch when it is close to expiry to avoid unnecessary round-trips.