diff --git a/scripts/verify-prices.ts b/scripts/verify-prices.ts index af9469e..642b5fc 100644 --- a/scripts/verify-prices.ts +++ b/scripts/verify-prices.ts @@ -338,7 +338,7 @@ const PROBES: Probe[] = [ ["powerful", "openai/gpt-5.4-pro"], ["reasoning", "anthropic/claude-opus-5"], // gpt-5.6-sol cut to $4/$20 2026-08-21 ["coding", "anthropic/claude-opus-5"], - ["fast", "google/gemini-3.5-flash"], + ["fast", "google/gemini-3.6-flash"], // gemini-3.5-flash until its 2026-11-24 retirement ["glm", "zai/glm-5.2"], ["cheap", "deepseek/deepseek-v4-pro"], ] as Array<[string, string]>).map(([mode, worstMember]) => { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 2dfdb4d..2e2119d 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -57,7 +57,8 @@ export const BASE_RPC_URLS = [ // gpt-5.4 ($2.5/$15), gpt-5.4-pro ($30/$180), gpt-5.2 / // gpt-5.3-codex ($1.75/$14) (gpt-5.3 is hidden + available:false), gpt-5.2-pro ($21/$168), gpt-5.4-mini, // gpt-5-mini, gpt-5.4-nano, gpt-4.1{,-mini,-nano}, gpt-4o{,-mini}, -// o1 ($15/$60), o3 ($2/$8), o3-mini, o4-mini +// o3 ($2/$8). o1 ($15/$60), o3-mini and o4-mini are RETIRED (2026-11-24, +// redirected to gpt-5.4-mini — see the note above MODEL_TIERS) // Anthropic (12): claude-fable-5.1 ($10/$50, 1M — listed by 2026-09-08 ABOVE // the default, so it carries a price row), claude-opus-5.5 ($4/$20, 1M, 128k // out — newest Opus, cheaper than Opus 5, thinking always on), @@ -73,7 +74,8 @@ export const BASE_RPC_URLS = [ // long-context tier, unlike 3.1 Pro — priced only, in no routing tier), // gemini-3.1-pro ($2/$12), gemini-3.8-flash and gemini-3.6-flash // ($0.75/$3.75 each — 3.6 was $1.5/$7.5 when first listed), gemini-3.5-flash ($1.5/$9 — REPRICED from the $0.5/$3 this -// file recorded in July), gemini-3-flash-preview ($0.5/$3), +// file recorded in July; RETIRED 2026-11-24, redirected to 3.6 Flash), +// gemini-3-flash-preview ($0.5/$3), // gemini-3.5-flash-lite ($0.3/$2.5, live-probed 2026-08-12), // gemini-3.1-flash-lite ($0.25/$1.5), gemini-2.5-pro, gemini-2.5-flash, // gemini-2.5-flash-lite — all 1M context @@ -142,8 +144,18 @@ export const BASE_RPC_URLS = [ // the rule above that is NOT a death certificate (gpt-oss-120b has been // hidden-alive since July). They stay routed at the tail of free[] until a // realistic-prompt POST probe reads their response `model` field. +// +// 2026-11-24 RETIREMENTS (owner-approved; the gateways redirect each id and +// quote the SUCCESSOR's price — the redirect runs before pricing): +// google/gemini-3.5-flash -> google/gemini-3.6-flash. Google has served 3.6 +// Flash under the 3.5 name since ~2026-10-10 while the catalogue billed +// $1.5/$9 for it; 3.6 is $0.75/$3.75. fast[0] now names the model that +// answers, in the same position. +// openai/o1, openai/o3-mini, openai/o4-mini (and o1-mini, which redirected +// onto o4-mini) -> openai/gpt-5.4-mini. Dead at OpenAI since 2026-10-23 +// and on Azure since 2026-11-19. None was in a tier; see their price rows. export const MODEL_TIERS = { - fast: ["google/gemini-3.5-flash", "google/gemini-2.5-flash", "openai/gpt-5.6-luna", "google/gemini-3.5-flash-lite", "openai/gpt-5-mini", "deepseek/deepseek-chat", "deepseek/deepseek-v4.1-flash", "google/gemini-3-flash-preview"], + fast: ["google/gemini-3.6-flash", "google/gemini-2.5-flash", "openai/gpt-5.6-luna", "google/gemini-3.5-flash-lite", "openai/gpt-5-mini", "deepseek/deepseek-chat", "deepseek/deepseek-v4.1-flash", "google/gemini-3-flash-preview"], balanced: ["openai/gpt-5.6-terra", "anthropic/claude-sonnet-5", "moonshot/kimi-k3.1-pro", "google/gemini-3.1-pro", "xai/grok-4.5", "openai/gpt-5.5"], powerful: ["anthropic/claude-opus-5", "anthropic/claude-opus-4.8", "openai/gpt-5.6-sol", "anthropic/claude-fable-5", "openai/gpt-5.4-pro", "openai/gpt-5.2-pro"], cheap: ["deepseek/deepseek-v4-pro", "qwen/qwen3.7-flash", "minimax/minimax-m3", "google/gemini-2.5-flash", "deepseek/deepseek-chat", "deepseek/deepseek-v4.1-flash", "openai/gpt-5.4-nano"], @@ -427,7 +439,7 @@ export const FREE_CHAT_MODELS: ReadonlySet = new Set([ * anthropic/claude-fable-5 $0.486310 $0.147480 3.30x * openai/gpt-5.6-sol $0.244171 $0.147480 1.66x * anthropic/claude-opus-5 $0.243655 $0.147480 1.65x <- powerful[0] - * google/gemini-3.5-flash $0.073951 $0.030072 2.46x <- fast[0] + * google/gemini-3.5-flash $0.073951 $0.030072 2.46x <- fast[0] (to 2026-11-24) * zai/glm-5 $0.049346 $0.030072 1.64x <- glm[0] * * (Live unpaid 402 quotes, 2026-08-13. Every frontier model was under-reserved, @@ -456,6 +468,13 @@ export const CHAT_PRICE_PER_MTOKEN: Record [undefined, "anthropic/claude-opus-5", 0.279964], [undefined, "openai/gpt-5.6-terra", 0.114736], [undefined, "google/gemini-3.5-flash", 0.086302], + [undefined, "google/gemini-3.6-flash", 0.042845], // fast[0] since 2026-11-24 [undefined, "zai/glm-5", 0.054858], [undefined, "deepseek/deepseek-v4-pro", 0.071808], [undefined, "openai/gpt-6-astra", 0.558928], @@ -84,7 +85,7 @@ const LIVE_CHARGE_100K: Array<[string | undefined, string | undefined, number]> ["balanced", undefined, 0.285340], // gpt-5.5 ["reasoning", undefined, 0.279964], // opus-5 ["coding", undefined, 0.279964], // claude-opus-5 - ["fast", undefined, 0.086302], // gemini-3.5-flash + ["fast", undefined, 0.042845], // gemini-3.6-flash (gemini-3.5-flash, $0.086302, until 2026-11-24) ["glm", undefined, 0.076315], // glm-5.x ["cheap", undefined, 0.071808], // deepseek-v4-pro ]; diff --git a/test/retired-models.test.ts b/test/retired-models.test.ts new file mode 100644 index 0000000..fc983d2 --- /dev/null +++ b/test/retired-models.test.ts @@ -0,0 +1,104 @@ +// Run with: npm test (tsx --test) +// +// Provider retirements the gateways answer with a REDIRECT (owner-approved +// 2026-11-24). A redirect is silent by design: the gateway rewrites the model +// id before it prices or routes, so a stale id here never errors — it quietly +// settles as another model at another price. Two things therefore have to hold +// for every redirected id, and neither surfaces on its own: +// +// 1. No routing tier sends traffic to it. A tier member is a choice this +// server makes for the caller; naming a model that is no longer served is +// choosing one the caller never sees. +// 2. An explicit pin still reserves enough, whichever rail answers it and in +// whichever order the gateways ship the redirect: at least the successor's +// rate (what a redirected call is quoted) AND at least the rate the +// catalogues list for the old id until then. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { estimateChatCost } from "../src/tools/chat.js"; +import { + MODEL_TIERS, + CHAT_PRICE_PER_MTOKEN, + DEFAULT_CHAT_PRICE, + canonicalChatModel, +} from "../src/utils/constants.js"; + +type Rate = { input: number; output: number }; + +// id -> [the gateways' redirect target, the rate GET /v1/models listed for the +// id on 2026-11-24, before any gateway shipped the redirect (null: unlisted)]. +const REDIRECTED: Record = { + "openai/o1": ["openai/gpt-5.4-mini", { input: 15, output: 60 }], + "openai/o1-mini": ["openai/gpt-5.4-mini", null], + "openai/o3-mini": ["openai/gpt-5.4-mini", { input: 1.1, output: 4.4 }], + "openai/o4-mini": ["openai/gpt-5.4-mini", { input: 1.1, output: 4.4 }], + "google/gemini-3.5-flash": ["google/gemini-3.6-flash", { input: 1.5, output: 9 }], +}; + +const bare = (id: string) => id.slice(id.indexOf("/") + 1); + +function rateFor(model: string): Rate { + const id = canonicalChatModel(model); + return Object.hasOwn(CHAT_PRICE_PER_MTOKEN, id) ? CHAT_PRICE_PER_MTOKEN[id] : DEFAULT_CHAT_PRICE; +} + +test("no routing tier names a retired, redirected model", () => { + for (const [mode, ids] of Object.entries(MODEL_TIERS)) { + for (const id of ids as readonly string[]) { + for (const retired of Object.keys(REDIRECTED)) { + assert.notEqual(id, retired, `${mode} routes to ${retired}, which the gateways redirect to ${REDIRECTED[retired][0]}`); + assert.notEqual(id, bare(retired), `${mode} routes to bare ${bare(retired)}`); + } + } + } +}); + +test("fast[0] names the model Google serves, in the position its old name held", () => { + assert.equal(MODEL_TIERS.fast[0], "google/gemini-3.6-flash"); + assert.deepEqual(CHAT_PRICE_PER_MTOKEN["google/gemini-3.6-flash"], { input: 0.75, output: 3.75 }); +}); + +test("every redirect target has its own price row (a tier or a pin lands on it)", () => { + for (const [retired, [target]] of Object.entries(REDIRECTED)) { + assert.ok(Object.hasOwn(CHAT_PRICE_PER_MTOKEN, target), `${retired} -> ${target} has no row`); + } +}); + +test("a pinned retired id reserves at least its successor's rate and its last listed rate", () => { + for (const [retired, [target, listed]] of Object.entries(REDIRECTED)) { + const successor = CHAT_PRICE_PER_MTOKEN[target]; + for (const spelling of [retired, bare(retired)]) { + const rate = rateFor(spelling); + assert.ok( + rate.input >= successor.input && rate.output >= successor.output, + `${spelling} reserves $${rate.input}/$${rate.output}, under the $${successor.input}/$${successor.output} its redirect to ${target} is quoted`, + ); + if (listed) { + assert.ok( + rate.input >= listed.input && rate.output >= listed.output, + `${spelling} reserves $${rate.input}/$${rate.output}, under the $${listed.input}/$${listed.output} still listed until the redirect ships`, + ); + } + } + } +}); + +test("the reserve for a pinned retired id covers the successor's reserve at every prompt size", () => { + for (const [retired, [target]] of Object.entries(REDIRECTED)) { + for (const chars of [1_000, 100_000, 700_000]) { + for (const spelling of [retired, bare(retired)]) { + const pinned = estimateChatCost(1024, undefined, spelling, undefined, chars); + const served = estimateChatCost(1024, undefined, target, undefined, chars); + assert.ok(pinned >= served, `${spelling} at ${chars} chars reserves ${pinned} < ${served} for ${target}`); + } + } + } +}); + +test("o3-mini and o4-mini carry no row: theirs would under-reserve gpt-5.4-mini's output", () => { + // $1.1/$4.4 against gpt-5.4-mini's $0.75/$4.5. The default covers both. + for (const id of ["openai/o3-mini", "openai/o4-mini"]) { + assert.equal(Object.hasOwn(CHAT_PRICE_PER_MTOKEN, id), false, id); + assert.deepEqual(rateFor(id), DEFAULT_CHAT_PRICE, id); + } +});