Getting started
Quickstart
Get from zero to live cost tracking in under 5 minutes.
1. Create a project
Sign in to LLM Cost Tracker and create your first project. A project maps to one app or codebase. You'll get an API key you'll use in step 3.
2. Install the SDK
npm install @llmcosttracker/sdk3. Wrap your LLM call
Replace your existing Anthropic call with trackedCall(). The return value is identical — nothing else in your code needs to change.
// Beforeconst response = await anthropic.messages.create({model: 'claude-sonnet-4-6', messages, max_tokens: 1024,})// After — same return value, now trackedimport { trackedCall } from '@llmcosttracker/sdk'const response = await trackedCall({client: anthropic, group: 'search', userId: session.userId, tier: session.plan, // 'free' | 'pro' | 'enterprise'apiKey: 'lct_live_your_key_here', params: {model: 'claude-sonnet-4-6', messages, max_tokens: 1024,},})The group tag is how LLM Cost Tracker attributes costs in the dashboard. Use any string that makes sense for your product — a feature name like 'search', a team name, a workflow, or a client. The tier tag enables spend enforcement by pricing tier — see Budget enforcement.
The same trackedCall() function works for any OpenAI-compatible provider — pass an OpenAI, DeepSeek, xAI, or Perplexity client and the SDK detects it automatically. For Google Gemini, pass a GoogleGenerativeAI client instance. The params shape stays exactly as each provider expects it.
4. Verify data is flowing
Make one LLM call in your app, then open your LLM Cost Tracker dashboard. You should see the event appear in the call log within a few seconds.
You can also test with curl:
curl -X POST https://www.llmcosttracker.com/api/events \ -H "Content-Type: application/json" \ -d '{"api_key": "lct_live_your_key_here", "group": "search", "user_id": "test_user", "tier": "free", "model": "claude-sonnet-4-6", "input_tokens": 1000, "output_tokens": 200, "latency_ms": 1200}'5. Set spend targets (optional)
Once data is flowing, head to the Spend targets page to set a monthly dollar target per group. The dashboard will track actual vs plan and alert you when something is drifting.
6. Set spend limits (optional)
Set per-user or per-tier spend limits and have them enforced automatically in the SDK. No additional instrumentation required — if you're passing userId and tier, you're already set up.
Done
Head to your dashboard to see cost by group, by user, and a full call log.
Next: SDK reference →