import type { NexusAIConfig } from '../types/config.js'; import type { CacheTtl } from '../types/providers.js'; import type { ResponseCost, ResponseMeta, TokenUsage } from '../types/response.js'; /** Token counts as a provider reported them, for `buildUsage()`. */ export interface UsageInput { /** * Prompt tokens billed at the standard input rate, excluding anything served from or written to * the provider cache. Adapters whose provider reports one combined prompt total must subtract * the cached counts before passing them here, so each token is priced exactly once. */ inputTokens?: number; /** Completion tokens, reasoning included. */ outputTokens?: number; /** Prompt tokens the provider served from its cache instead of processing again. */ cachedReadTokens?: number; /** Prompt tokens the provider stored into its cache on this call. */ cachedWriteTokens?: number; /** Share of `outputTokens` the provider attributes to internal reasoning. */ reasoningTokens?: number; } /** * Normalizes provider token counts into the portable `TokenUsage` shape. * * Cached and reasoning counts are only carried when the provider actually reported them, so a * zero and an unknown stay distinguishable. */ export declare function buildUsage(input: UsageInput): TokenUsage; /** Options for `priceUsage()`. */ export interface PriceUsageOptions { /** The model to price against. */ model: string; /** The usage to price. */ usage: TokenUsage; /** Cache lifetime the writes were made with, which some providers price differently. */ cacheTtl?: CacheTtl; /** Application registry entries and prices. */ config?: Pick; /** Set when the provider returned an authoritative charge rather than a local estimate. */ reported?: number; } /** Prices a normalized usage record, keeping each token class on its own line. */ export declare function priceUsage(options: PriceUsageOptions): ResponseCost; /** Options for `buildMeta()`: the provider's token counts plus the call's context. */ export interface BuildMetaOptions extends UsageInput { /** The provider that answered. */ provider: string; /** The model that answered. */ model: string; /** How long the call took, in milliseconds. */ latencyMs: number; /** Cache lifetime the writes were made with. */ cacheTtl?: CacheTtl; /** Application registry entries and prices. */ config?: Pick; /** Request id. Defaults to a generated one. */ requestId?: string; } /** * Builds a complete `ResponseMeta` from provider token counts. * * Every adapter shares this so pricing, cached-token accounting, and the deprecated formatted * string stay consistent instead of being re-derived per provider. */ export declare function buildMeta(options: BuildMetaOptions): ResponseMeta; /** * Guarantees `usage` and `cost` on a response built by a custom provider that predates them. * * Returns the same object when nothing is missing, so the normal path does no work. */ export declare function ensureUsageAndCost(meta: ResponseMeta, config?: Pick): ResponseMeta; /** Numeric cost for metrics and budgets, without parsing the formatted display string. */ export declare function costAmount(meta: ResponseMeta): number;