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 | @reasonabletech/lattice-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 |
| Code on this computer that calls local models | Existing OpenAI SDK with the local base URL | Local OpenAI-compatible API |
| A coding agent that manages the local runtime | lattice-ctl mcp | Lattice MCP server |
| 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 @reasonabletech/lattice-client
Use an OAuth access token when the signed-in user should authorize the app to use their compute context:
import { LatticeClient } from "@reasonabletech/lattice-client";
const compute = new LatticeClient({
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 LatticeClient({
credential: { kind: "apiKey", apiKey: process.env.LOVELACE_API_KEY! },
});
To create a key from your project directory, run:
ada developer api-key create
The command writes the key to .env.local (or .env) as LOVELACE_API_KEY
and never prints it. It signs you in through the browser first when needed.
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
To run model calls on this computer's local models, use the
local OpenAI-compatible API: the daemon serves it at
http://127.0.0.1:11435/v1 with no key, so an existing OpenAI SDK only needs
its base URL changed. It is the right target while you develop on your own
machine; it is not reachable from other machines, so a shipped app still calls
Lattice Cloud.
For the other local 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
@reasonabletech/lattice-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.