@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
28 lines (27 loc) • 1.12 kB
TypeScript
/**
* Analytics cost helpers.
*
* Prefer costs already computed by the telemetry/pricing pipeline
* (`utils/pricing.calculateCost` / span `ai.cost.total`). This module
* is a thin compatibility wrapper — it does not maintain a second
* hardcoded pricing table.
*/
/**
* Calculate cost from token counts using the canonical SDK pricing table.
* Returns 0 when the provider/model combination is unknown.
*
* Partial model-name matching uses longest-prefix preference inside
* `calculateCost` / `findRates` — shorter keys (e.g. `gpt-4o`) never
* win over more specific ones (e.g. `gpt-4o-mini`).
*
* @param model - Model name
* @param inputTokens - Number of input tokens
* @param outputTokens - Number of output tokens
* @param provider - Provider name (improves rate lookup; defaults to
* cross-provider search via openrouter alias)
* @returns Total cost in USD
*/
export declare function calculateAdvancedCost(model: string | undefined, inputTokens: number, outputTokens: number, provider?: string, cacheTokens?: {
cacheReadTokens?: number;
cacheCreationTokens?: number;
}): number;