v2.0.0
v2.0.0 is a major release with a redesigned client API, full TypeScript 5 support, and a new streaming architecture. Contains breaking changes from v1.x.
Breaking Changes
v2.0.0 contains breaking changes. Review the migration guide below before upgrading.
breakingvault.complete() renamed to vault.infer()All existing calls to vault.complete() must be renamed. The signature is otherwise identical.
breakingStreamChunk.text renamed to StreamChunk.deltaThe streaming chunk type now uses delta instead of text for consistency with the REST API.
breakingVaultConfig.key renamed to VaultConfig.apiKeyThe constructor option key is now apiKey. Zod validation will throw at startup if you use the old name.
breakingNode.js 16 droppedThe SDK now requires Node.js 18 or higher. Node.js 16 reached end-of-life in September 2023.
New Features
featvault.stream()First-class streaming API returning an async generator. Replaces the callback-based streaming from v1.
featLifecycle hooksonRequest, onResponse, and onError hooks for instrumentation, logging, and observability.
featWorkspace supportMulti-workspace routing built into the client. Create separate clients per environment.
featvault-3-pro modelNew 200k context model for complex reasoning and long document processing.
featisVaultError() type guardNarrow caught errors to VaultError in catch blocks without casting.
Migration Guide
diff
- import { VaultClient } from '@vault/sdk';
+ import { VaultClient } from '@vault/sdk'; // same import
const vault = new VaultClient({
- key: process.env.VAULT_API_KEY!,
+ apiKey: process.env.VAULT_API_KEY!,
workspace: process.env.VAULT_WORKSPACE ?? 'default',
});
- const result = await vault.complete({ model, prompt });
+ const result = await vault.infer({ model, prompt });
// Streaming
- vault.stream({ model, prompt }, (chunk) => {
- process.stdout.write(chunk.text);
- });
+ for await (const chunk of vault.stream({ model, prompt })) {
+ process.stdout.write(chunk.delta);
+ }