Edit on GitHub
Beginner~5 min

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.x or higher (LTS recommended)
  • A Vault account with an active workspace. Create one free
  • Your VAULT_API_KEY from 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.

bash
# npm
$ npm install @vault/sdk --save

# pnpm
$ pnpm add @vault/sdk

# yarn
$ yarn add @vault/sdk
Peer dependency note. The Vault SDK requires 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

1
Initialize the Vault client

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.

lib/vault.ts
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,
});
2
Set your environment variables

Create a Create a .env.local file at the root of your project. Never commit this file.

.env.local
VAULT_API_KEY=vlt_live_xxxxxxxxxxxxxxxxxxxxxxxx
VAULT_WORKSPACE=my-workspace

# Optional
VAULT_BASE_URL=https://api.vault.dev
VAULT_TIMEOUT=30000
3
Send your first inference request

Call Call vault.infer() with a model and prompt. The response includes the generated text and token usage.

app/api/test/route.ts
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..."
4
Stream a response

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.

app/api/stream/route.ts
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);
}
Ready to get started?
Create a free account and send your first API request in minutes.
Sign inCreate free account