Atune Docs
Get started

Quickstart

Install the atune SDK, verify capture, then ask your first question.

atune is the published npm package. npx atune init detects Next.js and known auth dependencies, installs the SDK, and writes server-side environment variables. Review the generated wiring before running your app.

Not on Next.js? Use Any backend instead: track() on any Node server, or the HTTP API from any language.

Requirements

  • Node 18+
  • The package declares Next.js 14+ as an optional peer dependency. This is not a guarantee that the installer handles every version or auth configuration.
  • npx atune init creates proxy.ts for a fresh app (Next.js 16). On Next.js 14/15, use middleware.ts via Manual setup.
  • Existing src/middleware.ts and custom auth/response handlers need manual review: the installer does not reliably chain every existing handler.

1. Run init

npx atune init# When prompted, paste your workspace API key (Settings → API key)

Paste your workspace API key when prompted. You'll find it in Atune under Settings → API key. Type or paste it into the terminal yourself, not into an AI chat. The installer message is not proof of a connection or received signal.

Keep your key server-side

ATUNE_API_KEY is the only secret. It is written to .env.local and used only on the server. Never ship it to the browser, and never commit it to a public repo.

2. What init wrote

init adds two variables to .env.local:

VariableWhat
ATUNE_API_KEYYour workspace key. The only secret. Server-side only.
ATUNE_URLYour Atune host. Defaults to https://useatune.com.

The installer chooses an existing src/proxy.ts, proxy.ts, or root middleware.ts; otherwise it creates proxy.ts. Keep existing auth and redirects intact. For custom responses, call atune(request, response) inside your existing handler as shown in Manual setup.

Capture needs a resolved account ID. Without one, no event is sent. Confirm that users in the same customer company resolve to the same account. Generate an authenticated request, then open Settings → Event log in Atune and check that the newest event carries that account and user before calling the installation connected.

3. Ask your first question

Once you have verified capture, replace acme with the actual account ID:

import { understand } from "atune";

const result = await understand("account:acme", "how healthy is this account?");

if (result.knows) {
  console.log(result.answer, result.confidence, result.citations);
} else {
  console.log("Not enough understanding yet.");
}

Every answer is grounded in your workspace's real signals and cited. When there isn't enough understanding yet, it returns knows: false rather than guessing.

Next steps

On this page