SDK
trackedCall()
Wraps a standard (non-streaming) LLM call and logs cost data to your dashboard. Supports Anthropic, OpenAI, Google Gemini, and any OpenAI-compatible provider (DeepSeek, xAI, Perplexity). Returns the identical response as the underlying call.
Usage
import { trackedCall } from '@llmcosttracker/sdk'const response = await trackedCall({client: anthropic, feature: 'summarize', userId: session.userId, apiKey: 'lct_live_your_key_here', params: {model: 'claude-sonnet-4-6', messages, max_tokens: 1024,},})Parameters
Returns
The exact response from the underlying LLM call — identical to calling the provider's API directly.
Error handling
If logging fails for any reason, the error is caught silently. The function always returns the LLM response — a logging failure will never throw or affect your application.
Next: trackedStream() →