@aeye/models 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aeye-models.md +272 -265
- package/dist/scripts/codegen.d.ts +4 -0
- package/dist/scripts/codegen.d.ts.map +1 -1
- package/dist/scripts/codegen.js +11 -0
- package/dist/scripts/codegen.js.map +1 -1
- package/dist/scripts/scrape.d.ts +2 -1
- package/dist/scripts/scrape.d.ts.map +1 -1
- package/dist/scripts/scrape.js +8 -4
- package/dist/scripts/scrape.js.map +1 -1
- package/dist/scripts/scrapers/aws.d.ts +5 -1
- package/dist/scripts/scrapers/aws.d.ts.map +1 -1
- package/dist/scripts/scrapers/aws.js +211 -57
- package/dist/scripts/scrapers/aws.js.map +1 -1
- package/dist/scripts/scrapers/docs.d.ts +43 -0
- package/dist/scripts/scrapers/docs.d.ts.map +1 -0
- package/dist/scripts/scrapers/docs.js +91 -0
- package/dist/scripts/scrapers/docs.js.map +1 -0
- package/dist/scripts/scrapers/openai.d.ts +4 -1
- package/dist/scripts/scrapers/openai.d.ts.map +1 -1
- package/dist/scripts/scrapers/openai.js +183 -445
- package/dist/scripts/scrapers/openai.js.map +1 -1
- package/dist/scripts/scrapers/openrouter.d.ts +1 -1
- package/dist/scripts/scrapers/openrouter.d.ts.map +1 -1
- package/dist/scripts/scrapers/openrouter.js +20 -79
- package/dist/scripts/scrapers/openrouter.js.map +1 -1
- package/dist/src/models/aws.d.ts.map +1 -1
- package/dist/src/models/aws.js +2180 -1033
- package/dist/src/models/aws.js.map +1 -1
- package/dist/src/models/openai.d.ts.map +1 -1
- package/dist/src/models/openai.js +1925 -1370
- package/dist/src/models/openai.js.map +1 -1
- package/dist/src/models/openrouter.d.ts.map +1 -1
- package/dist/src/models/openrouter.js +15699 -4981
- package/dist/src/models/openrouter.js.map +1 -1
- package/dist/src/strict-support.d.ts +2 -1
- package/dist/src/strict-support.d.ts.map +1 -1
- package/dist/src/strict-support.js +38 -16
- package/dist/src/strict-support.js.map +1 -1
- package/dist/src/transformers/replicate/black-forest-labs-flux-1-1-pro.js +1 -1
- package/dist/src/transformers/replicate/black-forest-labs-flux-1-1-pro.js.map +1 -1
- package/dist/src/transformers/replicate/black-forest-labs-flux-pro.js +1 -1
- package/dist/src/transformers/replicate/black-forest-labs-flux-pro.js.map +1 -1
- package/dist/src/transformers/replicate/openai-gpt-image-1.js +1 -1
- package/dist/src/transformers/replicate/openai-gpt-image-1.js.map +1 -1
- package/package.json +78 -79
- package/scripts/codegen.ts +12 -0
- package/scripts/scrape.ts +13 -5
- package/scripts/scrapers/aws.ts +245 -76
- package/scripts/scrapers/docs.ts +101 -0
- package/scripts/scrapers/openai.ts +185 -552
- package/scripts/scrapers/openrouter.ts +20 -106
- package/src/models/aws.ts +2569 -1422
- package/src/models/openai.ts +2764 -2209
- package/src/models/openrouter.ts +15699 -4981
- package/src/strict-support.ts +134 -111
- package/src/transformers/replicate/black-forest-labs-flux-1-1-pro.ts +1 -1
- package/src/transformers/replicate/black-forest-labs-flux-pro.ts +1 -1
- package/src/transformers/replicate/openai-gpt-image-1.ts +1 -1
- package/dist/scripts/_regen.d.ts +0 -2
- package/dist/scripts/_regen.d.ts.map +0 -1
- package/dist/scripts/_regen.js +0 -13
- package/dist/scripts/_regen.js.map +0 -1
|
@@ -1,488 +1,226 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OpenAI Model Scraper
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Builds model information for every model the API lists from the Markdown
|
|
5
|
+
* versions of OpenAI's docs: each model page (details, pricing, endpoints,
|
|
6
|
+
* features), the pricing page (GPT Image token prices), and the deprecations
|
|
7
|
+
* page (shutdown dates).
|
|
5
8
|
*/
|
|
6
|
-
import * as fs from 'fs/promises';
|
|
7
9
|
import * as path from 'path';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'average': 0.4,
|
|
15
|
-
'low': 0.2,
|
|
16
|
-
'lowest': 0.1,
|
|
17
|
-
};
|
|
18
|
-
const IntelligenceScoreMap = {
|
|
19
|
-
'highest': 1.0,
|
|
20
|
-
'higher': 0.8,
|
|
21
|
-
'high': 0.6,
|
|
22
|
-
'average': 0.4,
|
|
23
|
-
'low': 0.2,
|
|
24
|
-
'lowest': 0.1,
|
|
25
|
-
};
|
|
26
|
-
const ReasoningScoreMap = {
|
|
27
|
-
'highest': 1.0,
|
|
28
|
-
'higher': 0.8,
|
|
29
|
-
'high': 0.6,
|
|
30
|
-
'average': 0.4,
|
|
31
|
-
'low': 0.2,
|
|
32
|
-
'lowest': 0.1,
|
|
33
|
-
};
|
|
34
|
-
const SpeedScoreMap = {
|
|
35
|
-
'fastest': 120,
|
|
36
|
-
'very fast': 100,
|
|
37
|
-
'fast': 80,
|
|
38
|
-
'medium': 60,
|
|
39
|
-
'slow': 40,
|
|
40
|
-
'slowest': 20,
|
|
41
|
-
};
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
import { detectTier } from '@aeye/ai';
|
|
12
|
+
import { writeModelJSON, writeModelTS } from '../codegen';
|
|
13
|
+
import { amount, bullets, fetchMarkdown, isoDate, reasoningEfforts, section, subsections, tableRows } from './docs';
|
|
14
|
+
const DOCS = 'https://developers.openai.com/api/docs';
|
|
15
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
42
16
|
/**
|
|
43
|
-
*
|
|
17
|
+
* A dated snapshot suffix, which shares its base model's page.
|
|
44
18
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
19
|
+
const SNAPSHOT = /-(\d{4}-\d{2}-\d{2}|\d{4})$/;
|
|
20
|
+
/**
|
|
21
|
+
* Models the Decisions API takes. Model pages leave that endpoint out, so
|
|
22
|
+
* this follows the Decisions guide.
|
|
23
|
+
*/
|
|
24
|
+
const DECISION_MODELS = /^gpt-6-luna\b/;
|
|
25
|
+
/**
|
|
26
|
+
* Reasoning efforts of models whose pages don't list them, by base model:
|
|
27
|
+
* the o-series takes low to high, and the first GPT-5 models add minimal.
|
|
28
|
+
*/
|
|
29
|
+
const UNLISTED_EFFORTS = [
|
|
30
|
+
[/^o\d(-mini)?$/, ['low', 'medium', 'high']],
|
|
31
|
+
[/^gpt-5-(mini|nano)$/, ['minimal', 'low', 'medium', 'high']],
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Fetch a docs page as Markdown, or undefined when it doesn't exist.
|
|
35
|
+
*/
|
|
36
|
+
function fetchPage(page) {
|
|
37
|
+
return fetchMarkdown(`${DOCS}/${page}.md`);
|
|
57
38
|
}
|
|
58
39
|
/**
|
|
59
|
-
*
|
|
40
|
+
* Shutdown date of each model the deprecations page lists, as YYYY-MM-DD.
|
|
60
41
|
*/
|
|
61
|
-
async function
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
? modelId.slice(0, -11)
|
|
69
|
-
: modelId;
|
|
70
|
-
let url = `https://platform.openai.com/docs/models/${modelSlug}`;
|
|
71
|
-
if (modelSlug !== modelId) {
|
|
72
|
-
url += '?snapshot=' + modelId;
|
|
73
|
-
}
|
|
74
|
-
const response = await page.goto(url, {
|
|
75
|
-
waitUntil: ['domcontentloaded', 'networkidle0'],
|
|
76
|
-
timeout: 30000,
|
|
77
|
-
});
|
|
78
|
-
if (!response || response.status() === 404) {
|
|
79
|
-
return { modelId, data: null };
|
|
80
|
-
}
|
|
81
|
-
// Wait for main content to load
|
|
82
|
-
try {
|
|
83
|
-
// await page.waitForSelector('.docs-scroll-container', { timeout: 30000 });
|
|
84
|
-
}
|
|
85
|
-
catch (e) { }
|
|
86
|
-
const modelData = {
|
|
87
|
-
id: modelId,
|
|
88
|
-
name: modelId,
|
|
89
|
-
pricing: {},
|
|
90
|
-
capabilities: new Set(),
|
|
91
|
-
};
|
|
92
|
-
const bodyText = await page.$eval('body', el => el.textContent || '');
|
|
93
|
-
const bodyHtml = await page.$eval('body', el => el.innerHTML || '');
|
|
94
|
-
const grab = (regex, fromText = bodyText) => {
|
|
95
|
-
const match = fromText.match(regex);
|
|
96
|
-
return match ? match[1].toLowerCase() : undefined;
|
|
97
|
-
};
|
|
98
|
-
const grabNumber = (regex, fromText = bodyText) => {
|
|
99
|
-
const match = fromText.match(regex);
|
|
100
|
-
return match ? parseFloat(match[1].replace(/,/g, '')) : undefined;
|
|
101
|
-
};
|
|
102
|
-
// ===== HEADER =====
|
|
103
|
-
modelData.intelligence = grab(/Performance\s*(Highest|Higher|High|Average|Low|Lowest)/i);
|
|
104
|
-
modelData.performance = grab(/Intelligence\s*(Highest|Higher|High|Average|Low|Lowest)/i);
|
|
105
|
-
modelData.reasoning = grab(/Reasoning\s*(Highest|Higher|High|Average|Low|Lowest)/i);
|
|
106
|
-
modelData.speed = grab(/Speed\s*(Fastest|Very fast|Fast|Medium|Slow|Slowest)/i);
|
|
107
|
-
modelData.contextWindow = grabNumber(/([0-9,]+)\s+context window/i);
|
|
108
|
-
modelData.maxOutputTokens = grabNumber(/([0-9,]+)\s+max output tokens/i);
|
|
109
|
-
modelData.knowledgeCutoff = grab(/((Jan|January|Feb|February|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|August|Oct|October|Sep|Sept|September|Nov|November|Dec|December)\s+\d{1,2},\s+\d{4})\s+knowledge\s+cutoff/i);
|
|
110
|
-
modelData.reasoningTokenSupport = /Reasoning token support/i.test(bodyText);
|
|
111
|
-
const headerKeys = [
|
|
112
|
-
'intelligence',
|
|
113
|
-
'performance',
|
|
114
|
-
'reasoning',
|
|
115
|
-
'speed',
|
|
116
|
-
'contextWindow',
|
|
117
|
-
'maxOutputTokens',
|
|
118
|
-
'knowledgeCutoff',
|
|
119
|
-
];
|
|
120
|
-
const hasHeaderData = headerKeys.some((key) => modelData[key] !== undefined);
|
|
121
|
-
let hasPricingData = false;
|
|
122
|
-
const pricingStart = bodyText.indexOf('PricingPricing');
|
|
123
|
-
const pricingEnd = bodyText.indexOf('Modalities', pricingStart);
|
|
124
|
-
const pricingSection = bodyText.slice(pricingStart, pricingEnd);
|
|
125
|
-
const pricingSections = pricingSection.split(/(Text tokens|Image tokens|Image generation|Audio tokens|Speech generation|Embeddings|Modalities)/i);
|
|
126
|
-
const modalitiesStart = pricingSections.indexOf('Modalities');
|
|
127
|
-
const pricingSectionsTrimmed = modalitiesStart >= 0
|
|
128
|
-
? pricingSections.slice(0, modalitiesStart)
|
|
129
|
-
: pricingSections;
|
|
130
|
-
const pricingSectionsGrouped = {};
|
|
131
|
-
for (let i = 1; i < pricingSectionsTrimmed.length; i += 2) {
|
|
132
|
-
const key = pricingSectionsTrimmed[i].toLowerCase();
|
|
133
|
-
const value = pricingSectionsTrimmed[i + 1] || '';
|
|
134
|
-
pricingSectionsGrouped[key] = pricingSectionsGrouped[key] || [];
|
|
135
|
-
pricingSectionsGrouped[key].push(value);
|
|
136
|
-
}
|
|
137
|
-
const textTokens = pricingSectionsGrouped['text tokens'] || [];
|
|
138
|
-
if (textTokens.length > 0) {
|
|
139
|
-
for (const section of textTokens) {
|
|
140
|
-
modelData.pricing.textTokens = {};
|
|
141
|
-
modelData.pricing.textTokens.input = grabNumber(/Input\$(\d+(\.\d+)?)/s, section);
|
|
142
|
-
modelData.pricing.textTokens.cached = grabNumber(/Cached input\$(\d+(\.\d+)?)/s, section);
|
|
143
|
-
modelData.pricing.textTokens.output = grabNumber(/Output\$(\d+(\.\d+)?)/s, section);
|
|
144
|
-
hasPricingData ||= modelData.pricing.textTokens.input !== undefined;
|
|
145
|
-
hasPricingData ||= modelData.pricing.textTokens.output !== undefined;
|
|
146
|
-
hasPricingData ||= modelData.pricing.textTokens.cached !== undefined;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
const imageTokens = pricingSectionsGrouped['image tokens'] || [];
|
|
150
|
-
if (imageTokens.length > 0) {
|
|
151
|
-
for (const section of imageTokens) {
|
|
152
|
-
modelData.pricing.imageTokens = {};
|
|
153
|
-
modelData.pricing.imageTokens.input = grabNumber(/Input\$(\d+(\.\d+)?)/s, section);
|
|
154
|
-
if (modelData.pricing.imageTokens.input !== undefined) {
|
|
155
|
-
modelData.capabilities.add('vision');
|
|
156
|
-
hasPricingData = true;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const imageGeneration = pricingSectionsGrouped['image generation'] || [];
|
|
161
|
-
if (imageGeneration.length > 0) {
|
|
162
|
-
for (const section of imageGeneration) {
|
|
163
|
-
const quality = /Quality\s*([^\d]+)/i.exec(section);
|
|
164
|
-
if (!quality)
|
|
165
|
-
continue;
|
|
166
|
-
const size = /(1024|1536|256|512|1792)x(1024|1536|256|512|1792)/;
|
|
167
|
-
const sizeSections = section.split(size).slice(1);
|
|
168
|
-
for (let i = 0; i < sizeSections.length; i += 3) {
|
|
169
|
-
const width = parseInt(sizeSections[i], 10);
|
|
170
|
-
const height = parseInt(sizeSections[i + 1], 10);
|
|
171
|
-
const cost = parseFloat(sizeSections[i + 2].replace(/[\$\,]+/g, ''));
|
|
172
|
-
if (!isFinite(cost) || !isFinite(width) || !isFinite(height))
|
|
173
|
-
continue;
|
|
174
|
-
modelData.pricing.imageTokens = modelData.pricing.imageTokens || {};
|
|
175
|
-
modelData.pricing.imageTokens.output = modelData.pricing.imageTokens.output || [];
|
|
176
|
-
let qualityEntry = modelData.pricing.imageTokens.output.find((q) => q.quality === quality[1].trim().toLowerCase());
|
|
177
|
-
if (!qualityEntry) {
|
|
178
|
-
qualityEntry = { quality: quality[1].trim().toLowerCase(), sizes: [] };
|
|
179
|
-
modelData.pricing.imageTokens.output.push(qualityEntry);
|
|
180
|
-
}
|
|
181
|
-
qualityEntry.sizes.push({ width, height, cost });
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (modelData.pricing.imageTokens?.output?.length) {
|
|
185
|
-
modelData.capabilities.add('image');
|
|
186
|
-
hasPricingData = true;
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
delete modelData.pricing.imageTokens?.output;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const audioTokens = pricingSectionsGrouped['audio tokens'] || [];
|
|
193
|
-
if (audioTokens.length > 0) {
|
|
194
|
-
for (const section of audioTokens) {
|
|
195
|
-
modelData.pricing.audioTokens = {};
|
|
196
|
-
modelData.pricing.audioTokens.input = grabNumber(/Input\$(\d+(\.\d+)?)/s, section);
|
|
197
|
-
modelData.pricing.audioTokens.output = grabNumber(/Output\$(\d+(\.\d+)?)/s, section);
|
|
198
|
-
if (modelData.pricing.audioTokens.input !== undefined) {
|
|
199
|
-
modelData.capabilities.add('hearing');
|
|
200
|
-
hasPricingData = true;
|
|
201
|
-
}
|
|
202
|
-
if (modelData.pricing.audioTokens.output !== undefined) {
|
|
203
|
-
modelData.capabilities.add('audio');
|
|
204
|
-
hasPricingData = true;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
const speechGeneration = pricingSectionsGrouped['speech generation'] || [];
|
|
209
|
-
if (speechGeneration.length > 0) {
|
|
210
|
-
for (const section of speechGeneration) {
|
|
211
|
-
modelData.pricing.audioTokens = modelData.pricing.audioTokens || {};
|
|
212
|
-
modelData.pricing.audioTokens.output = grabNumber(/Cost\$(\d+(\.\d+)?)/s, section);
|
|
213
|
-
if (modelData.pricing.audioTokens.output !== undefined) {
|
|
214
|
-
modelData.capabilities.add('audio');
|
|
215
|
-
hasPricingData = true;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const embeddings = pricingSectionsGrouped['embeddings'] || [];
|
|
220
|
-
if (embeddings.length > 0) {
|
|
221
|
-
for (const section of embeddings) {
|
|
222
|
-
modelData.pricing.embeddings = {};
|
|
223
|
-
modelData.pricing.embeddings.cost = grabNumber(/Cost\$(\d+(\.\d+)?)/s, section);
|
|
224
|
-
if (modelData.pricing.embeddings.cost !== undefined) {
|
|
225
|
-
modelData.capabilities.add('embedding');
|
|
226
|
-
hasPricingData = true;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if (/Pricing.*Use caseTranscription/i.test(bodyText)) {
|
|
231
|
-
modelData.pricing.audioTokens = modelData.pricing.audioTokens || {};
|
|
232
|
-
modelData.pricing.audioTokens.input = grabNumber(/Pricing.*?Use caseTranscriptionCost\$(\d+(\.\d+)?)/s);
|
|
233
|
-
if (modelData.pricing.audioTokens.input !== undefined) {
|
|
234
|
-
modelData.capabilities.add('hearing');
|
|
235
|
-
}
|
|
236
|
-
hasPricingData ||= modelData.pricing.audioTokens.input !== undefined;
|
|
237
|
-
}
|
|
238
|
-
const textSupport = grab(/Text(Output only|Input only|Input and output|Not supported)/i) || '';
|
|
239
|
-
const imageSupport = grab(/Image(Output only|Input only|Input and output|Not supported)/i) || '';
|
|
240
|
-
const audioSupport = grab(/Audio(Output only|Input only|Input and output|Not supported)/i) || '';
|
|
241
|
-
// const videoSupport = grab(/Video(Output only|Input only|Input and output|Not supported)/i) || '';
|
|
242
|
-
if (textSupport.includes('input')) {
|
|
243
|
-
modelData.capabilities.add('chat');
|
|
244
|
-
}
|
|
245
|
-
if (imageSupport.includes('input')) {
|
|
246
|
-
modelData.capabilities.add('vision');
|
|
247
|
-
}
|
|
248
|
-
if (imageSupport.includes('output')) {
|
|
249
|
-
modelData.capabilities.add('image');
|
|
250
|
-
}
|
|
251
|
-
if (audioSupport.includes('input')) {
|
|
252
|
-
modelData.capabilities.add('hearing');
|
|
253
|
-
}
|
|
254
|
-
if (audioSupport.includes('output')) {
|
|
255
|
-
modelData.capabilities.add('audio');
|
|
256
|
-
}
|
|
257
|
-
if (/Streaming\s*Supported/i.test(bodyText)) {
|
|
258
|
-
modelData.capabilities.add('streaming');
|
|
259
|
-
}
|
|
260
|
-
if (/(Function|Tool) calling\s*Supported/i.test(bodyText)) {
|
|
261
|
-
modelData.capabilities.add('tools');
|
|
262
|
-
}
|
|
263
|
-
if (/Structured outputs?\s*Supported/i.test(bodyText)) {
|
|
264
|
-
modelData.capabilities.add('structured');
|
|
265
|
-
modelData.capabilities.add('json');
|
|
266
|
-
}
|
|
267
|
-
if (modelData.reasoningTokenSupport) {
|
|
268
|
-
modelData.capabilities.add('reasoning');
|
|
269
|
-
}
|
|
270
|
-
// Supported parameters
|
|
271
|
-
const chatEndpoint = bodyHtml.includes('<div class="text-sm font-semibold">Chat Completions</div>');
|
|
272
|
-
const imageEndpoint = bodyHtml.includes('<div class="text-sm font-semibold">Image generation</div>');
|
|
273
|
-
const embeddingEndpoint = bodyHtml.includes('<div class="text-sm font-semibold">Embeddings</div>');
|
|
274
|
-
const transcriptionEndpoint = bodyHtml.includes('<div class="text-sm font-semibold">Transcription</div>');
|
|
275
|
-
const speechEndpoint = bodyHtml.includes('<div class="text-sm font-semibold">Speech generation</div>');
|
|
276
|
-
if (chatEndpoint) {
|
|
277
|
-
modelData.supportedParameters = modelData.supportedParameters || new Set();
|
|
278
|
-
modelData.supportedParameters.add('maxTokens');
|
|
279
|
-
modelData.supportedParameters.add('temperature');
|
|
280
|
-
modelData.supportedParameters.add('topP');
|
|
281
|
-
modelData.supportedParameters.add('frequencyPenalty');
|
|
282
|
-
modelData.supportedParameters.add('presencePenalty');
|
|
283
|
-
modelData.supportedParameters.add('logitBias');
|
|
284
|
-
modelData.supportedParameters.add('logProbabilities');
|
|
285
|
-
if (modelData.reasoningTokenSupport) {
|
|
286
|
-
modelData.supportedParameters.add('reason');
|
|
42
|
+
async function fetchRetirements() {
|
|
43
|
+
const retirements = new Map();
|
|
44
|
+
for (const [date, models] of tableRows(await fetchPage('deprecations') ?? '')) {
|
|
45
|
+
const retiresAt = isoDate(date);
|
|
46
|
+
if (retiresAt) {
|
|
47
|
+
for (const [, id] of models.matchAll(/`([^`/]+)`/g)) {
|
|
48
|
+
retirements.set(id, retiresAt);
|
|
287
49
|
}
|
|
288
|
-
if (modelData.capabilities.has('tools')) {
|
|
289
|
-
modelData.supportedParameters.add('tools');
|
|
290
|
-
modelData.supportedParameters.add('toolChoice');
|
|
291
|
-
}
|
|
292
|
-
if (modelData.capabilities.has('structured')) {
|
|
293
|
-
modelData.supportedParameters.add('responseFormat');
|
|
294
|
-
modelData.supportedParameters.add('structuredOutput');
|
|
295
|
-
}
|
|
296
|
-
if (modelData.capabilities.has('json')) {
|
|
297
|
-
modelData.supportedParameters.add('responseFormat');
|
|
298
|
-
}
|
|
299
|
-
if (!modelId.includes('o3') && !modelId.includes('o4')) {
|
|
300
|
-
modelData.supportedParameters.add('stop');
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (imageEndpoint) {
|
|
304
|
-
modelData.supportedParameters = modelData.supportedParameters || new Set();
|
|
305
|
-
if (!modelId.startsWith('dall-e-3')) {
|
|
306
|
-
modelData.supportedParameters.add('imageStyle');
|
|
307
|
-
modelData.supportedParameters.add('imageMultiple');
|
|
308
|
-
}
|
|
309
|
-
if (modelId.startsWith('gpt-image-1')) {
|
|
310
|
-
modelData.supportedParameters.add('imageBackground');
|
|
311
|
-
modelData.supportedParameters.add('imageStream');
|
|
312
|
-
modelData.supportedParameters.add('imageFormat');
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
if (embeddingEndpoint) {
|
|
316
|
-
modelData.supportedParameters = modelData.supportedParameters || new Set();
|
|
317
|
-
if (modelId.startsWith('text-embedding-3')) {
|
|
318
|
-
modelData.supportedParameters.add('embeddingDimensions');
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
if (transcriptionEndpoint) {
|
|
322
|
-
modelData.supportedParameters = modelData.supportedParameters || new Set();
|
|
323
|
-
if (!modelId.startsWith('gpt-4o-transcribe-diarize')) {
|
|
324
|
-
modelData.supportedParameters.add('transcribePrompt');
|
|
325
|
-
}
|
|
326
|
-
if (!modelId.startsWith('whisper-1')) {
|
|
327
|
-
modelData.supportedParameters.add('transcribeStream');
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (speechEndpoint) {
|
|
331
|
-
modelData.supportedParameters = modelData.supportedParameters || new Set();
|
|
332
|
-
if (!modelId.startsWith('tts-1')) {
|
|
333
|
-
modelData.supportedParameters.add('speechInstructions');
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const hasCapabilitiesData = modelData.capabilities.size > 0;
|
|
337
|
-
const populatedOverall = hasHeaderData || hasPricingData || hasCapabilitiesData;
|
|
338
|
-
if (!modelData.supportedParameters || modelData.supportedParameters.size === 0) {
|
|
339
|
-
await fs.writeFile(`./data/pages/openai-${modelId.replace(/[^a-z]/gi, '')}.html`, bodyHtml);
|
|
340
50
|
}
|
|
341
|
-
if (!populatedOverall) {
|
|
342
|
-
console.log(`⚠ No model data found on page ${modelId}`);
|
|
343
|
-
await fs.writeFile(`./data/pages/openai-${modelId.replace(/[^a-z]/gi, '')}.txt`, bodyText);
|
|
344
|
-
return { modelId, data: null };
|
|
345
|
-
}
|
|
346
|
-
return {
|
|
347
|
-
modelId,
|
|
348
|
-
data: modelData,
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
catch (error) {
|
|
352
|
-
console.log(` ✗ Error scraping ${modelId}:`, error instanceof Error ? error.message : error);
|
|
353
|
-
return { modelId, data: null };
|
|
354
51
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
52
|
+
return retirements;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* GPT Image token prices from the pricing page's standard image table,
|
|
56
|
+
* since image model pages carry none.
|
|
57
|
+
*/
|
|
58
|
+
async function fetchImagePricing() {
|
|
59
|
+
const markdown = await fetchPage('pricing') ?? '';
|
|
60
|
+
const start = markdown.indexOf('Image generation models');
|
|
61
|
+
const table = markdown.slice(start).split('### Grouped Pricing Table data')[1] ?? '';
|
|
62
|
+
const pricing = new Map();
|
|
63
|
+
for (const [model, modality, input, output, cached] of tableRows(table.split('\n\n\n')[0])) {
|
|
64
|
+
const entry = pricing.get(model) ?? {};
|
|
65
|
+
if (modality === 'Image') {
|
|
66
|
+
entry.image = { input: amount(input), tokens: amount(output) };
|
|
67
|
+
}
|
|
68
|
+
else if (modality === 'Text') {
|
|
69
|
+
entry.text = { input: amount(input), output: amount(output), cached: amount(cached) };
|
|
70
|
+
}
|
|
71
|
+
pricing.set(model, entry);
|
|
360
72
|
}
|
|
73
|
+
return pricing;
|
|
361
74
|
}
|
|
362
75
|
/**
|
|
363
|
-
*
|
|
76
|
+
* Prices from a model page's Pricing section.
|
|
364
77
|
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
78
|
+
function parsePricing(markdown) {
|
|
79
|
+
const pricing = {};
|
|
80
|
+
for (const [name, body] of subsections(section(markdown, 'Pricing'))) {
|
|
81
|
+
const price = (metric) => amount(tableRows(body).find(([m]) => m === metric)?.[1] ?? '');
|
|
82
|
+
switch (name) {
|
|
83
|
+
case 'Text tokens':
|
|
84
|
+
pricing.text = { input: price('Input'), output: price('Output'), cached: price('Cached input'), cacheWrite: price('Cache writes') };
|
|
85
|
+
break;
|
|
86
|
+
case 'Audio tokens':
|
|
87
|
+
pricing.audio = { input: price('Input'), output: price('Output') };
|
|
88
|
+
break;
|
|
89
|
+
case 'Image tokens':
|
|
90
|
+
pricing.image = { input: price('Input'), tokens: price('Output') };
|
|
91
|
+
break;
|
|
92
|
+
case 'Embeddings':
|
|
93
|
+
pricing.embeddings = { cost: price('Cost') };
|
|
94
|
+
break;
|
|
95
|
+
case 'Transcription audio duration': {
|
|
96
|
+
const perMinute = price('Price');
|
|
97
|
+
pricing.audio = { perSecond: perMinute && perMinute / 60 };
|
|
98
|
+
break;
|
|
380
99
|
}
|
|
381
|
-
console.log(` ✓ Scraped ${batchResults.filter((r) => r.data).length}/${batch.length} models`);
|
|
382
100
|
}
|
|
383
|
-
console.log(`✓ Scraped ${results.length}/${modelIds.length} models\n`);
|
|
384
|
-
}
|
|
385
|
-
finally {
|
|
386
|
-
await browser.close();
|
|
387
101
|
}
|
|
388
|
-
return
|
|
102
|
+
return pricing;
|
|
389
103
|
}
|
|
390
104
|
/**
|
|
391
|
-
* Convert
|
|
105
|
+
* Convert one model page into ModelInfo.
|
|
392
106
|
*/
|
|
393
|
-
function
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
const
|
|
397
|
-
const
|
|
398
|
-
const
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
107
|
+
function parseModel(id, markdown, retirements, extraPricing) {
|
|
108
|
+
const details = bullets(section(markdown, 'Model details'));
|
|
109
|
+
const detail = (pattern) => details.map(d => pattern.exec(d)?.[1]).find(Boolean);
|
|
110
|
+
const list = (pattern) => detail(pattern)?.split(',').map(s => s.trim()) ?? [];
|
|
111
|
+
const inputs = list(/^Input modalities: (.+)$/);
|
|
112
|
+
const outputs = list(/^Output modalities: (.+)$/);
|
|
113
|
+
const features = new Set(bullets(section(markdown, 'Supported features')));
|
|
114
|
+
const endpoints = new Set(tableRows(section(markdown, 'Endpoints')).flatMap(([name, , support]) => support === 'Supported' ? [name] : []));
|
|
115
|
+
const reasons = details.includes('Reasoning token support');
|
|
116
|
+
const efforts = /Reasoning\.effort supports: ([^.]+)\./.exec(markdown)?.[1];
|
|
117
|
+
// Deprecations list snapshots, so an alias retires with its default snapshot
|
|
118
|
+
const snapshot = detail(/^Default snapshot: `(.+)`$/);
|
|
119
|
+
const retiresAt = retirements.get(id) ?? retirements.get(id.replace(SNAPSHOT, '')) ?? (snapshot && retirements.get(snapshot));
|
|
120
|
+
const chat = (endpoints.has('Chat Completions') || endpoints.has('Responses')) && outputs.includes('text');
|
|
121
|
+
const capabilities = new Set();
|
|
122
|
+
const parameters = new Set();
|
|
123
|
+
const allow = (when, ...params) => {
|
|
124
|
+
if (when) {
|
|
125
|
+
params.forEach(p => parameters.add(p));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const add = (when, capability, ...params) => {
|
|
129
|
+
if (when) {
|
|
130
|
+
capabilities.add(capability);
|
|
131
|
+
}
|
|
132
|
+
allow(when, ...params);
|
|
133
|
+
};
|
|
134
|
+
add(chat, 'chat', 'maxTokens', 'serviceTier');
|
|
135
|
+
add(chat && features.has('streaming'), 'streaming');
|
|
136
|
+
add(chat && features.has('function_calling'), 'tools', 'tools', 'toolChoice');
|
|
137
|
+
add(chat && features.has('structured_outputs'), 'structured', 'responseFormat', 'structuredOutput');
|
|
138
|
+
add(chat && features.has('structured_outputs'), 'json');
|
|
139
|
+
add(chat && inputs.includes('image'), 'vision');
|
|
140
|
+
add(chat && inputs.includes('audio'), 'hearing');
|
|
141
|
+
add(chat && features.has('file_uploads'), 'files');
|
|
142
|
+
add(chat && outputs.includes('audio'), 'audio');
|
|
143
|
+
add(chat && reasons, 'reasoning', 'reason', 'verbosity');
|
|
144
|
+
// Sampling controls are rejected by reasoning models
|
|
145
|
+
allow(chat && !reasons, 'temperature', 'topP', 'frequencyPenalty', 'presencePenalty', 'stop', 'seed', 'logitBias', 'logProbabilities');
|
|
146
|
+
add(endpoints.has('Image generation'), 'image', 'imageBackground', 'imageMultiple', 'imageFormat', 'imageStream');
|
|
147
|
+
add(endpoints.has('Image edit'), 'image');
|
|
148
|
+
add(endpoints.has('Speech generation'), 'audio', 'speechInstructions');
|
|
149
|
+
add(endpoints.has('Transcription'), 'hearing', 'transcribeStream', 'transcribePrompt');
|
|
150
|
+
add(endpoints.has('Embeddings'), 'embedding', 'embeddingDimensions');
|
|
151
|
+
add(DECISION_MODELS.test(id), 'decision');
|
|
405
152
|
return {
|
|
406
153
|
provider: 'openai',
|
|
407
|
-
id
|
|
408
|
-
name:
|
|
409
|
-
capabilities
|
|
410
|
-
supportedParameters:
|
|
411
|
-
tier,
|
|
412
|
-
contextWindow:
|
|
413
|
-
maxOutputTokens:
|
|
414
|
-
pricing: {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
output: data.pricing.textTokens?.output,
|
|
418
|
-
cached: data.pricing.textTokens?.cached,
|
|
419
|
-
} : undefined,
|
|
420
|
-
audio: data.pricing.audioTokens ? {
|
|
421
|
-
input: data.pricing.audioTokens?.input,
|
|
422
|
-
output: data.pricing.audioTokens?.output,
|
|
423
|
-
} : undefined,
|
|
424
|
-
image: data.pricing.imageTokens ? {
|
|
425
|
-
input: data.pricing.imageTokens?.input,
|
|
426
|
-
output: data.pricing.imageTokens?.output,
|
|
427
|
-
} : undefined,
|
|
428
|
-
embeddings: data.pricing.embeddings ? {
|
|
429
|
-
cost: data.pricing.embeddings?.cost,
|
|
430
|
-
} : undefined,
|
|
431
|
-
},
|
|
154
|
+
id,
|
|
155
|
+
name: /^# (.+)$/m.exec(markdown)?.[1].trim() ?? id,
|
|
156
|
+
capabilities,
|
|
157
|
+
supportedParameters: parameters,
|
|
158
|
+
tier: detectTier(id),
|
|
159
|
+
contextWindow: amount(detail(/^([\d,]+) context window$/) ?? '') ?? 0,
|
|
160
|
+
maxOutputTokens: amount(detail(/^([\d,]+) max output tokens$/) ?? ''),
|
|
161
|
+
pricing: { ...parsePricing(markdown), ...extraPricing },
|
|
162
|
+
reasoningEfforts: efforts ? reasoningEfforts(efforts) : reasons ? UNLISTED_EFFORTS.find(([base]) => base.test(id.replace(SNAPSHOT, '')))?.[1] : undefined,
|
|
163
|
+
retiresAt,
|
|
432
164
|
metadata: {
|
|
433
|
-
knowledgeCutoff:
|
|
434
|
-
|
|
435
|
-
performance: data.performance,
|
|
436
|
-
reasoning: data.reasoning,
|
|
437
|
-
speed: data.speed,
|
|
165
|
+
knowledgeCutoff: detail(/^(.+) knowledge cutoff$/),
|
|
166
|
+
responsesOnly: endpoints.has('Responses') && !endpoints.has('Chat Completions'),
|
|
438
167
|
},
|
|
439
168
|
};
|
|
440
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Model ids the API lists for the configured key.
|
|
172
|
+
*/
|
|
173
|
+
async function fetchModelIds() {
|
|
174
|
+
const response = await fetch('https://api.openai.com/v1/models', {
|
|
175
|
+
headers: { Authorization: `Bearer ${process.env.OPENAI_API_KEY}` },
|
|
176
|
+
});
|
|
177
|
+
const data = JSON.parse(await response.text());
|
|
178
|
+
if (!data.data) {
|
|
179
|
+
throw new Error('Invalid response from OpenAI API');
|
|
180
|
+
}
|
|
181
|
+
return data.data.map(model => model.id).sort();
|
|
182
|
+
}
|
|
441
183
|
/**
|
|
442
184
|
* Main scraper function
|
|
443
185
|
*/
|
|
444
186
|
export async function scrapeOpenAI(outputDir, options = {}) {
|
|
445
|
-
const { concurrency =
|
|
187
|
+
const { concurrency = 8 } = options;
|
|
446
188
|
console.log('\n=== OpenAI Scraper ===\n');
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
//
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
await writeModelTS(
|
|
474
|
-
console.log(
|
|
475
|
-
console.log('\n✓ OpenAI scraping complete\n');
|
|
189
|
+
const [ids, retirements, imagePricing] = await Promise.all([fetchModelIds(), fetchRetirements(), fetchImagePricing()]);
|
|
190
|
+
console.log(`✓ ${ids.length} models listed, ${retirements.size} with shutdown dates`);
|
|
191
|
+
// A snapshot without its own page shares its base model's page
|
|
192
|
+
const pages = new Map();
|
|
193
|
+
const page = (slug) => {
|
|
194
|
+
const markdown = pages.get(slug) ?? fetchPage(`models/${slug}`);
|
|
195
|
+
pages.set(slug, markdown);
|
|
196
|
+
return markdown;
|
|
197
|
+
};
|
|
198
|
+
const models = [];
|
|
199
|
+
const skipped = [];
|
|
200
|
+
for (let i = 0; i < ids.length; i += concurrency) {
|
|
201
|
+
await Promise.all(ids.slice(i, i + concurrency).map(async (id) => {
|
|
202
|
+
const base = id.replace(SNAPSHOT, '');
|
|
203
|
+
const markdown = await page(id) ?? await page(base);
|
|
204
|
+
if (markdown) {
|
|
205
|
+
models.push(parseModel(id, markdown, retirements, imagePricing.get(id) ?? imagePricing.get(base)));
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
skipped.push(id);
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
models.sort((a, b) => a.id.localeCompare(b.id));
|
|
213
|
+
console.log(`✓ Parsed ${models.length} models${skipped.length ? `, no docs page for: ${skipped.join(', ')}` : ''}`);
|
|
214
|
+
await writeModelJSON(models, path.join(outputDir, 'openai-modelinfo.json'));
|
|
215
|
+
await writeModelTS(models, 'openaiModels', path.join(__dirname, '../../src/models/openai.ts'));
|
|
216
|
+
console.log('✓ Generated TypeScript file: src/models/openai.ts\n');
|
|
476
217
|
}
|
|
477
218
|
// CLI execution
|
|
478
219
|
if (process.argv[1].endsWith('openai.ts')) {
|
|
479
220
|
const args = process.argv.slice(2);
|
|
480
221
|
const outputDir = args.find((arg) => !arg.startsWith('--')) || path.join(__dirname, '../../data');
|
|
481
222
|
const concurrencyArg = args.find((arg) => arg.startsWith('--concurrency='));
|
|
482
|
-
|
|
483
|
-
? parseInt(concurrencyArg.split('=')[1], 10)
|
|
484
|
-
: 5;
|
|
485
|
-
scrapeOpenAI(outputDir, { concurrency }).catch((error) => {
|
|
223
|
+
scrapeOpenAI(outputDir, { concurrency: concurrencyArg ? parseInt(concurrencyArg.split('=')[1], 10) : undefined }).catch((error) => {
|
|
486
224
|
console.error('✗ OpenAI scraping failed:', error);
|
|
487
225
|
process.exit(1);
|
|
488
226
|
});
|