Latten

How do you instrument a TypeScript AI app for cost and access visibility?

Add observe-only tracking at the places your app crosses boundaries: the request actor, LLM calls, database reads or writes, external APIs, and agent handoffs. With @latten/sdk, those calls keep returning the same values, while Latten records who acted, what was reached, and what the model cost.

See it on a live graph — no signup →

Start at the actor

Use withActor at the request entry point so downstream calls answer the basic question: who is this AI acting for? If no principal exists, leave it unattributed.

Wrap LLM and data calls

Use track around model calls and data touches. The SDK normalizes token usage across OpenAI, Anthropic, and Gemini shapes and records data reach without copying values.

Let the installer propose the diff

@latten/installer scans a TypeScript repo for likely crossings, then an AI coding agent can place the SDK calls and open a reviewable PR.

How it works

  1. 1. Install the SDK Add @latten/sdk and initialize it with the Latten endpoint and token.
  2. 2. Seed the actor Wrap each request or job with withActor when a principal is known.
  3. 3. Track crossings Wrap LLM, data, external API, and handoff calls with track.
  4. 4. Verify traffic Run the app and confirm crossings arrive in the Latten graph.

Common questions

Will tracking change return values?

No. track returns the wrapped function's result and is designed to be observe-only.

What happens if the network fails?

Events are buffered and delivered without throwing into the host app.

Can I use an AI coding agent to do this?

Yes. Add the @latten/installer MCP server and ask the agent to instrument the app with Latten.