Skip to content
Lovelace

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 thisStart here
A third-party app that sends compute through Lovelace@reasonabletech/lattice-clientLattice Cloud SDK quickstart
A backend that already speaks OpenAI-compatible chatExisting OpenAI SDK with the Lattice base URLOpenAI-compatible API
Runtime setup for a user's own machineLattice Cloud personal-runtime REST or SDK helpersPersonal runtimes
Local automation on the same machine as the daemonLocal daemon IPC or CLILattice quickstart
Code on this computer that calls local modelsExisting OpenAI SDK with the local base URLLocal OpenAI-compatible API
A coding agent that manages the local runtimelattice-ctl mcpLattice MCP server
Local model configuration for the daemonlattice-ctl and provider configurationLocal 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:

bash
pnpm add @reasonabletech/lattice-client

Use an OAuth access token when the signed-in user should authorize the app to use their compute context:

ts
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:

ts
const compute = new LatticeClient({
  credential: { kind: "apiKey", apiKey: process.env.LOVELACE_API_KEY! },
});

To create a key from your project directory, run:

bash
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:

  1. Your app signs in the user or authenticates with a developer key.
  2. Your backend calls Lattice Cloud through @reasonabletech/lattice-client or an OpenAI-compatible SDK.
  3. Lattice Cloud authorizes the request, chooses the target runtime, and meters the work.
  4. If the target is personal, the user's local daemon receives the work through its outbound relay connection.
  5. 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.