UNPKG

@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

23 lines (22 loc) • 1.19 kB
import type { TokenUsage, UsageContext } from "../types/index.js"; /** Convert proxy wire usage into disjoint billing buckets. Codex input already * includes cache tokens; reasoning is included in output for both providers. * OpenAI's documented formula subtracts both cached_tokens and cache_write_tokens: * https://developers.openai.com/api/docs/guides/prompt-caching#monitor-cache-performance */ export declare function proxyTokenUsage(usage: UsageContext): TokenUsage; /** * Read Anthropic's `usage.cache_creation.ephemeral_1h_input_tokens` — the * 1-hour-TTL share of `cache_creation_input_tokens` — from an untyped usage * object. Returns undefined when the breakdown is absent (older replies, or a * request that wrote no 1h breakpoint), so callers leave the field unset and * price exactly as before. */ export declare function readCacheCreation1hTokens(usage: unknown): number | undefined; /** * Spread target for a usage literal: the key exists only when a 1h count was * observed, so every payload without one keeps its exact old shape. */ export declare function oneHourCacheWriteFields(count: number | undefined): { cacheCreation1hTokens?: number; };