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