/** * Model Pricing Table * * List prices for the runtimes Crewly drives, used to turn raw token counts * into a cost figure for the Usage dashboard. * * Two things to keep in mind when reading a cost produced from this table: * * 1. These are pay-as-you-go API list prices. An agent running under a Max * subscription does not generate a bill at these rates — the number is an * API-equivalent, useful for comparing agents against each other and for * spotting runaway context, not for reconciling an invoice. * 2. Cache reads are far cheaper than fresh input and cache writes are dearer, * so a cost computed without splitting them out is wrong by an order of * magnitude for a long-lived agent. Every rate here is cache-aware and * {@link calculateCost} requires the split. * * When a model is not listed by name we fall back to its family (the `opus` / * `sonnet` / `haiku` substring) and finally to the sonnet tier. The resolved * rate carries a `source` so callers can mark an estimated cost as estimated * rather than presenting a guess as a measurement. * * @module services/monitoring/model-pricing */ /** Per-token USD rates for one model, split by how the tokens were billed. */ export interface ModelRate { /** USD per fresh (uncached) input token */ input: number; /** USD per output token */ output: number; /** USD per token read from the prompt cache */ cacheRead: number; /** USD per token written to the prompt cache */ cacheWrite: number; /** * A second rate card for long prompts, when the model has one (Claude * Haiku 5.5: 5x above 100K prompt tokens). It applies to a round-trip * whose prompt (fresh input + cache reads + cache writes) is larger than * `aboveTokens`. */ longPrompt?: { aboveTokens: number; rate: Omit; }; } /** A {@link ModelRate} plus how confidently it was matched to the model. */ export interface ResolvedModelRate extends ModelRate { /** * `exact` — the model id is listed by name. * `family` — matched on a family substring (`opus`/`sonnet`/`haiku`/ * `fable`, `deepseek`, `gpt-5`, `gemini-2.5-pro|flash`). * `default` — nothing matched; the sonnet tier was assumed. * * Anything other than `exact` means the cost is an estimate. */ source: 'exact' | 'family' | 'default'; } /** * Opus-class list price (USD per 1M tokens) of the 4.6–5 generation; also * the rate for an unlisted opus model. */ export declare const OPUS_TIER: ModelRate; /** Claude Opus 5.5: cheaper than Opus 5, and cache reads are 0.05x input. */ export declare const OPUS_5_5_TIER: ModelRate; /** * Sonnet-class list price (USD per 1M tokens) of the 5 / 5.5 generation; * also the rate for an unlisted sonnet model. */ export declare const SONNET_TIER: ModelRate; /** * Claude Haiku 5.5 (USD per 1M tokens) for prompts up to 100K tokens; a * longer prompt is billed at 5x. Also the rate for an unlisted haiku model. */ export declare const HAIKU_TIER: ModelRate; /** * Claude Fable 5.1 (USD per 1M tokens); cache reads are 0.025x input. Also * the rate for an unlisted fable model. */ export declare const FABLE_TIER: ModelRate; /** * Resolves the billing rate for a model id. * * @param model - Model id as the runtime reported it (e.g. `claude-opus-5`) * @returns The rate plus how it was matched; never throws, never returns null * * @example * ```typescript * const rate = resolveRate('claude-opus-5'); // source: 'exact' * const guess = resolveRate('claude-opus-9'); // source: 'family' * ``` */ export declare function resolveRate(model: string): ResolvedModelRate; /** The four token counts that make up one model round-trip. */ export interface TokenSplit { /** Fresh input tokens (not served from cache) */ input: number; /** Output tokens */ output: number; /** Input tokens served from the prompt cache */ cacheRead: number; /** Input tokens written into the prompt cache */ cacheWrite: number; } /** * Computes the cache-aware cost of one or more model round-trips. * * @param split - The four token counts of ONE round-trip (the long-prompt * rate card is chosen from its prompt size); pass 0 for any the runtime omits * @param model - Model id as the runtime reported it * @returns Cost in USD, and whether the rate was an exact match * * @example * ```typescript * const { cost, estimated } = calculateCost( * { input: 500, output: 200, cacheRead: 690_000, cacheWrite: 0 }, * 'claude-opus-5', * ); * ``` */ export declare function calculateCost(split: TokenSplit, model: string): { cost: number; estimated: boolean; rateSource: ResolvedModelRate['source']; }; //# sourceMappingURL=model-pricing.d.ts.map