@reasonabletech/lattice-client
v0.0.1
Published
TypeScript SDK for the Lattice Cloud gateway
Maintainers
Readme
@reasonabletech/lattice-client
TypeScript SDK for calling the Lattice Cloud gateway.
Overview
This package is for external or internal callers that need to talk to the Lattice Cloud gateway through a typed client instead of hand-written fetch calls. It wraps gateway requests with request construction, response parsing, and structured client errors. Use it from developer tools, platform services, or tests that submit compute work or inspect gateway-owned runtime state.
Import Surface
@reasonabletech/lattice-clientexposes the gateway client and its client configuration/error types.- Shared protocol types come from
@lovelace-ai/compute; use that package when no HTTP client behavior is needed. - Callers must provide environment-specific base URLs, credentials, and fetch behavior where appropriate.
Usage
Construct the client at the application or service boundary where credentials and gateway URL are already known.
import { LatticeClient } from "@reasonabletech/lattice-client";
const client = new LatticeClient({
baseUrl: "https://lattice.example.com",
credential: { kind: "apiKey", apiKey },
});Personal-runtime dispatch (generateTextForPersonalRuntime, chatCompleteForPersonalRuntime) requires an OAuth user access token as the credential, not an API key. An API key identifies which developer is calling, not which end user's device to route to — a personal-runtime call made with an API key throws PersonalRuntimeRequiresUserTokenError before any network call.
const client = new LatticeClient({
baseUrl: "https://lattice.example.com",
credential: { kind: "oauth", accessToken },
});Do not bury default gateway URLs in this package. Hosted apps and operators own deployment-specific configuration.
Realtime subscriptions
subscribeRealtimeSession streams a session's action-stream as typed
RealtimeSessionEvents. It reconnects with backoff on a dropped connection,
resuming from the last frame's sequence via Last-Event-ID so no events are
missed; a terminal stream_error frame throws a LatticeError.
for await (const event of client.subscribeRealtimeSession("sess_123")) {
if (event.type === "action.delta") process.stdout.write(event.delta);
}Public API
The client API is a typed HTTP boundary over the Lattice gateway. It should remain thin over the shared compute protocol and report failures through structured client errors. If gateway behavior changes, update this README, the generated API docs, and the gateway-facing tests in the same work.
Development
Run package checks from the repository root with pnpm --filter @reasonabletech/lattice-client typecheck, pnpm --filter @reasonabletech/lattice-client lint, and pnpm --filter @reasonabletech/lattice-client test.
Update this README when top-level usage, import boundaries, or package ownership changes. Use generated API documentation for symbol-level detail instead of duplicating export catalogs here.
Related Documentation
- Generated API documentation
- @lovelace-ai/compute README
- Backend Services Standards
- Documentation Organization
License
MIT
