Installation
Install the dexcost TypeScript SDK with npm, including optional LLM provider packages.
npm install dexcostOptional 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.
| 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 |
For example, to add OpenAI and Anthropic alongside dexcost:
npm install dexcost 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 better-sqlite3, ajv, ajv-formats, and js-yaml — no LLM provider SDK is required for local tracking.
Verify your install
import { init, close } from 'dexcost';
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. 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.