aimodels 0.1.1 → 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/README.md CHANGED
@@ -38,28 +38,6 @@ const largeContextModels = models.withMinContext(32768);
38
38
  const affordableModels = models.withMaxPrice(0.01); // Max $0.01 per 1K tokens
39
39
  ```
40
40
 
41
- ## Data Structure
42
-
43
- Each model entry contains the following information:
44
-
45
- ```typescript
46
- interface ModelSpec {
47
- id: string; // Unique identifier for the model
48
- name: string; // Display name
49
- provider: string; // Provider (e.g., 'openai', 'anthropic', etc.)
50
- contextWindow: number; // Maximum context window size in tokens
51
- capabilities: string[]; // Array of capabilities (e.g., ['chat', 'completion'])
52
- pricing: {
53
- input: number; // Cost per 1K input tokens in USD
54
- output: number; // Cost per 1K output tokens in USD
55
- };
56
- released: string; // Release date
57
- license?: string; // License information for open-source models
58
- trainingData?: string[]; // Known training data sources
59
- parameters?: number; // Number of parameters (if known)
60
- }
61
- ```
62
-
63
41
  ## Features
64
42
 
65
43
  - Comprehensive database of AI models
@@ -69,9 +47,6 @@ interface ModelSpec {
69
47
  - Zero dependencies
70
48
  - Universal JavaScript support (Node.js, browsers, Deno)
71
49
 
72
- ## Contributing
73
-
74
- Contributions are welcome! Please check our contributing guidelines for details on how to submit new models or updates.
75
50
 
76
51
  ## License
77
52
 
package/dist/index.d.mts CHANGED
@@ -1,36 +1,75 @@
1
- interface ModelPricing {
1
+ interface ModelPrice {
2
+ /** Price per million input tokens */
2
3
  input: number;
4
+ /** Price per million output tokens */
3
5
  output: number;
6
+ /** Price type */
7
+ type: 'token';
4
8
  }
5
- interface ModelSpec {
9
+
10
+ interface ModelContext {
11
+ /** Maximum total tokens (input + output) */
12
+ total: number;
13
+ /** Maximum output tokens */
14
+ maxOutput: number;
15
+ }
16
+ interface Model {
17
+ /** Unique identifier */
6
18
  id: string;
19
+ /** Display name */
7
20
  name: string;
8
- provider: string;
9
- contextWindow: number;
10
- capabilities: string[];
11
- pricing: ModelPricing;
12
- released: string;
13
- license?: string;
14
- trainingData?: string[];
15
- parameters?: number;
21
+ /** License type (e.g., "proprietary", "apache-2.0", "llama-2-community") */
22
+ license: string;
23
+ /** List of providers that can serve this model */
24
+ providers: string[];
25
+ /** Model capabilities */
26
+ can: string[];
27
+ /** Context window information */
28
+ context: ModelContext;
16
29
  }
17
- interface ModelsCollection {
30
+ interface ModelCollection {
18
31
  /** All available models */
19
- all: ModelSpec[];
20
- /** List of all unique providers */
32
+ all: Model[];
33
+ /** List of all creators */
34
+ creators: string[];
35
+ /** List of all providers */
21
36
  providers: string[];
37
+ /** Get models from a specific creator */
38
+ fromCreator(creator: string): Model[];
22
39
  /** Get models from a specific provider */
23
- from(provider: string): ModelSpec[];
40
+ fromProvider(provider: string): Model[];
24
41
  /** Find a specific model by ID */
25
- find(id: string): ModelSpec | undefined;
26
- /** Filter models by capability */
27
- withCapability(capability: string): ModelSpec[];
42
+ find(id: string): Model | undefined;
43
+ /** Filter models by one or more capabilities (all must be present) */
44
+ can(...capabilities: string[]): Model[];
28
45
  /** Filter models by minimum context window */
29
- withMinContext(tokens: number): ModelSpec[];
30
- /** Filter models by maximum price (per 1K tokens) */
31
- withMaxPrice(price: number): ModelSpec[];
46
+ withMinContext(tokens: number): Model[];
47
+ /** Get pricing for a model from a specific provider */
48
+ getPrice(modelId: string, provider: string): ModelPrice | undefined;
32
49
  }
33
50
 
34
- declare const models: ModelsCollection;
51
+ var creators = {
52
+ openai: {
53
+ name: "OpenAI",
54
+ website: "https://openai.com"
55
+ },
56
+ anthropic: {
57
+ name: "Anthropic",
58
+ website: "https://anthropic.com"
59
+ },
60
+ meta: {
61
+ name: "Meta",
62
+ website: "https://ai.meta.com"
63
+ },
64
+ mistral: {
65
+ name: "Mistral AI",
66
+ website: "https://mistral.ai"
67
+ }
68
+ };
69
+ var creators$1 = {
70
+ creators: creators
71
+ };
72
+
73
+ declare const models: ModelCollection;
35
74
 
36
- export { type ModelPricing, type ModelSpec, type ModelsCollection, models };
75
+ export { creators$1 as creators, models };
package/dist/index.d.ts CHANGED
@@ -1,36 +1,75 @@
1
- interface ModelPricing {
1
+ interface ModelPrice {
2
+ /** Price per million input tokens */
2
3
  input: number;
4
+ /** Price per million output tokens */
3
5
  output: number;
6
+ /** Price type */
7
+ type: 'token';
4
8
  }
5
- interface ModelSpec {
9
+
10
+ interface ModelContext {
11
+ /** Maximum total tokens (input + output) */
12
+ total: number;
13
+ /** Maximum output tokens */
14
+ maxOutput: number;
15
+ }
16
+ interface Model {
17
+ /** Unique identifier */
6
18
  id: string;
19
+ /** Display name */
7
20
  name: string;
8
- provider: string;
9
- contextWindow: number;
10
- capabilities: string[];
11
- pricing: ModelPricing;
12
- released: string;
13
- license?: string;
14
- trainingData?: string[];
15
- parameters?: number;
21
+ /** License type (e.g., "proprietary", "apache-2.0", "llama-2-community") */
22
+ license: string;
23
+ /** List of providers that can serve this model */
24
+ providers: string[];
25
+ /** Model capabilities */
26
+ can: string[];
27
+ /** Context window information */
28
+ context: ModelContext;
16
29
  }
17
- interface ModelsCollection {
30
+ interface ModelCollection {
18
31
  /** All available models */
19
- all: ModelSpec[];
20
- /** List of all unique providers */
32
+ all: Model[];
33
+ /** List of all creators */
34
+ creators: string[];
35
+ /** List of all providers */
21
36
  providers: string[];
37
+ /** Get models from a specific creator */
38
+ fromCreator(creator: string): Model[];
22
39
  /** Get models from a specific provider */
23
- from(provider: string): ModelSpec[];
40
+ fromProvider(provider: string): Model[];
24
41
  /** Find a specific model by ID */
25
- find(id: string): ModelSpec | undefined;
26
- /** Filter models by capability */
27
- withCapability(capability: string): ModelSpec[];
42
+ find(id: string): Model | undefined;
43
+ /** Filter models by one or more capabilities (all must be present) */
44
+ can(...capabilities: string[]): Model[];
28
45
  /** Filter models by minimum context window */
29
- withMinContext(tokens: number): ModelSpec[];
30
- /** Filter models by maximum price (per 1K tokens) */
31
- withMaxPrice(price: number): ModelSpec[];
46
+ withMinContext(tokens: number): Model[];
47
+ /** Get pricing for a model from a specific provider */
48
+ getPrice(modelId: string, provider: string): ModelPrice | undefined;
32
49
  }
33
50
 
34
- declare const models: ModelsCollection;
51
+ var creators = {
52
+ openai: {
53
+ name: "OpenAI",
54
+ website: "https://openai.com"
55
+ },
56
+ anthropic: {
57
+ name: "Anthropic",
58
+ website: "https://anthropic.com"
59
+ },
60
+ meta: {
61
+ name: "Meta",
62
+ website: "https://ai.meta.com"
63
+ },
64
+ mistral: {
65
+ name: "Mistral AI",
66
+ website: "https://mistral.ai"
67
+ }
68
+ };
69
+ var creators$1 = {
70
+ creators: creators
71
+ };
72
+
73
+ declare const models: ModelCollection;
35
74
 
36
- export { type ModelPricing, type ModelSpec, type ModelsCollection, models };
75
+ export { creators$1 as creators, models };
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
  });
package/dist/index.mjs CHANGED
@@ -1,83 +1,480 @@
1
- // src/data/models.json
2
- var models_default = [
3
- {
4
- id: "gpt-4",
5
- name: "GPT-4",
6
- provider: "openai",
7
- contextWindow: 8192,
8
- capabilities: ["chat", "completion"],
9
- pricing: {
10
- input: 0.03,
11
- output: 0.06
12
- },
13
- released: "2023-03-14",
14
- parameters: 11e11
15
- },
16
- {
17
- id: "gpt-3.5-turbo",
18
- name: "GPT-3.5 Turbo",
19
- provider: "openai",
20
- contextWindow: 4096,
21
- capabilities: ["chat", "completion"],
22
- pricing: {
23
- input: 15e-4,
24
- output: 2e-3
25
- },
26
- released: "2022-11-30"
27
- },
28
- {
29
- id: "claude-2.1",
30
- name: "Claude 2.1",
31
- provider: "anthropic",
32
- contextWindow: 2e5,
33
- capabilities: ["chat", "completion"],
34
- pricing: {
35
- input: 8e-3,
36
- output: 0.024
37
- },
38
- released: "2023-11-21"
39
- },
40
- {
41
- id: "llama-2-70b",
42
- name: "Llama 2 70B",
43
- provider: "meta",
44
- contextWindow: 4096,
45
- capabilities: ["chat", "completion"],
46
- pricing: {
47
- input: 0,
48
- output: 0
49
- },
50
- released: "2023-07-18",
51
- license: "Llama 2 Community License",
52
- parameters: 7e10
1
+ // src/data/models/openai.json
2
+ var openai_default = {
3
+ models: [
4
+ {
5
+ id: "whisper-1",
6
+ name: "Whisper-1",
7
+ license: "proprietary",
8
+ providers: ["openai"],
9
+ can: ["sound-in", "text-out"],
10
+ context: {
11
+ total: null,
12
+ maxOutput: null
13
+ }
14
+ },
15
+ {
16
+ id: "tts-1",
17
+ name: "TTS-1",
18
+ license: "proprietary",
19
+ providers: ["openai"],
20
+ can: ["text-in", "sound-out"],
21
+ context: {
22
+ total: null,
23
+ maxOutput: null
24
+ }
25
+ },
26
+ {
27
+ id: "tts-1-hd",
28
+ name: "TTS-1 HD",
29
+ license: "proprietary",
30
+ providers: ["openai"],
31
+ can: ["text-in", "sound-out"],
32
+ context: {
33
+ total: null,
34
+ maxOutput: null
35
+ }
36
+ },
37
+ {
38
+ id: "gpt-4o",
39
+ name: "GPT-4O",
40
+ license: "proprietary",
41
+ providers: ["openai"],
42
+ can: ["chat", "img-in", "json-out", "function-out"],
43
+ context: {
44
+ total: 128e3,
45
+ maxOutput: 16384
46
+ }
47
+ },
48
+ {
49
+ id: "gpt-4o-mini",
50
+ name: "GPT-4O Mini",
51
+ license: "proprietary",
52
+ providers: ["openai"],
53
+ can: ["chat", "img-in", "json-out", "function-out"],
54
+ context: {
55
+ total: 128e3,
56
+ maxOutput: 16384
57
+ }
58
+ },
59
+ {
60
+ id: "o1",
61
+ name: "OpenAI O1",
62
+ license: "proprietary",
63
+ providers: ["openai"],
64
+ can: ["chat", "img-in", "json-out", "function-out"],
65
+ context: {
66
+ total: 2e5,
67
+ maxOutput: 1e5
68
+ }
69
+ },
70
+ {
71
+ id: "o1-mini",
72
+ name: "OpenAI O1 Mini",
73
+ license: "proprietary",
74
+ providers: ["openai"],
75
+ can: ["chat", "json-out", "function-out"],
76
+ context: {
77
+ total: 128e3,
78
+ maxOutput: 65536
79
+ }
80
+ },
81
+ {
82
+ id: "o3-mini",
83
+ name: "OpenAI O3 Mini",
84
+ license: "proprietary",
85
+ providers: ["openai"],
86
+ can: ["chat", "json-out", "function-out"],
87
+ context: {
88
+ total: 2e5,
89
+ maxOutput: 1e5
90
+ }
91
+ },
92
+ {
93
+ id: "gpt-4o-audio-preview",
94
+ name: "GPT-4O Audio",
95
+ license: "proprietary",
96
+ providers: ["openai"],
97
+ can: ["chat", "sound-in", "json-out", "function-out"],
98
+ context: {
99
+ total: 128e3,
100
+ maxOutput: 16384
101
+ }
102
+ },
103
+ {
104
+ id: "gpt-4o-realtime-preview",
105
+ name: "GPT-4O Realtime",
106
+ license: "proprietary",
107
+ providers: ["openai"],
108
+ can: ["chat", "sound-in", "json-out", "function-out"],
109
+ context: {
110
+ total: 128e3,
111
+ maxOutput: 4096
112
+ }
113
+ },
114
+ {
115
+ id: "dall-e-3",
116
+ name: "DALL-E 3",
117
+ license: "proprietary",
118
+ providers: ["openai"],
119
+ can: ["img-out"],
120
+ context: {
121
+ maxOutput: 1,
122
+ sizes: [
123
+ "1024x1024",
124
+ "1024x1792",
125
+ "1792x1024"
126
+ ],
127
+ qualities: [
128
+ "standard",
129
+ "hd"
130
+ ]
131
+ }
132
+ }
133
+ ]
134
+ };
135
+
136
+ // src/data/models/anthropic.json
137
+ var anthropic_default = {
138
+ models: [
139
+ {
140
+ id: "claude-3-opus",
141
+ name: "Claude 3 Opus",
142
+ license: "proprietary",
143
+ providers: ["anthropic"],
144
+ can: ["chat", "img-in", "json-out", "function-out"],
145
+ context: {
146
+ total: 2e5,
147
+ maxOutput: 4096
148
+ }
149
+ },
150
+ {
151
+ id: "claude-3-sonnet",
152
+ name: "Claude 3 Sonnet",
153
+ license: "proprietary",
154
+ providers: ["anthropic"],
155
+ can: ["chat", "img-in", "json-out", "function-out"],
156
+ context: {
157
+ total: 2e5,
158
+ maxOutput: 4096
159
+ }
160
+ },
161
+ {
162
+ id: "claude-3-haiku",
163
+ name: "Claude 3 Haiku",
164
+ license: "proprietary",
165
+ providers: ["anthropic"],
166
+ can: ["chat", "img-in", "json-out", "function-out"],
167
+ context: {
168
+ total: 2e5,
169
+ maxOutput: 4096
170
+ }
171
+ }
172
+ ]
173
+ };
174
+
175
+ // src/data/models/meta.json
176
+ var meta_default = {
177
+ models: [
178
+ {
179
+ id: "llama2-70b-4096",
180
+ name: "Llama 2 70B",
181
+ license: "llama-2-community",
182
+ providers: ["groq", "ollama"],
183
+ can: ["chat", "json-out", "function-out"],
184
+ context: {
185
+ total: 4096,
186
+ maxOutput: 4096
187
+ }
188
+ }
189
+ ]
190
+ };
191
+
192
+ // src/data/models/mistral.json
193
+ var mistral_default = {
194
+ models: [
195
+ {
196
+ id: "mixtral-8x7b-32768",
197
+ name: "Mixtral 8x7B",
198
+ license: "apache-2.0",
199
+ providers: ["groq"],
200
+ can: ["chat", "json-out", "function-out"],
201
+ context: {
202
+ total: 32768,
203
+ maxOutput: 4096
204
+ }
205
+ }
206
+ ]
207
+ };
208
+
209
+ // src/builders/models.ts
210
+ function buildAllModels() {
211
+ return [
212
+ ...openai_default.models,
213
+ ...anthropic_default.models,
214
+ ...meta_default.models,
215
+ ...mistral_default.models
216
+ ];
217
+ }
218
+
219
+ // src/data/providers/openai.json
220
+ var openai_default2 = {
221
+ id: "openai",
222
+ name: "OpenAI",
223
+ websiteUrl: "https://openai.com/",
224
+ apiUrl: "https://api.openai.com/v1",
225
+ defaultModel: "gpt-4o",
226
+ models: {
227
+ "gpt-4o": {
228
+ type: "token",
229
+ input: 20,
230
+ output: 80
231
+ },
232
+ "gpt-3.5-turbo": {
233
+ type: "token",
234
+ input: 5,
235
+ output: 20
236
+ },
237
+ "gpt-4o-vision": {
238
+ type: "token",
239
+ input: 15,
240
+ input_cached: 7.5,
241
+ output: 60
242
+ },
243
+ "o1-mini": {
244
+ type: "token",
245
+ input: 3,
246
+ input_cached: 1.5,
247
+ output: 15
248
+ },
249
+ "o3-mini": {
250
+ type: "token",
251
+ input: 3,
252
+ input_cached: 1.5,
253
+ output: 15
254
+ },
255
+ "gpt-4o-audio-preview": {
256
+ type: "token",
257
+ input: 20,
258
+ output: 80
259
+ },
260
+ "gpt-4o-vision-preview": {
261
+ type: "token",
262
+ input: 20,
263
+ output: 80
264
+ },
265
+ "whisper-1": {
266
+ type: "minute",
267
+ price: 6e-3
268
+ },
269
+ "tts-1": {
270
+ type: "character",
271
+ price: 15e-6
272
+ },
273
+ "tts-1-hd": {
274
+ type: "character",
275
+ price: 3e-5
276
+ },
277
+ "dall-e-2": {
278
+ type: "image",
279
+ price: 0.016,
280
+ size: "256x256",
281
+ unit: "per_image"
282
+ },
283
+ "dall-e-2-512": {
284
+ type: "image",
285
+ price: 0.018,
286
+ size: "512x512",
287
+ unit: "per_image"
288
+ },
289
+ "dall-e-2-1024": {
290
+ type: "image",
291
+ price: 0.02,
292
+ size: "1024x1024",
293
+ unit: "per_image"
294
+ },
295
+ "dall-e-3": {
296
+ type: "image",
297
+ price: 0.04,
298
+ size: "1024x1024",
299
+ unit: "per_image"
300
+ },
301
+ "dall-e-3-hd": {
302
+ type: "image",
303
+ price: 0.08,
304
+ size: "1024x1024",
305
+ unit: "per_image"
306
+ }
53
307
  }
54
- ];
308
+ };
309
+
310
+ // src/data/providers/anthropic.json
311
+ var anthropic_default2 = {
312
+ id: "anthropic",
313
+ name: "Anthropic",
314
+ websiteUrl: "https://www.anthropic.com/",
315
+ apiUrl: "https://api.anthropic.com/v1",
316
+ defaultModel: "claude-3-sonnet",
317
+ models: {
318
+ "claude-3-opus": {
319
+ type: "token",
320
+ input: 15,
321
+ output: 75
322
+ },
323
+ "claude-3-sonnet": {
324
+ type: "token",
325
+ input: 3,
326
+ output: 15
327
+ },
328
+ "claude-3-haiku": {
329
+ type: "token",
330
+ input: 2.5,
331
+ output: 12.5
332
+ }
333
+ }
334
+ };
335
+
336
+ // src/data/providers/mistral.json
337
+ var mistral_default2 = {
338
+ id: "mistral",
339
+ name: "Mistral",
340
+ websiteUrl: "https://mistral.ai/",
341
+ apiUrl: "https://api.mistral.ai/v1",
342
+ defaultModel: "mixtral-8x7b-32768",
343
+ models: {
344
+ "mixtral-8x7b-32768": {
345
+ type: "token",
346
+ input: 0.7,
347
+ output: 0.7
348
+ },
349
+ "mistral-large-latest": {
350
+ type: "token",
351
+ input: 0.7,
352
+ output: 0.7
353
+ }
354
+ }
355
+ };
356
+
357
+ // src/builders/providers.ts
358
+ function isTokenPrice(price) {
359
+ 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";
360
+ }
361
+ function isImagePrice(price) {
362
+ 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";
363
+ }
364
+ function isCharacterPrice(price) {
365
+ return typeof price === "object" && price !== null && "type" in price && price.type === "character" && "price" in price && typeof price.price === "number";
366
+ }
367
+ function isMinutePrice(price) {
368
+ return typeof price === "object" && price !== null && "type" in price && price.type === "minute" && "price" in price && typeof price.price === "number";
369
+ }
370
+ function validateProvider(raw) {
371
+ if (typeof raw !== "object" || raw === null) {
372
+ throw new Error("Provider data must be an object");
373
+ }
374
+ const provider = raw;
375
+ if (typeof provider.id !== "string") {
376
+ throw new Error("Provider id must be a string");
377
+ }
378
+ if (typeof provider.name !== "string") {
379
+ throw new Error("Provider name must be a string");
380
+ }
381
+ if (typeof provider.websiteUrl !== "string") {
382
+ throw new Error("Provider websiteUrl must be a string");
383
+ }
384
+ if (typeof provider.apiUrl !== "string") {
385
+ throw new Error("Provider apiUrl must be a string");
386
+ }
387
+ if (typeof provider.models !== "object" || provider.models === null) {
388
+ throw new Error("Provider models must be an object");
389
+ }
390
+ const models2 = provider.models;
391
+ Object.values(models2).forEach((price) => {
392
+ if (!isTokenPrice(price) && !isImagePrice(price) && !isCharacterPrice(price) && !isMinutePrice(price)) {
393
+ throw new Error(`Invalid price data: ${JSON.stringify(price)}`);
394
+ }
395
+ });
396
+ return {
397
+ id: provider.id,
398
+ name: provider.name,
399
+ websiteUrl: provider.websiteUrl,
400
+ apiUrl: provider.apiUrl,
401
+ models: provider.models
402
+ };
403
+ }
404
+ function buildAllProviders() {
405
+ return [
406
+ validateProvider(openai_default2),
407
+ validateProvider(anthropic_default2),
408
+ validateProvider(mistral_default2)
409
+ ];
410
+ }
411
+ function buildProvidersData() {
412
+ return {
413
+ providers: buildAllProviders()
414
+ };
415
+ }
416
+
417
+ // src/data/creators.json
418
+ var creators_default = {
419
+ creators: {
420
+ openai: {
421
+ name: "OpenAI",
422
+ website: "https://openai.com"
423
+ },
424
+ anthropic: {
425
+ name: "Anthropic",
426
+ website: "https://anthropic.com"
427
+ },
428
+ meta: {
429
+ name: "Meta",
430
+ website: "https://ai.meta.com"
431
+ },
432
+ mistral: {
433
+ name: "Mistral AI",
434
+ website: "https://mistral.ai"
435
+ }
436
+ }
437
+ };
55
438
 
56
439
  // src/index.ts
57
- var aimodels = models_default;
440
+ var allModels = buildAllModels();
441
+ var providersData = buildProvidersData();
58
442
  var models = {
59
- all: aimodels,
443
+ all: allModels,
444
+ get creators() {
445
+ return Object.keys(creators_default.creators);
446
+ },
60
447
  get providers() {
61
- return [...new Set(aimodels.map((model) => model.provider))];
448
+ return providersData.providers.map((p) => p.id);
62
449
  },
63
- from(provider) {
64
- return aimodels.filter((model) => model.provider === provider);
450
+ fromCreator(creator) {
451
+ return allModels.filter(
452
+ (model) => model.license.startsWith(creator) || // For open source models
453
+ providersData.providers.find((p) => p.id === creator)?.models[model.id]
454
+ // For proprietary models
455
+ );
456
+ },
457
+ fromProvider(provider) {
458
+ return allModels.filter((model) => model.providers.includes(provider));
65
459
  },
66
460
  find(id) {
67
- return aimodels.find((model) => model.id === id);
461
+ return allModels.find((model) => model.id === id);
68
462
  },
69
- withCapability(capability) {
70
- return aimodels.filter((model) => model.capabilities.includes(capability));
463
+ can(...capabilities) {
464
+ return allModels.filter(
465
+ (model) => capabilities.every((capability) => model.can.includes(capability))
466
+ );
71
467
  },
72
468
  withMinContext(tokens) {
73
- return aimodels.filter((model) => model.contextWindow >= tokens);
469
+ return allModels.filter((model) => model.context.total >= tokens);
74
470
  },
75
- withMaxPrice(price) {
76
- return aimodels.filter(
77
- (model) => model.pricing.input <= price && model.pricing.output <= price
78
- );
471
+ getPrice(modelId, provider) {
472
+ const providerData = providersData.providers.find((p) => p.id === provider);
473
+ const price = providerData?.models[modelId];
474
+ return price?.type === "token" ? price : void 0;
79
475
  }
80
476
  };
81
477
  export {
478
+ creators_default as creators,
82
479
  models
83
480
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimodels",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A collection of AI model specifications across different providers",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -17,20 +17,30 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "scripts": {
20
+ "prebuild": "npm run typecheck && npm run lint && npm test",
20
21
  "build": "tsup src/index.ts --format cjs,esm --dts",
21
- "test": "jest",
22
+ "test": "deno test tests/",
23
+ "test:watch": "deno test --watch tests/",
22
24
  "typecheck": "tsc --noEmit",
23
25
  "lint": "eslint src --ext .ts",
24
- "prepublishOnly": "npm run build"
26
+ "clean": "rm -rf dist",
27
+ "prepare": "npm run build",
28
+ "preversion": "npm run typecheck && npm run lint && npm test",
29
+ "version": "git add -A",
30
+ "postversion": "git push && git push --tags",
31
+ "prepublishOnly": "npm run clean && npm run typecheck && npm test && npm run lint",
32
+ "postpublish": "npm run clean"
25
33
  },
26
34
  "keywords": [
27
35
  "ai",
28
36
  "models",
37
+ "ai models",
29
38
  "llm",
30
39
  "machine-learning",
31
40
  "specifications",
32
41
  "openai",
33
42
  "anthropic",
43
+ "mistral",
34
44
  "open-source"
35
45
  ],
36
46
  "author": "Dmitry Kury (d@dkury.com)",
@@ -43,13 +53,14 @@
43
53
  "url": "https://github.com/mitkury/aimodels/issues"
44
54
  },
45
55
  "homepage": "https://github.com/mitkury/aimodels#readme",
56
+ "engines": {
57
+ "deno": ">=1.40.0"
58
+ },
46
59
  "devDependencies": {
47
60
  "@types/node": "^20.0.0",
48
61
  "@typescript-eslint/eslint-plugin": "^6.0.0",
49
62
  "@typescript-eslint/parser": "^6.0.0",
50
63
  "eslint": "^8.0.0",
51
- "jest": "^29.0.0",
52
- "ts-jest": "^29.0.0",
53
64
  "tsup": "^8.0.0",
54
65
  "typescript": "^5.0.0"
55
66
  }