Documentation Index
Fetch the complete documentation index at: https://docs.voight.xyz/llms.txt
Use this file to discover all available pages before exploring further.
init is the wizard sub-command in @voightxyz/sdk for apps that already call OpenAI or Anthropic in production. It automates the install of the App SDKs (@voightxyz/openai and @voightxyz/anthropic) so you don’t have to copy snippets from the docs.
Run it from the root of your app:
What the wizard does
The flow is single-pass — no daemon, no background services, no follow-up commands:- Detects providers. Reads
package.json(bothdependenciesanddevDependencies). If neitheropenainor@anthropic-ai/sdkis found, the wizard aborts cleanly and explains what to install. - Detects package manager. Looks for
pnpm-lock.yaml→yarn.lock→bun.lockb→ falls back to npm. The install command printed at the end matches what you actually use. - Detects framework. Looks for
nextin deps. If present, the usage snippet at the end uses Next.js Route Handler shape (export async function POST); otherwise Express style (app.post('/api/chat', ...)). - Prompts for privacy level. Three options:
- Minimal — metadata only (tokens, latency, cost). No prompts or responses captured.
- Standard ★ — full content with 12-pattern PII scrubbing. Required for customer-facing apps where end-user PII flows through prompts.
- Full — raw, no scrubbing. Debugging only.
- Prompts for the Voight API key (
vk_...). Validates it againstapi.voight.xyzbefore writing anything — typo’d keys get caught here, not in production. - Prompts for an agent name. Defaults to your
package.jsonname; press enter to accept or type a custom one. - Writes
src/lib/voight.ts(orlib/voight.tsif your project doesn’t havesrc/). Contains the wrapped clients for the providers it detected, plus a header comment explaining how to swap if your provider keys come from AWS Secrets Manager / Vault / Doppler instead of env. - Appends
VOIGHT_KEYto.env.local. Creates the file if absent. ExistingVOIGHT_KEYlines are left alone. - Prints the install command + usage snippet. The install command uses your package manager (e.g.
pnpm add @voightxyz/openai @voightxyz/anthropicif pnpm-lock detected).
What it does NOT do
- ❌ Never touches
~/.claude,~/.cursor,~/.codexor any other path outside your project’scwd. This is the key difference fromsetup(which wires IDE hooks globally). - ❌ Never asks for or stores your provider keys (
OPENAI_API_KEY,ANTHROPIC_API_KEY). Those belong to your app and stay there. The Voight wrapper instruments the requests but never reads the auth header. - ❌ Never runs
npm installfor you. We print the command so you can run it in your terminal — that way you stay in control of your lockfile (and we don’t accidentally pin a version you didn’t approve). - ❌ Never overrides an existing
src/lib/voight.ts. If the file already exists, the wizard aborts and asks you to move it aside.
Example session
Generated file
src/lib/voight.ts after a dual-provider install with agent: 'production-chat-api', privacy: 'standard':
import { openai, anthropic, withTrace, log } from '@/lib/voight'.
Non-interactive flags
If you’re scripting the install (CI, Dockerfile, dotfile bootstrap), pass everything as flags:VOIGHT_KEY and VOIGHT_PRIVACY from env too if you’d rather not pass them inline. Refuses to write anything if the key validation fails — same safety as the interactive flow.
Manual install (skip the wizard)
The wizard is convenience, not requirement. If you’d rather wire things up by hand, the OpenAI SDK and Anthropic SDK pages walk through the same install — npm install, wrap your client, setVOIGHT_KEY. Three commands, no wizard.
Troubleshooting
`No openai or @anthropic-ai/sdk detected in package.json`
`No openai or @anthropic-ai/sdk detected in package.json`
The wizard only operates on projects that already use one of those SDKs. If you’re in a monorepo, Then re-run the wizard.
cd into the app folder first (e.g. cd apps/web). If your project doesn’t use either yet, install the provider SDK first:`Key validation failed: invalid key (401)`
`Key validation failed: invalid key (401)`
The key you pasted isn’t recognised by
api.voight.xyz. Common causes:- Typo in the paste — Voight keys start with
vk_and are about 50 characters - The key was revoked — check dashboard/settings and generate a new one
- Wrong key entirely (e.g. you pasted an OpenAI key by mistake)
`src/lib/voight.ts already exists`
`src/lib/voight.ts already exists`
The wizard refuses to overwrite an existing file. Either move it aside (
mv src/lib/voight.ts src/lib/voight.ts.bak) or delete it, then re-run.`.env.local already has a VOIGHT_KEY entry`
`.env.local already has a VOIGHT_KEY entry`
Not an error — the wizard leaves your existing
VOIGHT_KEY alone instead of overwriting it. If you genuinely want to rotate the key, edit .env.local manually.The wizard detected the wrong package manager
The wizard detected the wrong package manager
The wizard picks the package manager whose lockfile it sees first (pnpm → yarn → bun → npm). If you have stale lockfiles from a previous tool, delete them. The wizard never runs the install itself — you can always run
pnpm add ... / yarn add ... / bun add ... regardless of what the wizard printed.Safety guarantees
init is implemented in src/init.ts of @voightxyz/sdk with zero edits to the existing setup, hook, or any other module. It cannot affect users running setup or hook because:
- The CLI dispatches by sub-command name (
setup/init/hook) — thesetupbranch runs first and returns before reachinginit. init.tshas no imports fromsetup.ts. There’s no shared mutable state, no shared global config.initwrites only insideprocess.cwd()— nohomedir()calls, no~/.configpaths. The shape is enforced by the test suite (256 tests, including a structural assertion thatinitnever produces a write path outside cwd).
Next
- OpenAI SDK — what the wrapped OpenAI client captures
- Anthropic SDK — what the wrapped Anthropic client captures
- Tracing —
withTraceandlogin depth - Per-user spend — the
tags.userIdpattern the wizard’s snippet demonstrates - AI Apps overview — the dashboard surface the wizard targets