🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(pricing): cut gpt-5.6-sol price across all tiers (#16436)
langfuse-bot24062d400f72
diff --git a/.agents/skills/add-model-price/references/model-audit-memory.md b/.agents/skills/add-model-price/references/model-audit-memory.mdindex cfb3a4123d..5e321b9e1f 100644--- a/.agents/skills/add-model-price/references/model-audit-memory.md+++ b/.agents/skills/add-model-price/references/model-audit-memory.md@@ -12,17 +12,19 @@ audit date.## Latest useful snapshot-**Audit date:** 2026-08-21+**Audit date:** 2026-08-24All prices listed as `$X / MTok` (per million tokens). Per-token JSON values: divide by 1,000,000.-The 2026-08-21 run re-fetched the full Anthropic pricing table, the full OpenAI-standard-pricing-table dump, and the Gemini AI Studio pricing pages-(`ai.google.dev/pricing` and `ai.google.dev/gemini-api/docs/pricing`, with an explicit-Free/Paid column split) and confirmed every price below unchanged from the 2026-08-14-snapshot. Rows below still read "Re-confirmed ... [date of last dedicated verification]"-where that earlier wording remains accurate; treat any row without an explicit-2026-08-21 note as re-confirmed today via one of these three full-table fetches.+The 2026-08-24 run re-fetched the full Anthropic pricing table, the full OpenAI+standard-pricing-table dump (plus a targeted verbatim re-fetch of the gpt-5.6 family and+its dedicated model/Fast-mode/Flex rows), and a targeted subset of the Gemini AI Studio+pricing pages and models page. Anthropic and Gemini rows checked this run were confirmed+unchanged; the only price change found was **gpt-5.6-sol** (see its row and+`provider-sources-and-price-keys.md` for detail). Rows below still read "Re-confirmed ...+[date of last dedicated verification]" where that earlier wording remains accurate; treat+any row without an explicit 2026-08-24 or 2026-08-21 note as last confirmed on one of+those two dates via a full-table fetch, not independently re-checked today.| Provider | Model / pricing entry | Pricing checked | Price confirmed | Tiering checked | Tiering correct | Change | Official source(s) | Comments || -------- | --------------------- | --------------- | --------------- | --------------- | --------------- | ------ | ------------------ | -------- |@@ -48,9 +50,9 @@ where that earlier wording remains accurate; treat any row without an explicit| Anthropic | claude-3-sonnet-20240229 | Input $3/MTok, Output $15/MTok | No | Not on current page | Not applicable | None | https://platform.claude.com/docs/en/about-claude/pricing | Not re-verified this run. Legacy. || Anthropic | claude-3-haiku-20240307 | Input $0.25/MTok, Output $1.25/MTok | No | Not on current page | Not applicable | None | https://platform.claude.com/docs/en/about-claude/pricing | Not re-verified this run. Legacy. || AWS Bedrock | claude-3-5-sonnet-20240620 / claude-3.5-sonnet-20241022 (Public Extended Access SKU) | $6.00/MTok input, $30.00/MTok output, $7.50/MTok cache write, $0.60/MTok cache read | Yes (SKU confirmed real, Aug 4 2026) | Distinct dated SKU, not a context-length tier | Not applicable | Unresolved | https://aws.amazon.com/bedrock/pricing/ | Not re-verified this run; permanent documented limitation (model-ID string match cannot distinguish billing SKU) — see provider-sources-and-price-keys.md. |-| OpenAI | gpt-5.6-sol | Input $5/MTok, Cached $0.50/MTok, Cache write $6.25/MTok, Output $30/MTok | Yes | Large Context (>272K): $10/$1.00/$12.50/$45 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed via full standard-pricing-table dump this run. |-| OpenAI | gpt-5.6-terra | Input $2/MTok, Cached $0.20/MTok, Cache write $2.50/MTok, Output $12/MTok | Yes | Large Context (>272K): $4/$0.40/$5.00/$18 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed stable. |-| OpenAI | gpt-5.6-luna | Input $0.20/MTok, Cached $0.02/MTok, Cache write $0.25/MTok, Output $1.20/MTok | Yes | Large Context (>272K): $0.40/$0.04/$0.50/$1.80 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed stable. |+| OpenAI | gpt-5.6-sol | Input $4/MTok, Cached $0.40/MTok, Cache write $5.00/MTok, Output $20/MTok | Yes | Large Context (>272K): $8/$0.80/$10.00/$30; Fast mode 2x base ($8/$0.80/$10/$40, LC $16/$1.60/$20/$60); Flex 0.5x base ($2/$0.20/$2.50/$10, LC $4/$0.40/$5/$15) | Yes | Updated | https://developers.openai.com/api/docs/pricing https://developers.openai.com/api/docs/models/gpt-5.6-sol | **Price cut found 2026-08-24.** Previously $5/$0.50/$6.25/$30 standard, $10/$1.00/$12.50/$45 large-context. Confirmed via 3 independent fetches (aggregate table, targeted verbatim row quote, dedicated model page). Model page states "a 20% reduction in input pricing and a 33% reduction in output pricing", "promotional pricing available at least through November 21, 2026" — re-verify after that date. All 6 pricing-file tiers (Standard, Fast mode, Flex, Large Context, Fast+LC, Flex+LC) updated; multipliers (2x/1.5x large-context, 2x Fast mode, 0.5x Flex, 1.25x cache-write) all still reconcile with the new base price. |+| OpenAI | gpt-5.6-terra | Input $2/MTok, Cached $0.20/MTok, Cache write $2.50/MTok, Output $12/MTok | Yes | Large Context (>272K): $4/$0.40/$5.00/$18 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed unchanged 2026-08-24 (unlike sibling gpt-5.6-sol). |+| OpenAI | gpt-5.6-luna | Input $0.20/MTok, Cached $0.02/MTok, Cache write $0.25/MTok, Output $1.20/MTok | Yes | Large Context (>272K): $0.40/$0.04/$0.50/$1.80 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed unchanged 2026-08-24 (unlike sibling gpt-5.6-sol). || OpenAI | gpt-5.5-2026-04-23 (alias gpt-5.5) | Input $5/MTok, Cached $0.50/MTok, Output $30/MTok | Yes | Large Context (>272K): $10/$1.00/$45 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed unchanged. No cache-write pricing for this model. || OpenAI | gpt-5.5-pro-2026-04-23 (alias gpt-5.5-pro) | Input $30/MTok, Output $180/MTok; no cache | Yes | Large Context (>272K): $60/$270 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed unchanged. || OpenAI | gpt-5.4 | Input $2.50/MTok, Cached $0.25/MTok, Output $15/MTok | Yes | Large Context (>272K): $5.00/$0.50/$22.50 | Yes | None | https://developers.openai.com/api/docs/pricing | Re-confirmed unchanged. |@@ -185,3 +187,17 @@ where that earlier wording remains accurate; treat any row without an explicit`ai.google.dev/gemini-api/docs/pricing`, and `gemini-3-pro-preview` also does not appearon `ai.google.dev/gemini-api/docs/models`. Same status as finding #4; existing fileprices retained without fresh confirmation for a second consecutive run.++11. **Selectable models with no matching pricing regex — confirmed still a known,+ intentional gap (re-checked 2026-08-24)** — Cross-checked every selectable model in+ `anthropicModels`, `openAIModels`, `vertexAIModels`, and `googleAIStudioModels` against+ every `matchPattern` in the pricing file. All `openAIModels` and `anthropicModels`+ entries match. The following `vertexAIModels`/`googleAIStudioModels` entries have no+ matching pricing entry: `gemini-1.5-pro`, `gemini-1.5-flash`, `gemini-1.5-flash-8b`,+ `gemini-2.0-pro-exp-02-05`, `gemini-2.0-flash-exp`, `gemini-2.0-flash-thinking-exp-01-21`,+ `gemini-2.5-flash-preview-09-2025`, `gemini-2.5-flash-lite-preview-09-2025`. This matches+ the already-documented limitations in `provider-sources-and-price-keys.md` ("Gemini 1.5+ models" and "Gemini experimental / preview model IDs" sections) — these are+ retired/experimental IDs with no official pricing page entry, not a new finding. No file+ change made. Future audits do not need to re-run this full cross-check unless a new+ selectable model is added to `types.ts`.diff --git a/.agents/skills/add-model-price/references/provider-sources-and-price-keys.md b/.agents/skills/add-model-price/references/provider-sources-and-price-keys.mdindex 3fddfefbdc..4ded128680 100644--- a/.agents/skills/add-model-price/references/provider-sources-and-price-keys.md+++ b/.agents/skills/add-model-price/references/provider-sources-and-price-keys.md@@ -175,6 +175,30 @@ Always fetch pricing from the provider's official docs before editing.launch. Standard OpenAI matchPattern: `(?i)^(openai\/)?(gpt-5.3-codex)$`. Added to pricingfile and `openAIModels`in July 27 2026 audit. Official sources:`https://developers.openai.com/api/docs/pricing` and`https://developers.openai.com/api/docs/models/gpt-5.3-codex`.+- **GPT-5.6 Sol price cut (found August 24 2026)** — OpenAI cut pricing for+ `gpt-5.6-sol` only; `gpt-5.6-terra` and `gpt-5.6-luna` are unchanged (re-confirmed+ identical to their July 31 2026 values below). Confirmed via 3 independent WebFetch+ calls: the aggregate standard-pricing-table dump, a targeted verbatim quote of the+ Standard-table row, and a dedicated fetch of+ `https://developers.openai.com/api/docs/models/gpt-5.6-sol` (which states the change is+ "a 20% reduction in input pricing and a 33% reduction in output pricing" with+ "promotional pricing available at least through November 21, 2026" — re-check after that+ date). New standard (≤272K) price: $4.00/MTok input, $0.40/MTok cached input, $5.00/MTok+ cache write, $20.00/MTok output (previously $5.00/$0.50/$6.25/$30.00). New Large Context+ (>272K) price: $8.00/$0.80/$10.00/$30.00 (previously $10.00/$1.00/$12.50/$45.00). The+ 2x-input/1.5x-output large-context multiplier and the 1.25x-of-input cache-write+ multiplier both still hold exactly on the new base price. The Fast mode and Flex tiers+ (added August 20 2026) were independently re-fetched and also scale off the new base at+ their existing multipliers: Fast mode 2x base ($8.00/$0.80/$10.00/$40.00 standard,+ $16.00/$1.60/$20.00/$60.00 large-context), Flex 0.5x base ($2.00/$0.20/$2.50/$10.00+ standard, $4.00/$0.40/$5.00/$15.00 large-context). All six pricing-file tiers for+ `gpt-5.6-sol` were updated to match. Lesson: an aggregate WebFetch table dump can look+ identical in shape to a real price change vs. a hallucinated/garbled one (the first dump+ this run showed self-inconsistent numbers that didn't match any documented multiplier) —+ always cross-check a suspicious price-table result with a second, targeted verbatim-quote+ fetch and the model's own dedicated page before trusting it, and verify the documented+ formulas (large-context multiplier, cache-write multiplier) still reconcile with the new+ numbers before applying them.- **GPT-5.6 Terra / Luna price cut (found July 31 2026)** — OpenAI lowered pricing for`gpt-5.6-terra` and `gpt-5.6-luna` sometime between the July 27 and July 31 2026 audits;`gpt-5.6-sol` was unchanged. Confirmed via 4 independent WebFetch calls (the overviewdiff --git a/worker/src/__tests__/pricing-tier-matcher.test.ts b/worker/src/__tests__/pricing-tier-matcher.test.tsdeleted file mode 100644index 0c078515bb..0000000000--- a/worker/src/__tests__/pricing-tier-matcher.test.ts+++ /dev/null@@ -1,1588 +0,0 @@-import { describe, expect, it } from "vitest";-import { Decimal } from "decimal.js";-import { z } from "zod";-import { validateRegexPattern } from "@langfuse/shared";-import {- hasPricingTierUsageDetails,- matchPricingTier,- type PricingTierWithPrices,-} from "@langfuse/shared/src/server";-import { DefaultModelPriceSchema } from "../scripts/upsertDefaultModelPrices";-import defaultModelPrices from "../constants/default-model-prices.json";--describe("hasPricingTierUsageDetails", () => {- it("requires at least one usage detail, including zero-valued details", () => {- expect(hasPricingTierUsageDetails(undefined)).toBe(false);- expect(hasPricingTierUsageDetails({})).toBe(false);- expect(hasPricingTierUsageDetails({ input: 0 })).toBe(true);- });-});--describe("default-model-prices.json", () => {- it("should parse successfully with Zod schema (same validation as upsertDefaultModelPrices)", () => {- expect(() =>- z.array(DefaultModelPriceSchema).parse(defaultModelPrices),- ).not.toThrow();- });-- it("should have unique model IDs", () => {- const ids = defaultModelPrices.map((model) => model.id);- const uniqueIds = new Set(ids);- expect(ids.length).toBe(uniqueIds.size);- });-- it("should have unique pricing tier IDs globally", () => {- const allTierIds: string[] = [];- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- allTierIds.push(tier.id);- }- }- const uniqueTierIds = new Set(allTierIds);- expect(allTierIds.length).toBe(uniqueTierIds.size);- });-- it("should have unique model names", () => {- const modelNames = defaultModelPrices.map((model) => model.modelName);- const uniqueNames = new Set(modelNames);- expect(modelNames.length).toBe(uniqueNames.size);- });-- it("should have updatedAt greater than or equal to createdAt", () => {- for (const model of defaultModelPrices) {- const created = new Date(model.createdAt);- const updated = new Date(model.updatedAt);- expect(updated.getTime()).toBeGreaterThanOrEqual(created.getTime());- }- });-- it("should have valid date formats for all timestamps", () => {- for (const model of defaultModelPrices) {- const created = new Date(model.createdAt);- const updated = new Date(model.updatedAt);- expect(created.toString()).not.toBe("Invalid Date");- expect(updated.toString()).not.toBe("Invalid Date");- }- });-- it("should have at least one pricing tier per model", () => {- for (const model of defaultModelPrices) {- expect(model.pricingTiers.length).toBeGreaterThan(0);- }- });-- it("should have exactly one default tier per model", () => {- for (const model of defaultModelPrices) {- const defaultTiers = model.pricingTiers.filter((t) => t.isDefault);- expect(defaultTiers.length).toBe(1);- }- });-- it("should have default tier with priority 0 and no conditions", () => {- for (const model of defaultModelPrices) {- const defaultTier = model.pricingTiers.find((t) => t.isDefault);- expect(defaultTier).toBeDefined();- expect(defaultTier!.priority).toBe(0);- expect(defaultTier!.conditions).toEqual([]);- }- });-- it("should have default tier IDs in the form of ${modelId}_tier_default", () => {- for (const model of defaultModelPrices) {- const defaultTier = model.pricingTiers.find((t) => t.isDefault);- expect(defaultTier).toBeDefined();- const expectedId = `${model.id}_tier_default`;- expect(defaultTier!.id).toBe(expectedId);- }- });-- it("should have unique priorities within each model", () => {- for (const model of defaultModelPrices) {- const priorities = model.pricingTiers.map((t) => t.priority);- const uniquePriorities = new Set(priorities);- expect(priorities.length).toBe(uniquePriorities.size);- }- });-- it("should have unique tier names within each model", () => {- for (const model of defaultModelPrices) {- const names = model.pricingTiers.map((t) => t.name);- const uniqueNames = new Set(names);- expect(names.length).toBe(uniqueNames.size);- }- });-- it("should have non-negative priority values", () => {- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- expect(tier.priority).toBeGreaterThanOrEqual(0);- }- }- });-- it("should have integer priority values", () => {- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- expect(Number.isInteger(tier.priority)).toBe(true);- }- }- });-- it("should have at least one price per tier", () => {- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- expect(Object.keys(tier.prices).length).toBeGreaterThan(0);- }- }- });-- it("should have non-negative price values", () => {- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- for (const [usageType, price] of Object.entries(tier.prices)) {- expect(price).toBeGreaterThanOrEqual(0);- }- }- }- });-- it("should have valid number values for all prices (no NaN or Infinity)", () => {- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- for (const [usageType, price] of Object.entries(tier.prices)) {- expect(Number.isFinite(price)).toBe(true);- }- }- }- });-- it("should have same price keys across all tiers within a model", () => {- for (const model of defaultModelPrices) {- if (model.pricingTiers.length <= 1) continue;-- const defaultTier = model.pricingTiers.find((t) => t.isDefault);- expect(defaultTier).toBeDefined();-- const defaultKeys = Object.keys(defaultTier!.prices).sort();-- for (const tier of model.pricingTiers) {- if (tier.isDefault) continue;-- const tierKeys = Object.keys(tier.prices).sort();- expect(tierKeys).toEqual(defaultKeys);- }- }- });-- it("should have valid condition structures for non-default tiers", () => {- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- if (tier.isDefault) continue;-- // Non-default tiers must have at least one condition- expect(tier.conditions.length).toBeGreaterThan(0);-- for (const condition of tier.conditions) {- expect(condition).toHaveProperty("operator");- if ("usageDetailPattern" in condition) {- expect(condition).toHaveProperty("value");- expect(["gt", "gte", "lt", "lte", "eq", "neq"]).toContain(- condition.operator,- );- expect(typeof condition.value).toBe("number");- expect(typeof condition.caseSensitive).toBe("boolean");- expect(typeof condition.usageDetailPattern).toBe("string");- expect(condition.usageDetailPattern.length).toBeGreaterThan(0);- expect(condition.usageDetailPattern.length).toBeLessThanOrEqual(- 200,- );- } else {- expect(["model_parameters", "metadata"]).toContain(- condition.source,- );- expect(condition).toHaveProperty("key");- expect(condition.operator).toBe("in");- expect(condition.values).toEqual(- expect.arrayContaining([expect.any(String)]),- );- }- }- }- }- });-- it("should have valid regex patterns in all conditions", () => {- for (const model of defaultModelPrices) {- for (const tier of model.pricingTiers) {- for (const condition of tier.conditions) {- const pattern =- "usageDetailPattern" in condition- ? condition.usageDetailPattern- : null;- if (pattern !== null) {- expect(() => validateRegexPattern(pattern)).not.toThrow();- }- }- }- }- });-- it("should match AWS geographic inference profiles for Claude Haiku 4.5", () => {- const claudeModel = defaultModelPrices.find(- (model) => model.modelName === "claude-haiku-4-5-20251001",- );- expect(claudeModel).toBeDefined();-- expect(claudeModel!.matchPattern).toContain(- "(eu\\.|us\\.|apac\\.|au\\.|jp\\.|global\\.)?anthropic\\.claude-haiku-4-5-20251001-v1:0",- );- });-- it("should consistently support JP and AU prefixes for Anthropic Bedrock models", () => {- const bedrockModels = defaultModelPrices.filter((model) =>- model.matchPattern.includes("anthropic\\.claude"),- );- expect(bedrockModels.length).toBeGreaterThan(0);-- for (const model of bedrockModels) {- expect(model.matchPattern, model.modelName).toContain(- "(eu\\.|us\\.|apac\\.|au\\.|jp\\.|global\\.)?anthropic\\.claude",- );- }- });-- it("should correctly match claude-sonnet-4-5 with standard pricing", () => {- const claudeModel = defaultModelPrices.find(- (m) => m.id === "c5qmrqolku82tra3vgdixmys",- );- expect(claudeModel).toBeDefined();- expect(claudeModel!.modelName).toBe("claude-sonnet-4-5-20250929");- expect(claudeModel!.pricingTiers.length).toBe(1);-- // Convert to PricingTierWithPrices format- const tiers: PricingTierWithPrices[] = claudeModel!.pricingTiers.map(- (tier) => ({- id: tier.id,- name: tier.name,- isDefault: tier.isDefault,- priority: tier.priority,- conditions: tier.conditions,- prices: Object.entries(tier.prices).map(([usageType, price]) => ({- usageType,- price: new Decimal(price),- })),- }),- );-- const standardResult = matchPricingTier(tiers, {- input: 150000,- output: 5000,- });- expect(standardResult).not.toBeNull();- expect(standardResult?.pricingTierName).toBe("Standard");- expect(standardResult?.prices.input.toNumber()).toBe(0.000003);- });-- it("should price Gemini 3 Google Search grounding queries", () => {- const gemini3ModelNames = [- "gemini-3-pro-preview",- "gemini-3.1-pro-preview",- "gemini-3.5-flash",- "gemini-3-flash-preview",- "gemini-3.1-flash-lite",- "gemini-3.1-flash-lite-preview",- ];- const groundingUsageKeys = [- "grounding_queries",- "groundingQueries",- "web_search_queries",- "webSearchQueries",- ];-- for (const modelName of gemini3ModelNames) {- const model = defaultModelPrices.find((m) => m.modelName === modelName);- expect(model, modelName).toBeDefined();-- for (const tier of model!.pricingTiers) {- for (const usageKey of groundingUsageKeys) {- expect(tier.prices[usageKey], `${modelName}/${usageKey}`).toBe(14e-3);- }- }- }- });-- it("should price GPT-5.6 usage aliases across context and service tiers", () => {- const modelNames = ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"];-- for (const modelName of modelNames) {- const model = defaultModelPrices.find(- (candidate) => candidate.modelName === modelName,- );- expect(model, modelName).toBeDefined();- expect(model!.pricingTiers.map((tier) => tier.name)).toEqual([- "Standard",- "Fast mode · Large context (>272K)",- "Flex · Large context (>272K)",- "Fast mode",- "Flex",- "Large Context (>272K)",- ]);-- for (const tier of model!.pricingTiers) {- const prices = tier.prices as Record<string, number>;- expect(prices.cache_read_input_tokens).toBe(prices.input_cached_tokens);- expect(prices.reasoning_tokens).toBe(prices.output_reasoning_tokens);- expect(prices.input_cache_creation).toBeCloseTo(- prices.input * 1.25,- 15,- );- expect(prices.cache_write_tokens).toBeCloseTo(prices.input * 1.25, 15);- }- }-- const sol = defaultModelPrices.find(- (model) => model.modelName === "gpt-5.6-sol",- );- expect(sol).toBeDefined();-- const tiers: PricingTierWithPrices[] = sol!.pricingTiers.map((tier) => ({- id: tier.id,- name: tier.name,- isDefault: tier.isDefault,- priority: tier.priority,- conditions: tier.conditions,- prices: Object.entries(tier.prices).map(([usageType, price]) => ({- usageType,- price: new Decimal(price),- })),- }));-- const reportedUsage = {- input: 786,- cache_read_input_tokens: 718398,- output: 242,- reasoning_tokens: 25,- };- const reportedResult = matchPricingTier(tiers, reportedUsage);- expect(reportedResult?.pricingTierName).toBe("Large Context (>272K)");-- const reportedCost = Object.entries(reportedUsage).reduce(- (total, [usageType, units]) =>- total + (reportedResult?.prices[usageType]?.toNumber() ?? 0) * units,- 0,- );- expect(reportedCost).toBeCloseTo(0.738273, 12);-- expect(- matchPricingTier(tiers, { cache_write_tokens: 272001 })?.pricingTierName,- ).toBe("Large Context (>272K)");-- expect(- matchPricingTier(- tiers,- { cache_write_tokens: 272001 },- { modelParameters: { service_tier: "priority" } },- )?.pricingTierName,- ).toBe("Fast mode · Large context (>272K)");-- expect(- matchPricingTier(- tiers,- { cache_write_tokens: 272001 },- { modelParameters: { service_tier: "fast" } },- )?.pricingTierName,- ).toBe("Fast mode · Large context (>272K)");-- expect(- matchPricingTier(- tiers,- { input: 1000 },- { modelParameters: { service_tier: "priority" } },- )?.pricingTierName,- ).toBe("Fast mode");-- expect(- matchPricingTier(- tiers,- { input: 1000 },- { modelParameters: { service_tier: "fast" } },- )?.pricingTierName,- ).toBe("Fast mode");-- expect(- matchPricingTier(- tiers,- { input: 1000 },- { modelParameters: { service_tier: "flex" } },- )?.pricingTierName,- ).toBe("Flex");-- expect(- matchPricingTier(- tiers,- { cache_write_tokens: 272001 },- { modelParameters: { service_tier: "flex" } },- )?.pricingTierName,- ).toBe("Flex · Large context (>272K)");- });-- it.each(["fast", "priority"])(- "should match GPT-5.5 Fast mode for the %s service tier value",- (serviceTier) => {- const model = defaultModelPrices.find(- (candidate) => candidate.modelName === "gpt-5.5-2026-04-23",- );- expect(model).toBeDefined();-- const tiers: PricingTierWithPrices[] = model!.pricingTiers.map(- (tier) => ({- id: tier.id,- name: tier.name,- isDefault: tier.isDefault,- priority: tier.priority,- conditions: tier.conditions,- prices: Object.entries(tier.prices).map(([usageType, price]) => ({- usageType,- price: new Decimal(price),- })),- }),- );-- expect(- matchPricingTier(- tiers,- { input: 1000 },- { modelParameters: { service_tier: serviceTier } },- )?.pricingTierName,- ).toBe("Fast mode");- },- );-- it.each([- ["gpt-5.4", 5, 30],- ["gpt-5.4-2026-03-05", 5, 30],- ["gpt-5.4-mini", 1.5, 9],- ["gpt-5.4-mini-2026-03-17", 1.5, 9],- ["gpt-5.2", 3.5, 28],- ["gpt-5.2-2025-12-11", 3.5, 28],- ["gpt-5.1", 2.5, 20],- ["gpt-5.1-2025-11-13", 2.5, 20],- ["gpt-5", 2.5, 20],- ["gpt-5-2025-08-07", 2.5, 20],- ["gpt-5-mini", 0.45, 3.6],- ["gpt-5-mini-2025-08-07", 0.45, 3.6],- ["gpt-4.1", 3.5, 14],- ["gpt-4.1-2025-04-14", 3.5, 14],- ["gpt-4.1-mini", 0.7, 2.8],- ["gpt-4.1-mini-2025-04-14", 0.7, 2.8],- ["gpt-4.1-nano", 0.2, 0.8],- ["gpt-4.1-nano-2025-04-14", 0.2, 0.8],- ["gpt-4o", 4.25, 17],- ["gpt-4o-2024-05-13", 8.75, 26.25],- ["gpt-4o-2024-08-06", 4.25, 17],- ["gpt-4o-2024-11-20", 4.25, 17],- ["gpt-4o-mini", 0.25, 1],- ["gpt-4o-mini-2024-07-18", 0.25, 1],- ["o3", 3.5, 14],- ["o3-2025-04-16", 3.5, 14],- ["o4-mini", 2, 8],- ["o4-mini-2025-04-16", 2, 8],- ])(- "should price %s Fast mode",- (modelName, inputPerMillion, outputPerMillion) => {- const model = defaultModelPrices.find(- (candidate) => candidate.modelName === modelName,- );- const tier = model?.pricingTiers.find(- (candidate) => candidate.name === "Fast mode",- );-- expect(tier, modelName).toBeDefined();- expect(tier?.conditions).toContainEqual({- source: "model_parameters",- key: "service_tier",- operator: "in",- values: ["fast", "priority"],- });- expect(tier?.prices.input).toBeCloseTo(inputPerMillion * 1e-6, 15);- expect(tier?.prices.output).toBeCloseTo(outputPerMillion * 1e-6, 15);- },- );-- it.each([- ["gpt-5.6-sol", 2.5, 15],- ["gpt-5.6-terra", 1, 6],- ["gpt-5.6-luna", 0.1, 0.6],- ["gpt-5.5-2026-04-23", 2.5, 15],- ["gpt-5.5-pro-2026-04-23", 15, 90],- ["gpt-5.4", 1.25, 7.5],- ["gpt-5.4-2026-03-05", 1.25, 7.5],- ["gpt-5.4-pro", 15, 90],- ["gpt-5.4-pro-2026-03-05", 15, 90],- ["gpt-5.4-mini", 0.375, 2.25],- ["gpt-5.4-mini-2026-03-17", 0.375, 2.25],- ["gpt-5.4-nano", 0.1, 0.625],- ["gpt-5.4-nano-2026-03-17", 0.1, 0.625],- ["gpt-5.2", 0.875, 7],- ["gpt-5.2-2025-12-11", 0.875, 7],- ["gpt-5.1", 0.625, 5],- ["gpt-5.1-2025-11-13", 0.625, 5],- ["gpt-5", 0.625, 5],- ["gpt-5-2025-08-07", 0.625, 5],- ["gpt-5-mini", 0.125, 1],- ["gpt-5-mini-2025-08-07", 0.125, 1],- ["gpt-5-nano", 0.025, 0.2],- ["gpt-5-nano-2025-08-07", 0.025, 0.2],- ["o3", 1, 4],- ["o3-2025-04-16", 1, 4],- ["o4-mini", 0.55, 2.2],- ["o4-mini-2025-04-16", 0.55, 2.2],- ])(- "should price %s Flex processing",- (modelName, inputPerMillion, outputPerMillion) => {- const model = defaultModelPrices.find(- (candidate) => candidate.modelName === modelName,- );- const tier = model?.pricingTiers.find(- (candidate) => candidate.name === "Flex",- );-- expect(tier, modelName).toBeDefined();- expect(tier?.conditions).toEqual([- {- source: "model_parameters",- key: "service_tier",- operator: "in",- values: ["flex"],- },- ]);- expect(tier?.prices.input).toBeCloseTo(inputPerMillion * 1e-6, 15);- expect(tier?.prices.output).toBeCloseTo(outputPerMillion * 1e-6, 15);- },- );-- it.each(["claude-opus-5", "claude-opus-4-8"])(- "should price %s Fast mode using Anthropic's speed parameter",- (modelName) => {- const model = defaultModelPrices.find(- (candidate) => candidate.modelName === modelName,- );- const tier = model?.pricingTiers.find(- (candidate) => candidate.name === "Fast mode",- );-- expect(tier, modelName).toBeDefined();- expect(tier?.conditions).toEqual([- {- source: "model_parameters",- key: "speed",- operator: "in",- values: ["fast"],- },- ]);- expect(tier?.prices.input).toBe(10e-6);- expect(tier?.prices.output).toBe(50e-6);- expect(tier?.prices.input_cache_creation_5m).toBe(12.5e-6);- expect(tier?.prices.input_cache_creation_1h).toBe(20e-6);- expect(tier?.prices.input_cache_read).toBe(1e-6);-- const tiers: PricingTierWithPrices[] = model!.pricingTiers.map(- (candidate) => ({- id: candidate.id,- name: candidate.name,- isDefault: candidate.isDefault,- priority: candidate.priority,- conditions: candidate.conditions,- prices: Object.entries(candidate.prices).map(- ([usageType, price]) => ({- usageType,- price: new Decimal(price),- }),- ),- }),- );- expect(- matchPricingTier(- tiers,- { input: 1000 },- { modelParameters: { speed: "fast" } },- )?.pricingTierName,- ).toBe("Fast mode");- },- );-});--describe("validateRegexPattern", () => {- it("should accept valid regex patterns", () => {- expect(() => validateRegexPattern("^input")).not.toThrow();- expect(() => validateRegexPattern("^(input|output)")).not.toThrow();- expect(() => validateRegexPattern(".*tokens.*")).not.toThrow();- expect(() => validateRegexPattern("^input_[a-z]+$")).not.toThrow();- });-- it("should reject empty patterns", () => {- expect(() => validateRegexPattern("")).toThrow("Pattern cannot be empty");- });-- it("should reject patterns exceeding max length", () => {- const longPattern = "a".repeat(201);- expect(() => validateRegexPattern(longPattern)).toThrow(- "Pattern exceeds maximum length of 200 characters",- );- });-- it("should reject invalid regex syntax", () => {- expect(() => validateRegexPattern("(unclosed")).toThrow(- "Invalid regex syntax",- );- expect(() => validateRegexPattern("[unclosed")).toThrow(- "Invalid regex syntax",- );- });-- it("should reject patterns with catastrophic backtracking", () => {- // Classic catastrophic backtracking pattern- const dangerousPattern = "(a+)+b";- expect(() => validateRegexPattern(dangerousPattern)).toThrow(- "catastrophic backtracking",- );- });-- it("should accept safe complex patterns", () => {- expect(() => validateRegexPattern("^(input|prompt)_tokens$")).not.toThrow();- expect(() =>- validateRegexPattern("^(input|output)_(cached|regular)$"),- ).not.toThrow();- });-});--describe("matchPricingTier", () => {- describe("attribute conditions", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000005") }],- },- {- id: "tier-priority",- name: "Priority",- isDefault: false,- priority: 1,- conditions: [- {- source: "model_parameters",- key: "service_tier",- operator: "in",- values: ["priority"],- },- ],- prices: [{ usageType: "input", price: new Decimal("0.0000125") }],- },- ];-- it("matches exact top-level model parameters", () => {- const result = matchPricingTier(- tiers,- { input: 12 },- {- modelParameters: { service_tier: "priority" },- },- );-- expect(result?.pricingTierId).toBe("tier-priority");- });-- it("matches exact top-level metadata", () => {- const metadataTiers: PricingTierWithPrices[] = [- tiers[0]!,- {- ...tiers[1]!,- conditions: [- {- source: "metadata",- key: "inference_geo",- operator: "in",- values: ["us"],- },- ],- },- ];-- const result = matchPricingTier(- metadataTiers,- { input: 12 },- {- metadata: { inference_geo: "us" },- },- );-- expect(result?.pricingTierId).toBe("tier-priority");- });-- it("falls back when the exact key is absent", () => {- const result = matchPricingTier(- tiers,- { input: 12 },- {- modelParameters: { different_key: "priority" },- },- );-- expect(result?.pricingTierId).toBe("tier-default");- });-- it.each(["fast", "priority"])(- "matches any configured attribute value for %s",- (serviceTier) => {- const result = matchPricingTier(- [- tiers[0]!,- {- ...tiers[1]!,- conditions: [- {- source: "model_parameters",- key: "service_tier",- operator: "in",- values: ["fast", "priority"],- },- ],- },- ],- { input: 12 },- { modelParameters: { service_tier: serviceTier } },- );-- expect(result?.pricingTierId).toBe("tier-priority");- },- );-- it("falls back when an attribute value is outside the configured set", () => {- const result = matchPricingTier(- [- tiers[0]!,- {- ...tiers[1]!,- conditions: [- {- source: "model_parameters",- key: "service_tier",- operator: "in",- values: ["fast", "priority"],- },- ],- },- ],- { input: 12 },- { modelParameters: { service_tier: "standard" } },- );-- expect(result?.pricingTierId).toBe("tier-default");- });- });-- describe("Basic tier matching", () => {- it("should return default tier when no conditions match", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [- { usageType: "input", price: new Decimal("0.000003") },- { usageType: "output", price: new Decimal("0.000015") },- ],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 500000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000001") }],- },- ];-- const usageDetails = {- input: 100000,- output: 2000,- };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result).not.toBeNull();- expect(result?.pricingTierId).toBe("tier-default");- expect(result?.pricingTierName).toBe("Standard");- expect(result?.prices.input.toNumber()).toBe(0.000003);- expect(result?.prices.output.toNumber()).toBe(0.000015);- });-- it("should return matched tier when condition passes", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 200000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- const usageDetails = {- input: 250000,- output: 2000,- };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result).not.toBeNull();- expect(result?.pricingTierId).toBe("tier-high");- expect(result?.pricingTierName).toBe("High Volume");- expect(result?.prices.input.toNumber()).toBe(0.000006);- });-- it("should return null when no tiers exist", () => {- const tiers: PricingTierWithPrices[] = [];- const usageDetails = { input: 1000 };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result).toBeNull();- });-- it("should return null when no default tier exists and no conditions match", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 500000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000001") }],- },- ];-- const usageDetails = { input: 100000 };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result).toBeNull();- });- });-- describe("Pattern matching", () => {- it("should sum values from multiple keys matching pattern", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input", // Matches input, input_cached, input_regular- operator: "gt",- value: 200000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- const usageDetails = {- input_cached: 150000,- input_regular: 60000, // Total: 210K > 200K- output: 2000,- };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result?.pricingTierId).toBe("tier-high");- expect(result?.pricingTierName).toBe("High Volume");- });-- it("should be case-insensitive by default", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^INPUT",- operator: "gt",- value: 100000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- const usageDetails = {- input_tokens: 150000, // Should match "^INPUT" case-insensitively- };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result?.pricingTierId).toBe("tier-high");- });-- it("should respect case-sensitive flag", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^INPUT",- operator: "gt",- value: 100000,- caseSensitive: true, // Case-sensitive matching- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- const usageDetails = {- input_tokens: 150000, // Should NOT match "^INPUT" with case-sensitive- INPUT_TOKENS: 50000, // Should match but below threshold- };-- const result = matchPricingTier(tiers, usageDetails);-- // Should fall back to default since INPUT_TOKENS (50K) < 100K- expect(result?.pricingTierId).toBe("tier-default");- });- });-- describe("Operator evaluation", () => {- const createTiers = (- operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq",- value: number,- ): PricingTierWithPrices[] => [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-conditional",- name: "Conditional",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator,- value,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- it("should correctly evaluate 'gt' operator", () => {- const tiers = createTiers("gt", 100);-- expect(matchPricingTier(tiers, { input: 101 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 100 })?.pricingTierId).toBe(- "tier-default",- );- expect(matchPricingTier(tiers, { input: 99 })?.pricingTierId).toBe(- "tier-default",- );- });-- it("should correctly evaluate 'gte' operator", () => {- const tiers = createTiers("gte", 100);-- expect(matchPricingTier(tiers, { input: 101 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 100 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 99 })?.pricingTierId).toBe(- "tier-default",- );- });-- it("should correctly evaluate 'lt' operator", () => {- const tiers = createTiers("lt", 100);-- expect(matchPricingTier(tiers, { input: 99 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 100 })?.pricingTierId).toBe(- "tier-default",- );- expect(matchPricingTier(tiers, { input: 101 })?.pricingTierId).toBe(- "tier-default",- );- });-- it("should correctly evaluate 'lte' operator", () => {- const tiers = createTiers("lte", 100);-- expect(matchPricingTier(tiers, { input: 99 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 100 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 101 })?.pricingTierId).toBe(- "tier-default",- );- });-- it("should correctly evaluate 'eq' operator", () => {- const tiers = createTiers("eq", 100);-- expect(matchPricingTier(tiers, { input: 100 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 99 })?.pricingTierId).toBe(- "tier-default",- );- expect(matchPricingTier(tiers, { input: 101 })?.pricingTierId).toBe(- "tier-default",- );- });-- it("should correctly evaluate 'neq' operator", () => {- const tiers = createTiers("neq", 100);-- expect(matchPricingTier(tiers, { input: 99 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 101 })?.pricingTierId).toBe(- "tier-conditional",- );- expect(matchPricingTier(tiers, { input: 100 })?.pricingTierId).toBe(- "tier-default",- );- });- });-- describe("Priority-based tier selection", () => {- it("should select tier with lowest priority when multiple tiers match", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-medium",- name: "Medium Volume",- isDefault: false,- priority: 2, // Higher priority number- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 100000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000002") }],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1, // Lower priority number (evaluated first)- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 100000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000001") }],- },- ];-- const usageDetails = { input: 250000 };-- const result = matchPricingTier(tiers, usageDetails);-- // Both tier-medium and tier-high match, but tier-high has priority 1 (evaluated first)- expect(result?.pricingTierId).toBe("tier-high");- expect(result?.pricingTierName).toBe("High Volume");- });- });-- describe("Multiple conditions (AND logic)", () => {- it("should match only when ALL conditions pass", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-complex",- name: "Complex Tier",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 200000,- caseSensitive: false,- },- {- usageDetailPattern: "^output",- operator: "lt",- value: 10000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- // Both conditions match: input > 200K AND output < 10K- const usageDetails1 = {- input: 250000,- output: 5000,- };- expect(matchPricingTier(tiers, usageDetails1)?.pricingTierId).toBe(- "tier-complex",- );-- // First condition matches, second doesn't: input > 200K but output >= 10K- const usageDetails2 = {- input: 250000,- output: 15000,- };- expect(matchPricingTier(tiers, usageDetails2)?.pricingTierId).toBe(- "tier-default",- );-- // Second condition matches, first doesn't: input <= 200K but output < 10K- const usageDetails3 = {- input: 100000,- output: 5000,- };- expect(matchPricingTier(tiers, usageDetails3)?.pricingTierId).toBe(- "tier-default",- );- });- });-- describe("Pattern matching edge cases", () => {- it("should handle missing keys in usage details", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 200000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- // No keys matching "^input" pattern- const usageDetails = {- output: 2000,- };-- const result = matchPricingTier(tiers, usageDetails);-- // Should fall back to default (sum of matching keys is 0)- expect(result?.pricingTierId).toBe("tier-default");- });-- it("should handle pattern matching no keys (sum = 0)", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-special",- name: "Special",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^special",- operator: "eq",- value: 0, // Matches when sum is exactly 0- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000001") }],- },- ];-- const usageDetails = {- input: 1000,- output: 500,- };-- const result = matchPricingTier(tiers, usageDetails);-- // No keys match "^special", so sum = 0, which equals 0- expect(result?.pricingTierId).toBe("tier-special");- });-- it("should handle complex regex patterns", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-cache",- name: "Cache Tier",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "_(cached|cache)$", // Matches keys ending with _cached or _cache- operator: "gt",- value: 50000,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000001") }],- },- ];-- const usageDetails = {- input_cached: 30000,- output_cache: 25000, // Total: 55K > 50K- input_regular: 100000,- };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result?.pricingTierId).toBe("tier-cache");- });- });-- describe("Edge cases and error handling", () => {- it("should handle zero values in usage details", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-high",- name: "High Volume",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator: "eq",- value: 0,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0") }],- },- ];-- const usageDetails = {- input: 0,- output: 100,- };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result?.pricingTierId).toBe("tier-high");- });-- it("should handle empty usage details object", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- ];-- const usageDetails = {};-- const result = matchPricingTier(tiers, usageDetails);-- expect(result?.pricingTierId).toBe("tier-default");- });-- it("should gracefully handle invalid regex at runtime (should not happen due to validation)", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [{ usageType: "input", price: new Decimal("0.000003") }],- },- {- id: "tier-invalid",- name: "Invalid Regex Tier",- isDefault: false,- priority: 1,- conditions: [- {- // This would be caught by validation, but testing runtime safety- usageDetailPattern: "(unclosed",- operator: "gt",- value: 100,- caseSensitive: false,- },- ],- prices: [{ usageType: "input", price: new Decimal("0.000006") }],- },- ];-- const usageDetails = { input: 1000 };-- // Should fall back to default due to regex error- const result = matchPricingTier(tiers, usageDetails);-- expect(result?.pricingTierId).toBe("tier-default");- });- });-- describe("Real-world examples", () => {- it("should match Anthropic Claude tiered pricing", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-standard",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [- { usageType: "input", price: new Decimal("0.000003") },- { usageType: "output", price: new Decimal("0.000015") },- ],- },- {- id: "tier-large-context",- name: "Large Context (>200K)",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^input",- operator: "gt",- value: 200000,- caseSensitive: false,- },- ],- prices: [- { usageType: "input", price: new Decimal("0.000006") },- { usageType: "output", price: new Decimal("0.000015") },- ],- },- ];-- // Below threshold- const resultBelow = matchPricingTier(tiers, {- input: 150000,- output: 2000,- });- expect(resultBelow?.pricingTierName).toBe("Standard");- expect(resultBelow?.prices.input.toNumber()).toBe(0.000003);-- // Above threshold- const resultAbove = matchPricingTier(tiers, {- input: 250000,- output: 2000,- });- expect(resultAbove?.pricingTierName).toBe("Large Context (>200K)");- expect(resultAbove?.prices.input.toNumber()).toBe(0.000006);- });-- it("should match Google Gemini tiered pricing with multiple pattern options", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-standard",- name: "Standard",- isDefault: true,- priority: 0,- conditions: [],- prices: [- { usageType: "input", price: new Decimal("0.00000125") },- { usageType: "output", price: new Decimal("0.000005") },- ],- },- {- id: "tier-high-volume",- name: "High Volume (>200K)",- isDefault: false,- priority: 1,- conditions: [- {- usageDetailPattern: "^(input|prompt)", // Matches input or prompt prefixes- operator: "gt",- value: 200000,- caseSensitive: false,- },- ],- prices: [- { usageType: "input", price: new Decimal("0.0000025") },- { usageType: "output", price: new Decimal("0.00001") },- ],- },- ];-- // Using "input" prefix- const resultInput = matchPricingTier(tiers, {- input_tokens: 250000,- output_tokens: 5000,- });- expect(resultInput?.pricingTierName).toBe("High Volume (>200K)");-- // Using "prompt" prefix- const resultPrompt = matchPricingTier(tiers, {- prompt_tokens: 250000,- completion_tokens: 5000,- });- expect(resultPrompt?.pricingTierName).toBe("High Volume (>200K)");- });- });-- describe("Decimal price handling", () => {- it("should preserve Decimal precision in returned prices", () => {- const tiers: PricingTierWithPrices[] = [- {- id: "tier-default",- name: "Default",- isDefault: true,- priority: 0,- conditions: [],- prices: [- { usageType: "input", price: new Decimal("0.000003123456789") },- ],- },- ];-- const usageDetails = { input: 1000 };-- const result = matchPricingTier(tiers, usageDetails);-- expect(result?.prices.input).toBeInstanceOf(Decimal);- expect(result?.prices.input.toString()).toBe("0.000003123456789");- });- });-});diff --git a/worker/src/constants/default-model-prices.json b/worker/src/constants/default-model-prices.jsonindex 4cbc4aa050..f2c202697d 100644--- a/worker/src/constants/default-model-prices.json+++ b/worker/src/constants/default-model-prices.json@@ -5761,7 +5761,7 @@"modelName": "gpt-5.6-sol","matchPattern": "(?i)^(openai/)?(gpt-5.6-sol)$","createdAt": "2026-07-09T00:00:00.000Z",- "updatedAt": "2026-08-20T00:00:00.000Z",+ "updatedAt": "2026-08-24T00:00:00.000Z","tokenizerConfig": {"tokensPerName": 1,"tokenizerModel": "gpt-4",@@ -5776,16 +5776,16 @@"priority": 0,"conditions": [],"prices": {- "input": 5e-6,- "input_cached_tokens": 0.5e-6,- "input_cache_read": 0.5e-6,- "cache_read_input_tokens": 0.5e-6,- "input_cache_creation": 6.25e-6,- "cache_write_tokens": 6.25e-6,- "output": 30e-6,- "output_reasoning_tokens": 30e-6,- "output_reasoning": 30e-6,- "reasoning_tokens": 30e-6+ "input": 4e-6,+ "input_cached_tokens": 0.4e-6,+ "input_cache_read": 0.4e-6,+ "cache_read_input_tokens": 0.4e-6,+ "input_cache_creation": 5e-6,+ "cache_write_tokens": 5e-6,+ "output": 20e-6,+ "output_reasoning_tokens": 20e-6,+ "output_reasoning": 20e-6,+ "reasoning_tokens": 20e-6}},{@@ -5808,16 +5808,16 @@}],"prices": {- "input": 20e-6,- "input_cached_tokens": 2e-6,- "input_cache_read": 2e-6,- "cache_read_input_tokens": 2e-6,- "input_cache_creation": 25e-6,- "cache_write_tokens": 25e-6,- "output": 90e-6,- "output_reasoning_tokens": 90e-6,- "output_reasoning": 90e-6,- "reasoning_tokens": 90e-6+ "input": 16e-6,+ "input_cached_tokens": 1.6e-6,+ "input_cache_read": 1.6e-6,+ "cache_read_input_tokens": 1.6e-6,+ "input_cache_creation": 20e-6,+ "cache_write_tokens": 20e-6,+ "output": 60e-6,+ "output_reasoning_tokens": 60e-6,+ "output_reasoning": 60e-6,+ "reasoning_tokens": 60e-6}},{@@ -5840,16 +5840,16 @@}],"prices": {- "input": 5e-6,- "input_cached_tokens": 0.5e-6,- "input_cache_read": 0.5e-6,- "cache_read_input_tokens": 0.5e-6,- "input_cache_creation": 6.25e-6,- "cache_write_tokens": 6.25e-6,- "output": 22.5e-6,- "output_reasoning_tokens": 22.5e-6,- "output_reasoning": 22.5e-6,- "reasoning_tokens": 22.5e-6+ "input": 4e-6,+ "input_cached_tokens": 0.4e-6,+ "input_cache_read": 0.4e-6,+ "cache_read_input_tokens": 0.4e-6,+ "input_cache_creation": 5e-6,+ "cache_write_tokens": 5e-6,+ "output": 15e-6,+ "output_reasoning_tokens": 15e-6,+ "output_reasoning": 15e-6,+ "reasoning_tokens": 15e-6}},{@@ -5866,16 +5866,16 @@}],"prices": {- "input": 10e-6,- "input_cached_tokens": 1e-6,- "input_cache_read": 1e-6,- "cache_read_input_tokens": 1e-6,- "input_cache_creation": 12.5e-6,- "cache_write_tokens": 12.5e-6,- "output": 60e-6,- "output_reasoning_tokens": 60e-6,- "output_reasoning": 60e-6,- "reasoning_tokens": 60e-6+ "input": 8e-6,+ "input_cached_tokens": 0.8e-6,+ "input_cache_read": 0.8e-6,+ "cache_read_input_tokens": 0.8e-6,+ "input_cache_creation": 10e-6,+ "cache_write_tokens": 10e-6,+ "output": 40e-6,+ "output_reasoning_tokens": 40e-6,+ "output_reasoning": 40e-6,+ "reasoning_tokens": 40e-6}},{@@ -5892,16 +5892,16 @@}],"prices": {- "input": 2.5e-6,- "input_cached_tokens": 0.25e-6,- "input_cache_read": 0.25e-6,- "cache_read_input_tokens": 0.25e-6,- "input_cache_creation": 3.125e-6,- "cache_write_tokens": 3.125e-6,- "output": 15e-6,- "output_reasoning_tokens": 15e-6,- "output_reasoning": 15e-6,- "reasoning_tokens": 15e-6+ "input": 2e-6,+ "input_cached_tokens": 0.2e-6,+ "input_cache_read": 0.2e-6,+ "cache_read_input_tokens": 0.2e-6,+ "input_cache_creation": 2.5e-6,+ "cache_write_tokens": 2.5e-6,+ "output": 10e-6,+ "output_reasoning_tokens": 10e-6,+ "output_reasoning": 10e-6,+ "reasoning_tokens": 10e-6}},{@@ -5918,16 +5918,16 @@}],"prices": {- "input": 10e-6,- "input_cached_tokens": 1e-6,- "input_cache_read": 1e-6,- "cache_read_input_tokens": 1e-6,- "input_cache_creation": 12.5e-6,- "cache_write_tokens": 12.5e-6,- "output": 45e-6,- "output_reasoning_tokens": 45e-6,- "output_reasoning": 45e-6,- "reasoning_tokens": 45e-6+ "input": 8e-6,+ "input_cached_tokens": 0.8e-6,+ "input_cache_read": 0.8e-6,+ "cache_read_input_tokens": 0.8e-6,+ "input_cache_creation": 10e-6,+ "cache_write_tokens": 10e-6,+ "output": 30e-6,+ "output_reasoning_tokens": 30e-6,+ "output_reasoning": 30e-6,+ "reasoning_tokens": 30e-6}}]