Local Lattice Programmatic Usage
This page explains the boundary between local Lattice integration and the hosted Lattice Cloud gateway. Use it when you are deciding which SDK or API a developer-facing app should call.
Local Lattice is the daemon and runtime on a machine. Lattice Cloud is the hosted gateway that third-party apps call to discover runtimes, route compute, meter requests, and handle OAuth or developer-key authorization.
Choose The Correct API
| You are building... | Use this | Start here |
|---|---|---|
| A third-party app that sends compute through Lovelace | @lovelace-ai/compute-client | Lattice Cloud SDK quickstart |
| A backend that already speaks OpenAI-compatible chat | Existing OpenAI SDK with the Lattice base URL | OpenAI-compatible API |
| Runtime setup for a user's own machine | Lattice Cloud personal-runtime REST or SDK helpers | Personal runtimes |
| Local automation on the same machine as the daemon | Local daemon IPC or CLI | Lattice quickstart |
| Local model configuration for the daemon | lattice-ctl and provider configuration | Local model setup |
Do not use local-daemon integration as the public API for a third-party app. The app-facing API is Lattice Cloud. The local daemon can still serve the request, but it does so as a paired personal runtime behind the gateway.
Gateway SDK Quick Path
For a third-party app backend, install the Lattice Cloud compute client:
pnpm add @lovelace-ai/compute-client
Use an OAuth access token when the signed-in user should authorize the app to use their compute context:
import { ComputeClient } from "@lovelace-ai/compute-client";
const compute = new ComputeClient({
credential: { kind: "oauth", accessToken },
});
const [runtime] = await compute.listReachablePersonalRuntimes();
if (runtime === undefined) {
throw new Error("No reachable personal runtime is available.");
}
const completion = await compute.chatCompleteForPersonalRuntime(runtime, {
messages: [{ role: "user", content: "Summarize this document." }],
});
console.log(completion.choices[0]?.message.content);
Use a developer API key instead when your product owns the traffic and should be billed directly:
const compute = new ComputeClient({
credential: { kind: "apiKey", apiKey: process.env.LOVELACE_API_KEY! },
});
Keep developer keys in trusted backend code. Browser-only code should use Sign in with Lovelace and call your backend, not the gateway directly with a developer key.
Local-Daemon Integration
Use local-daemon integration only when your code runs on the same machine as the Lattice daemon and the user has intentionally installed and configured that runtime.
Common local cases include:
- local developer tools that inspect daemon health
- scripts that configure local providers
- desktop or CLI workflows that manage local sessions
- relay setup commands that pair the daemon with Lattice Cloud
For these flows, the CLI docs are the stable public surface:
Mental Model
The clean application shape is:
- Your app signs in the user or authenticates with a developer key.
- Your backend calls Lattice Cloud through
@lovelace-ai/compute-clientor an OpenAI-compatible SDK. - Lattice Cloud authorizes the request, chooses the target runtime, and meters the work.
- If the target is personal, the user's local daemon receives the work through its outbound relay connection.
- Your backend returns the completion response to your app.
This keeps app authorization, billing, and runtime selection in one public gateway contract while preserving local execution when the user chooses it.