Open History to see the last commit
1/**
2 * Release-date sources for providers whose models API carries no timestamp
3 * (issue #1). Two mechanisms, tried in order:
4 *
5 * 1. A curated per-provider map of rawId → 'YYYY-MM-DD' (public announcement
6 * or first-availability date, UTC). Extend freely — unmapped models simply
7 * keep their poll-time firstSeenAt.
8 * 2. For Gemini, the deprecations page's Release date column, read in
9 * `geminiReleasedAt`, then a `MM-YYYY` suffix embedded in preview ids
10 * (e.g. `gemini-2.5-computer-use-preview-10-2025`) → first of that month.
11 *
12 * Providers that DO report a date (OpenAI/xAI/OpenRouter `created`,
13 * Anthropic `created_at`, FAL `metadata.date`) parse it in their own
14 * listModels; the shared epoch helpers live here.
15 */
16
17/** Epoch seconds for a `YYYY-MM-DD` date at UTC midnight. */
18export function dateToEpoch(date: string): number {
19 return Math.floor(Date.parse(`${date}T00:00:00Z`) / 1000)
20}
21
22/** Epoch seconds from an ISO 8601 timestamp; null when unparseable. */
23export function isoToEpochSeconds(
24 iso: string | undefined | null,
25): number | null {
26 if (!iso) return null
27 const ms = Date.parse(iso)
28 return Number.isNaN(ms) ? null : Math.floor(ms / 1000)
29}
30
31/**
32 * Gemini preview ids often end in `-MM-YYYY` (announcement month). Returns
33 * the first of that month, or null when the id carries no date.
34 */
35export function geminiIdSuffixDate(rawId: string): number | null {
36 const match = /-(\d{2})-(\d{4})$/.exec(rawId)
37 if (!match) return null
38 const [, month, year] = match
39 const m = Number(month)
40 if (m < 1 || m > 12) return null
41 return dateToEpoch(`${year}-${month}-01`)
42}
43
44/**
45 * BytePlus dated ids end in `-YYMMDD` (e.g. `seedance-1-5-pro-251215` →
46 * 2025-12-15) — the release stamp BytePlus itself versions models by.
47 * Returns null for undated ids (`seed-audio-1.0`, `seed-asr`) or an
48 * implausible month/day.
49 */
50export function byteplusIdSuffixDate(rawId: string): number | null {
51 const match = /-(\d{2})(\d{2})(\d{2})$/.exec(rawId)
52 if (!match) return null
53 const [, year, month, day] = match
54 const m = Number(month)
55 const d = Number(day)
56 if (m < 1 || m > 12 || d < 1 || d > 31) return null
57 return dateToEpoch(`20${year}-${month}-${day}`)
58}
59
60/**
61 * First public availability (preview counts), from ai.google.dev changelog
62 * and Google announcement posts. Rolling `-latest` aliases and models with
63 * no confirmable date are deliberately unmapped. Ids carrying a `-MM-YYYY`
64 * suffix (computer-use, deep-research, native-audio previews, …) resolve
65 * via geminiIdSuffixDate and need no entry here.
66 */
67export const GEMINI_RELEASE_DATES: Record<string, string> = {
68 'gemini-2.0-flash': '2024-12-11',
69 'gemini-2.0-flash-001': '2025-02-05',
70 'gemini-2.0-flash-lite': '2025-02-05',
71 'gemini-2.0-flash-lite-001': '2025-02-25',
72 'gemini-2.5-pro': '2025-03-25',
73 'gemini-2.5-flash': '2025-04-17',
74 'gemini-2.5-flash-lite': '2025-07-22',
75 'gemini-2.5-flash-image': '2025-08-26',
76 'gemini-2.5-flash-preview-tts': '2025-05-20',
77 'gemini-2.5-pro-preview-tts': '2025-05-20',
78 'gemini-3-pro-preview': '2025-11-18',
79 'gemini-3-flash-preview': '2025-12-17',
80 'gemini-3-pro-image': '2025-11-20',
81 'gemini-3-pro-image-preview': '2025-11-20',
82 'nano-banana-pro-preview': '2025-11-20',
83 'gemini-3.1-pro-preview': '2026-02-19',
84 'gemini-3.1-pro-preview-customtools': '2026-02-19',
85 'gemini-3.1-flash-lite-preview': '2026-03-03',
86 'gemini-3.1-flash-lite': '2026-05-07',
87 'gemini-3.1-flash-image': '2026-05-28',
88 'gemini-3.1-flash-image-preview': '2026-05-28',
89 'gemini-3.5-flash': '2026-05-19',
90 'gemini-omni-flash-preview': '2026-06-30',
91 'gemini-embedding-001': '2025-07-14',
92 'gemini-embedding-2': '2026-04-22',
93 'gemini-embedding-2-preview': '2026-04-22',
94 'gemma-4-26b-a4b-it': '2026-04-02',
95 'gemma-4-31b-it': '2026-04-02',
96 'lyria-3-pro-preview': '2026-03-25',
97 'veo-3.1-generate-preview': '2025-10-15',
98 'veo-3.1-fast-generate-preview': '2025-10-15',
99 'gemini-robotics-er-1.5-preview': '2025-09-25',
100 'gemini-robotics-er-1.6-preview': '2026-04-14',
101 'imagen-4.0-generate-001': '2025-08-14',
102 'imagen-4.0-ultra-generate-001': '2025-08-14',
103 'imagen-4.0-fast-generate-001': '2025-08-14',
104}
105
106/**
107 * From ElevenLabs' own blog posts (public alpha/launch dates). The v1
108 * multilingual and speech-to-speech models have no official dated posts
109 * and stay unmapped.
110 */
111export const ELEVENLABS_RELEASE_DATES: Record<string, string> = {
112 eleven_monolingual_v1: '2023-01-23',
113 eleven_multilingual_v2: '2023-08-22',
114 eleven_turbo_v2: '2023-11-09',
115 eleven_turbo_v2_5: '2024-07-19',
116 eleven_flash_v2: '2024-12-01',
117 eleven_flash_v2_5: '2024-12-01',
118 eleven_v3: '2025-06-05',
119}
120
121/** Curated lookup + (Gemini) id-suffix fallback. */
122export function curatedReleasedAt(
123 map: Record<string, string>,
124 rawId: string,
125): number | null {
126 const date = map[rawId]
127 if (date) return dateToEpoch(date)
128 return null
129}