aimodels 0.1.0 → 0.1.2

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/dist/index.js CHANGED
@@ -20,91 +20,489 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ creators: () => creators_default,
23
24
  models: () => models
24
25
  });
25
26
  module.exports = __toCommonJS(index_exports);
26
27
 
27
- // src/data/models.json
28
- var models_default = [
29
- {
30
- id: "gpt-4",
31
- name: "GPT-4",
32
- provider: "openai",
33
- contextWindow: 8192,
34
- capabilities: ["chat", "completion"],
35
- pricing: {
36
- input: 0.03,
37
- output: 0.06
38
- },
39
- released: "2023-03-14",
40
- parameters: 11e11
41
- },
42
- {
43
- id: "gpt-3.5-turbo",
44
- name: "GPT-3.5 Turbo",
45
- provider: "openai",
46
- contextWindow: 4096,
47
- capabilities: ["chat", "completion"],
48
- pricing: {
49
- input: 15e-4,
50
- output: 2e-3
51
- },
52
- released: "2022-11-30"
53
- },
54
- {
55
- id: "claude-2.1",
56
- name: "Claude 2.1",
57
- provider: "anthropic",
58
- contextWindow: 2e5,
59
- capabilities: ["chat", "completion"],
60
- pricing: {
61
- input: 8e-3,
62
- output: 0.024
63
- },
64
- released: "2023-11-21"
65
- },
66
- {
67
- id: "llama-2-70b",
68
- name: "Llama 2 70B",
69
- provider: "meta",
70
- contextWindow: 4096,
71
- capabilities: ["chat", "completion"],
72
- pricing: {
73
- input: 0,
74
- output: 0
75
- },
76
- released: "2023-07-18",
77
- license: "Llama 2 Community License",
78
- parameters: 7e10
28
+ // src/data/models/openai.json
29
+ var openai_default = {
30
+ models: [
31
+ {
32
+ id: "whisper-1",
33
+ name: "Whisper-1",
34
+ license: "proprietary",
35
+ providers: ["openai"],
36
+ can: ["sound-in", "text-out"],
37
+ context: {
38
+ total: null,
39
+ maxOutput: null
40
+ }
41
+ },
42
+ {
43
+ id: "tts-1",
44
+ name: "TTS-1",
45
+ license: "proprietary",
46
+ providers: ["openai"],
47
+ can: ["text-in", "sound-out"],
48
+ context: {
49
+ total: null,
50
+ maxOutput: null
51
+ }
52
+ },
53
+ {
54
+ id: "tts-1-hd",
55
+ name: "TTS-1 HD",
56
+ license: "proprietary",
57
+ providers: ["openai"],
58
+ can: ["text-in", "sound-out"],
59
+ context: {
60
+ total: null,
61
+ maxOutput: null
62
+ }
63
+ },
64
+ {
65
+ id: "gpt-4o",
66
+ name: "GPT-4O",
67
+ license: "proprietary",
68
+ providers: ["openai"],
69
+ can: ["chat", "img-in", "json-out", "function-out"],
70
+ context: {
71
+ total: 128e3,
72
+ maxOutput: 16384
73
+ }
74
+ },
75
+ {
76
+ id: "gpt-4o-mini",
77
+ name: "GPT-4O Mini",
78
+ license: "proprietary",
79
+ providers: ["openai"],
80
+ can: ["chat", "img-in", "json-out", "function-out"],
81
+ context: {
82
+ total: 128e3,
83
+ maxOutput: 16384
84
+ }
85
+ },
86
+ {
87
+ id: "o1",
88
+ name: "OpenAI O1",
89
+ license: "proprietary",
90
+ providers: ["openai"],
91
+ can: ["chat", "img-in", "json-out", "function-out"],
92
+ context: {
93
+ total: 2e5,
94
+ maxOutput: 1e5
95
+ }
96
+ },
97
+ {
98
+ id: "o1-mini",
99
+ name: "OpenAI O1 Mini",
100
+ license: "proprietary",
101
+ providers: ["openai"],
102
+ can: ["chat", "json-out", "function-out"],
103
+ context: {
104
+ total: 128e3,
105
+ maxOutput: 65536
106
+ }
107
+ },
108
+ {
109
+ id: "o3-mini",
110
+ name: "OpenAI O3 Mini",
111
+ license: "proprietary",
112
+ providers: ["openai"],
113
+ can: ["chat", "json-out", "function-out"],
114
+ context: {
115
+ total: 2e5,
116
+ maxOutput: 1e5
117
+ }
118
+ },
119
+ {
120
+ id: "gpt-4o-audio-preview",
121
+ name: "GPT-4O Audio",
122
+ license: "proprietary",
123
+ providers: ["openai"],
124
+ can: ["chat", "sound-in", "json-out", "function-out"],
125
+ context: {
126
+ total: 128e3,
127
+ maxOutput: 16384
128
+ }
129
+ },
130
+ {
131
+ id: "gpt-4o-realtime-preview",
132
+ name: "GPT-4O Realtime",
133
+ license: "proprietary",
134
+ providers: ["openai"],
135
+ can: ["chat", "sound-in", "json-out", "function-out"],
136
+ context: {
137
+ total: 128e3,
138
+ maxOutput: 4096
139
+ }
140
+ },
141
+ {
142
+ id: "dall-e-3",
143
+ name: "DALL-E 3",
144
+ license: "proprietary",
145
+ providers: ["openai"],
146
+ can: ["img-out"],
147
+ context: {
148
+ maxOutput: 1,
149
+ sizes: [
150
+ "1024x1024",
151
+ "1024x1792",
152
+ "1792x1024"
153
+ ],
154
+ qualities: [
155
+ "standard",
156
+ "hd"
157
+ ]
158
+ }
159
+ }
160
+ ]
161
+ };
162
+
163
+ // src/data/models/anthropic.json
164
+ var anthropic_default = {
165
+ models: [
166
+ {
167
+ id: "claude-3-opus",
168
+ name: "Claude 3 Opus",
169
+ license: "proprietary",
170
+ providers: ["anthropic"],
171
+ can: ["chat", "img-in", "json-out", "function-out"],
172
+ context: {
173
+ total: 2e5,
174
+ maxOutput: 4096
175
+ }
176
+ },
177
+ {
178
+ id: "claude-3-sonnet",
179
+ name: "Claude 3 Sonnet",
180
+ license: "proprietary",
181
+ providers: ["anthropic"],
182
+ can: ["chat", "img-in", "json-out", "function-out"],
183
+ context: {
184
+ total: 2e5,
185
+ maxOutput: 4096
186
+ }
187
+ },
188
+ {
189
+ id: "claude-3-haiku",
190
+ name: "Claude 3 Haiku",
191
+ license: "proprietary",
192
+ providers: ["anthropic"],
193
+ can: ["chat", "img-in", "json-out", "function-out"],
194
+ context: {
195
+ total: 2e5,
196
+ maxOutput: 4096
197
+ }
198
+ }
199
+ ]
200
+ };
201
+
202
+ // src/data/models/meta.json
203
+ var meta_default = {
204
+ models: [
205
+ {
206
+ id: "llama2-70b-4096",
207
+ name: "Llama 2 70B",
208
+ license: "llama-2-community",
209
+ providers: ["groq", "ollama"],
210
+ can: ["chat", "json-out", "function-out"],
211
+ context: {
212
+ total: 4096,
213
+ maxOutput: 4096
214
+ }
215
+ }
216
+ ]
217
+ };
218
+
219
+ // src/data/models/mistral.json
220
+ var mistral_default = {
221
+ models: [
222
+ {
223
+ id: "mixtral-8x7b-32768",
224
+ name: "Mixtral 8x7B",
225
+ license: "apache-2.0",
226
+ providers: ["groq"],
227
+ can: ["chat", "json-out", "function-out"],
228
+ context: {
229
+ total: 32768,
230
+ maxOutput: 4096
231
+ }
232
+ }
233
+ ]
234
+ };
235
+
236
+ // src/builders/models.ts
237
+ function buildAllModels() {
238
+ return [
239
+ ...openai_default.models,
240
+ ...anthropic_default.models,
241
+ ...meta_default.models,
242
+ ...mistral_default.models
243
+ ];
244
+ }
245
+
246
+ // src/data/providers/openai.json
247
+ var openai_default2 = {
248
+ id: "openai",
249
+ name: "OpenAI",
250
+ websiteUrl: "https://openai.com/",
251
+ apiUrl: "https://api.openai.com/v1",
252
+ defaultModel: "gpt-4o",
253
+ models: {
254
+ "gpt-4o": {
255
+ type: "token",
256
+ input: 20,
257
+ output: 80
258
+ },
259
+ "gpt-3.5-turbo": {
260
+ type: "token",
261
+ input: 5,
262
+ output: 20
263
+ },
264
+ "gpt-4o-vision": {
265
+ type: "token",
266
+ input: 15,
267
+ input_cached: 7.5,
268
+ output: 60
269
+ },
270
+ "o1-mini": {
271
+ type: "token",
272
+ input: 3,
273
+ input_cached: 1.5,
274
+ output: 15
275
+ },
276
+ "o3-mini": {
277
+ type: "token",
278
+ input: 3,
279
+ input_cached: 1.5,
280
+ output: 15
281
+ },
282
+ "gpt-4o-audio-preview": {
283
+ type: "token",
284
+ input: 20,
285
+ output: 80
286
+ },
287
+ "gpt-4o-vision-preview": {
288
+ type: "token",
289
+ input: 20,
290
+ output: 80
291
+ },
292
+ "whisper-1": {
293
+ type: "minute",
294
+ price: 6e-3
295
+ },
296
+ "tts-1": {
297
+ type: "character",
298
+ price: 15e-6
299
+ },
300
+ "tts-1-hd": {
301
+ type: "character",
302
+ price: 3e-5
303
+ },
304
+ "dall-e-2": {
305
+ type: "image",
306
+ price: 0.016,
307
+ size: "256x256",
308
+ unit: "per_image"
309
+ },
310
+ "dall-e-2-512": {
311
+ type: "image",
312
+ price: 0.018,
313
+ size: "512x512",
314
+ unit: "per_image"
315
+ },
316
+ "dall-e-2-1024": {
317
+ type: "image",
318
+ price: 0.02,
319
+ size: "1024x1024",
320
+ unit: "per_image"
321
+ },
322
+ "dall-e-3": {
323
+ type: "image",
324
+ price: 0.04,
325
+ size: "1024x1024",
326
+ unit: "per_image"
327
+ },
328
+ "dall-e-3-hd": {
329
+ type: "image",
330
+ price: 0.08,
331
+ size: "1024x1024",
332
+ unit: "per_image"
333
+ }
79
334
  }
80
- ];
335
+ };
336
+
337
+ // src/data/providers/anthropic.json
338
+ var anthropic_default2 = {
339
+ id: "anthropic",
340
+ name: "Anthropic",
341
+ websiteUrl: "https://www.anthropic.com/",
342
+ apiUrl: "https://api.anthropic.com/v1",
343
+ defaultModel: "claude-3-sonnet",
344
+ models: {
345
+ "claude-3-opus": {
346
+ type: "token",
347
+ input: 15,
348
+ output: 75
349
+ },
350
+ "claude-3-sonnet": {
351
+ type: "token",
352
+ input: 3,
353
+ output: 15
354
+ },
355
+ "claude-3-haiku": {
356
+ type: "token",
357
+ input: 2.5,
358
+ output: 12.5
359
+ }
360
+ }
361
+ };
362
+
363
+ // src/data/providers/mistral.json
364
+ var mistral_default2 = {
365
+ id: "mistral",
366
+ name: "Mistral",
367
+ websiteUrl: "https://mistral.ai/",
368
+ apiUrl: "https://api.mistral.ai/v1",
369
+ defaultModel: "mixtral-8x7b-32768",
370
+ models: {
371
+ "mixtral-8x7b-32768": {
372
+ type: "token",
373
+ input: 0.7,
374
+ output: 0.7
375
+ },
376
+ "mistral-large-latest": {
377
+ type: "token",
378
+ input: 0.7,
379
+ output: 0.7
380
+ }
381
+ }
382
+ };
383
+
384
+ // src/builders/providers.ts
385
+ function isTokenPrice(price) {
386
+ return typeof price === "object" && price !== null && "type" in price && price.type === "token" && "input" in price && typeof price.input === "number" && "output" in price && typeof price.output === "number";
387
+ }
388
+ function isImagePrice(price) {
389
+ return typeof price === "object" && price !== null && "type" in price && price.type === "image" && "price" in price && typeof price.price === "number" && "size" in price && typeof price.size === "string" && "unit" in price && price.unit === "per_image";
390
+ }
391
+ function isCharacterPrice(price) {
392
+ return typeof price === "object" && price !== null && "type" in price && price.type === "character" && "price" in price && typeof price.price === "number";
393
+ }
394
+ function isMinutePrice(price) {
395
+ return typeof price === "object" && price !== null && "type" in price && price.type === "minute" && "price" in price && typeof price.price === "number";
396
+ }
397
+ function validateProvider(raw) {
398
+ if (typeof raw !== "object" || raw === null) {
399
+ throw new Error("Provider data must be an object");
400
+ }
401
+ const provider = raw;
402
+ if (typeof provider.id !== "string") {
403
+ throw new Error("Provider id must be a string");
404
+ }
405
+ if (typeof provider.name !== "string") {
406
+ throw new Error("Provider name must be a string");
407
+ }
408
+ if (typeof provider.websiteUrl !== "string") {
409
+ throw new Error("Provider websiteUrl must be a string");
410
+ }
411
+ if (typeof provider.apiUrl !== "string") {
412
+ throw new Error("Provider apiUrl must be a string");
413
+ }
414
+ if (typeof provider.models !== "object" || provider.models === null) {
415
+ throw new Error("Provider models must be an object");
416
+ }
417
+ const models2 = provider.models;
418
+ Object.values(models2).forEach((price) => {
419
+ if (!isTokenPrice(price) && !isImagePrice(price) && !isCharacterPrice(price) && !isMinutePrice(price)) {
420
+ throw new Error(`Invalid price data: ${JSON.stringify(price)}`);
421
+ }
422
+ });
423
+ return {
424
+ id: provider.id,
425
+ name: provider.name,
426
+ websiteUrl: provider.websiteUrl,
427
+ apiUrl: provider.apiUrl,
428
+ models: provider.models
429
+ };
430
+ }
431
+ function buildAllProviders() {
432
+ return [
433
+ validateProvider(openai_default2),
434
+ validateProvider(anthropic_default2),
435
+ validateProvider(mistral_default2)
436
+ ];
437
+ }
438
+ function buildProvidersData() {
439
+ return {
440
+ providers: buildAllProviders()
441
+ };
442
+ }
443
+
444
+ // src/data/creators.json
445
+ var creators_default = {
446
+ creators: {
447
+ openai: {
448
+ name: "OpenAI",
449
+ website: "https://openai.com"
450
+ },
451
+ anthropic: {
452
+ name: "Anthropic",
453
+ website: "https://anthropic.com"
454
+ },
455
+ meta: {
456
+ name: "Meta",
457
+ website: "https://ai.meta.com"
458
+ },
459
+ mistral: {
460
+ name: "Mistral AI",
461
+ website: "https://mistral.ai"
462
+ }
463
+ }
464
+ };
81
465
 
82
466
  // src/index.ts
83
- var aimodels = models_default;
467
+ var allModels = buildAllModels();
468
+ var providersData = buildProvidersData();
84
469
  var models = {
85
- all: aimodels,
470
+ all: allModels,
471
+ get creators() {
472
+ return Object.keys(creators_default.creators);
473
+ },
86
474
  get providers() {
87
- return [...new Set(aimodels.map((model) => model.provider))];
475
+ return providersData.providers.map((p) => p.id);
88
476
  },
89
- from(provider) {
90
- return aimodels.filter((model) => model.provider === provider);
477
+ fromCreator(creator) {
478
+ return allModels.filter(
479
+ (model) => model.license.startsWith(creator) || // For open source models
480
+ providersData.providers.find((p) => p.id === creator)?.models[model.id]
481
+ // For proprietary models
482
+ );
483
+ },
484
+ fromProvider(provider) {
485
+ return allModels.filter((model) => model.providers.includes(provider));
91
486
  },
92
487
  find(id) {
93
- return aimodels.find((model) => model.id === id);
488
+ return allModels.find((model) => model.id === id);
94
489
  },
95
- withCapability(capability) {
96
- return aimodels.filter((model) => model.capabilities.includes(capability));
490
+ can(...capabilities) {
491
+ return allModels.filter(
492
+ (model) => capabilities.every((capability) => model.can.includes(capability))
493
+ );
97
494
  },
98
495
  withMinContext(tokens) {
99
- return aimodels.filter((model) => model.contextWindow >= tokens);
496
+ return allModels.filter((model) => model.context.total >= tokens);
100
497
  },
101
- withMaxPrice(price) {
102
- return aimodels.filter(
103
- (model) => model.pricing.input <= price && model.pricing.output <= price
104
- );
498
+ getPrice(modelId, provider) {
499
+ const providerData = providersData.providers.find((p) => p.id === provider);
500
+ const price = providerData?.models[modelId];
501
+ return price?.type === "token" ? price : void 0;
105
502
  }
106
503
  };
107
504
  // Annotate the CommonJS export names for ESM import in node:
108
505
  0 && (module.exports = {
506
+ creators,
109
507
  models
110
508
  });