dexcost
TypeScript

Installation

Install the dexcost TypeScript SDK with npm, including optional LLM provider packages.

npm install @dexcost/sdk

Optional 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:

ProviderPackage to install
OpenAInpm install openai
Anthropicnpm install @anthropic-ai/sdk
Vercel AInpm install ai
Google Gemininpm install @google/generative-ai
AWS Bedrocknpm install @aws-sdk/client-bedrock-runtime
Coherenpm 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/sdk

playwright is an optional peer dependency, required only if you use the browser adapter (trackBrowser):

npm install playwright

Requirements

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.

On this page