Quick Start
Get Vault running in your project in under five minutes. This guide covers package installation, SDK initialization, and sending your first request to the inference API. By the end, you will have a working integration you can build on.
Prerequisites
- Node.js
18.xor higher (LTS recommended) - A Vault account with an active workspace. Create one free
- Your
VAULT_API_KEYfrom the dashboard. Settings → API Keys - Basic familiarity with async/await in JavaScript or TypeScript.
Installation
Install the official Vault SDK. All three package managers are supported.
# npm $ npm install @vault/sdk --save # pnpm $ pnpm add @vault/sdk # yarn $ yarn add @vault/sdk
zod ^3.22 for schema validation at runtime. If you do not have it installed, add it alongside: npm install zod. Zod is not bundled to avoid version conflicts in monorepos.Setup Guide
Create a single client instance and export it. Pass your API key via environment variable. The Create a single client instance and export it. Pass your API key via environment variable. The workspace field maps to your workspace slug found in Settings.
import { VaultClient } from '@vault/sdk';
export const vault = new VaultClient({
apiKey: process.env.VAULT_API_KEY!,
workspace: process.env.VAULT_WORKSPACE ?? 'default',
timeout: 30_000,
});Create a Create a .env.local file at the root of your project. Never commit this file.
VAULT_API_KEY=vlt_live_xxxxxxxxxxxxxxxxxxxxxxxx VAULT_WORKSPACE=my-workspace # Optional VAULT_BASE_URL=https://api.vault.dev VAULT_TIMEOUT=30000
Call Call vault.infer() with a model and prompt. The response includes the generated text and token usage.
import { vault } from '@/lib/vault';
const result = await vault.infer({
model: 'vault-3-turbo',
prompt: 'Explain the Vault SDK in one sentence.',
maxTokens: 128,
});
console.log(result.text);
// → "The Vault SDK provides a type-safe..."For long-running completions, use the streaming API to receive tokens incrementally. Pass For long-running completions, use the streaming API. Pass stream: true and iterate the async generator.
import { vault } from '@/lib/vault';
const stream = vault.stream({
model: 'vault-3-turbo',
prompt: 'Write a haiku about distributed systems.',
});
for await (const chunk of stream) {
process.stdout.write(chunk.delta);
}