Installation
Install the dexcost TypeScript SDK with npm, including optional LLM provider packages.
npm install @dexcost/sdkOptional extras
LLM provider SDKs are optional — install only the ones your application uses. dexcost detects them at runtime and instruments only those it finds; missing providers are silently skipped.
The following packages are declared as optional peer dependencies in @dexcost/sdk:
| Provider | Package to install |
|---|---|
| OpenAI | npm install openai |
| Anthropic | npm install @anthropic-ai/sdk |
| Vercel AI | npm install ai |
| Google Gemini | npm install @google/generative-ai |
| AWS Bedrock | npm install @aws-sdk/client-bedrock-runtime |
| Cohere | npm install cohere-ai |
Note: @google/generative-ai, @aws-sdk/client-bedrock-runtime, and cohere-ai are instrumented at runtime but are not listed as formal peer dependencies in package.json. Install them when your application uses those providers.
For example, to add OpenAI and Anthropic alongside dexcost:
npm install @dexcost/sdk openai @anthropic-ai/sdkplaywright is an optional peer dependency, required only if you use the browser adapter (trackBrowser):
npm install playwrightRequirements
Node.js 18 or later. The core package depends only on ajv, ajv-formats, decimal.js, and js-yaml — no LLM provider SDK is required for local tracking. The local SQLite buffer uses better-sqlite3, which is listed as both an optional peer dependency and an optional dependency; install it if you want on-disk buffering (npm install better-sqlite3).
Verify your install
import { init, close } from '@dexcost/sdk';
const tracker = init({ environment: 'development' });
console.log('dexcost initialized:', tracker.config.storageMode);
close();This prints dexcost initialized: local when the import resolves correctly. config and storageMode are properties of the ResolvedConfig type exported from @dexcost/sdk. If the import fails, verify that your package.json includes "type": "module" or that you are using a bundler or tsx/ts-node with ESM support.