SDK Configuration
createVaultkitClient accepts a VaultkitConfig object. Use it to control authentication, timeouts, retries, logging, and the way dynamic vaults are generated.
Required properties
Always provide these three values when creating a client:| Property | Type | Description |
|---|---|---|
apiKey | string | Your Vaultkit API key (represents your organization). |
userId | string | Identifier for the end user the agent is acting on behalf of. |
vaultId or featureMappingId | string | Either a static vault ID, or a dynamic vault template ID. Only one is required. |
About static vs. dynamic vaults:
- Use
vaultIdif you have a pre-configured vault in the Vaultkit dashboard.- Use
featureMappingIdto generate vaults on demand. Vaultkit will create a per-user vault the first timeconnect()is called.
Optional properties
Fine-tune behavior with these optional settings:| Property | Type | Default | Purpose |
|---|---|---|---|
selectedProviders | string[] | undefined | Restrict which providers to activate for dynamic vaults. Must be a subset of the feature mapping’s providers. |
selectedScopes | string[] | undefined | Further limit provider permissions for dynamic vaults. |
timeout | number | 30000 | Timeout (ms) for discovery requests made during connect(). |
retries | number | 3 | Retry attempts for transient network failures. |
baseUrl | string | https://app.vaultkit.dev | Only set this if using a self-hosted or custom Vaultkit instance. Default points to production. |
log | (level, message, data?) => void | Lightweight console logger | Receive verbose status messages (info, warn, error). Useful for piping diagnostics to your observability stack. |
Example: Interactive flow (recommended)
This is the typical flow for apps with user-facing UIs. Users select features and authenticate providers through the SDK UI components, then you create a client with the resulting vault.Example: Programmatic flow (advanced)
Use this only when you need to dynamically provision vaults server-side without user interaction.Example: Backend/Internal agent (no UI)
For internal services and scheduled jobs, use pre-configured vaults without any UI components:Inspecting the client
createVaultkitClient returns a small API:
vaultkit.tools– Getter that exposes the array of Vaultkit tools afterconnect()succeeds.await vaultkit.connect()– Resolves the correct vault and fetches tools. It also handles dynamic provisioning whenfeatureMappingIdis present.await vaultkit.disconnect()– Clears in-memory tool state. Call this infinallyblocks to avoid leaking resources.
connect() once during startup.