aimodels 0.1.1 → 0.2.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/README.md +53 -38
- package/dist/index.d.mts +75 -22
- package/dist/index.d.ts +75 -22
- package/dist/index.js +578 -67
- package/dist/index.mjs +577 -67
- package/package.json +16 -5
package/README.md
CHANGED
|
@@ -17,61 +17,76 @@ import { models } from 'aimodels';
|
|
|
17
17
|
console.log(models.all);
|
|
18
18
|
|
|
19
19
|
// Get list of all providers
|
|
20
|
-
console.log(models.providers); // ['openai', 'anthropic', '
|
|
20
|
+
console.log(models.providers); // ['openai', 'anthropic', 'mistral', ...]
|
|
21
|
+
|
|
22
|
+
// Get list of model creators
|
|
23
|
+
console.log(models.creators); // ['meta', 'mistral', ...]
|
|
21
24
|
|
|
22
25
|
// Get models from a specific provider
|
|
23
|
-
const openAiModels = models.
|
|
26
|
+
const openAiModels = models.fromProvider('openai');
|
|
27
|
+
|
|
28
|
+
// Get models from a specific creator
|
|
29
|
+
const metaModels = models.fromCreator('meta');
|
|
24
30
|
|
|
25
31
|
// Find a specific model
|
|
26
|
-
const model = models.find('
|
|
27
|
-
console.log(model.
|
|
28
|
-
console.log(model
|
|
29
|
-
|
|
32
|
+
const model = models.find('gpt-4');
|
|
33
|
+
console.log(model?.context.total); // Context window size
|
|
34
|
+
console.log(model?.providers); // ['openai']
|
|
35
|
+
|
|
36
|
+
// Get model pricing for a specific provider
|
|
37
|
+
const price = models.getPrice('gpt-4', 'openai');
|
|
38
|
+
console.log(price); // { type: 'token', input: 0.03, output: 0.06 }
|
|
30
39
|
|
|
31
|
-
// Filter models by
|
|
32
|
-
const chatModels = models.
|
|
40
|
+
// Filter models by capabilities
|
|
41
|
+
const chatModels = models.can('chat');
|
|
42
|
+
const multimodalModels = models.can('chat', 'img-in');
|
|
33
43
|
|
|
34
44
|
// Filter by context window
|
|
35
45
|
const largeContextModels = models.withMinContext(32768);
|
|
36
|
-
|
|
37
|
-
// Filter by maximum price
|
|
38
|
-
const affordableModels = models.withMaxPrice(0.01); // Max $0.01 per 1K tokens
|
|
39
|
-
```
|
|
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
46
|
```
|
|
62
47
|
|
|
63
48
|
## Features
|
|
64
49
|
|
|
65
|
-
- Comprehensive database of AI models
|
|
50
|
+
- Comprehensive database of AI models from major providers (OpenAI, Anthropic, Mistral, etc.)
|
|
66
51
|
- Normalized data structure for easy comparison
|
|
67
|
-
-
|
|
68
|
-
-
|
|
52
|
+
- Model capabilities (chat, img-in, img-out, function-out, etc.)
|
|
53
|
+
- Context window information
|
|
54
|
+
- Pricing information per provider
|
|
55
|
+
- Creator and provider associations
|
|
56
|
+
- TypeScript support with full type safety
|
|
69
57
|
- Zero dependencies
|
|
70
58
|
- Universal JavaScript support (Node.js, browsers, Deno)
|
|
59
|
+
- Regular updates with new models
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Types
|
|
71
63
|
|
|
72
|
-
|
|
64
|
+
```typescript
|
|
65
|
+
interface Model {
|
|
66
|
+
id: string; // Unique model identifier
|
|
67
|
+
name: string; // Display name
|
|
68
|
+
can: string[]; // Capabilities (chat, img-in, img-out, etc.)
|
|
69
|
+
providers: string[]; // Available providers
|
|
70
|
+
context: {
|
|
71
|
+
total: number; // Total context window size
|
|
72
|
+
};
|
|
73
|
+
license: string; // License or creator
|
|
74
|
+
}
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
type ModelPrice =
|
|
77
|
+
| { type: 'token'; input: number; output: number } // Price per 1K tokens
|
|
78
|
+
| { type: 'image'; price: number; size: string } // Price per image
|
|
79
|
+
| { type: 'character'; price: number } // Price per character
|
|
80
|
+
| { type: 'minute'; price: number }; // Price per minute
|
|
81
|
+
|
|
82
|
+
interface Provider {
|
|
83
|
+
id: string; // Provider identifier
|
|
84
|
+
name: string; // Display name
|
|
85
|
+
websiteUrl: string; // Provider's website
|
|
86
|
+
apiUrl: string; // API documentation URL
|
|
87
|
+
models: Record<string, ModelPrice>; // Model pricing
|
|
88
|
+
}
|
|
89
|
+
```
|
|
75
90
|
|
|
76
91
|
## License
|
|
77
92
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,36 +1,89 @@
|
|
|
1
|
-
interface
|
|
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
|
-
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Defines all possible model capabilities
|
|
12
|
+
*/
|
|
13
|
+
type Capability = "chat" | "reason" | "text-in" | "text-out" | "img-in" | "img-out" | "sound-in" | "sound-out" | "json-out" | "function-out" | "vectors-out";
|
|
14
|
+
|
|
15
|
+
declare class ModelCollection extends Array<Model> {
|
|
16
|
+
constructor(models: Model[]);
|
|
17
|
+
can(...capabilities: Capability[]): ModelCollection;
|
|
18
|
+
know(...languages: string[]): ModelCollection;
|
|
19
|
+
filter(predicate: (value: Model, index: number, array: Model[]) => boolean): ModelCollection;
|
|
20
|
+
slice(start?: number, end?: number): ModelCollection;
|
|
21
|
+
}
|
|
22
|
+
interface ModelContext {
|
|
23
|
+
/** Maximum total tokens (input + output) */
|
|
24
|
+
total: number;
|
|
25
|
+
/** Maximum output tokens */
|
|
26
|
+
maxOutput: number;
|
|
27
|
+
}
|
|
28
|
+
interface Model {
|
|
29
|
+
/** Unique identifier */
|
|
6
30
|
id: string;
|
|
31
|
+
/** Display name */
|
|
7
32
|
name: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
/** License type (e.g., "proprietary", "apache-2.0", "llama-2-community") */
|
|
34
|
+
license: string;
|
|
35
|
+
/** List of providers that can serve this model */
|
|
36
|
+
providers: string[];
|
|
37
|
+
/** Model capabilities */
|
|
38
|
+
can: Capability[];
|
|
39
|
+
/** Languages the model knows */
|
|
40
|
+
languages?: string[];
|
|
41
|
+
/** Context window information */
|
|
42
|
+
context: ModelContext;
|
|
16
43
|
}
|
|
17
|
-
interface
|
|
44
|
+
interface ModelsAPI {
|
|
18
45
|
/** All available models */
|
|
19
|
-
all:
|
|
20
|
-
/** List of all
|
|
46
|
+
all: ModelCollection;
|
|
47
|
+
/** List of all creators */
|
|
48
|
+
creators: string[];
|
|
49
|
+
/** List of all providers */
|
|
21
50
|
providers: string[];
|
|
51
|
+
/** Get models from a specific creator */
|
|
52
|
+
fromCreator(creator: string): ModelCollection;
|
|
22
53
|
/** Get models from a specific provider */
|
|
23
|
-
|
|
54
|
+
fromProvider(provider: string): ModelCollection;
|
|
24
55
|
/** Find a specific model by ID */
|
|
25
|
-
find(id: string):
|
|
26
|
-
/** Filter models by
|
|
27
|
-
|
|
56
|
+
find(id: string): Model | undefined;
|
|
57
|
+
/** Filter models by one or more capabilities (all must be present) */
|
|
58
|
+
can(...capabilities: string[]): ModelCollection;
|
|
28
59
|
/** Filter models by minimum context window */
|
|
29
|
-
withMinContext(tokens: number):
|
|
30
|
-
/**
|
|
31
|
-
|
|
60
|
+
withMinContext(tokens: number): ModelCollection;
|
|
61
|
+
/** Get pricing for a model from a specific provider */
|
|
62
|
+
getPrice(modelId: string, provider: string): ModelPrice | undefined;
|
|
32
63
|
}
|
|
33
64
|
|
|
34
|
-
|
|
65
|
+
var creators = {
|
|
66
|
+
openai: {
|
|
67
|
+
name: "OpenAI",
|
|
68
|
+
website: "https://openai.com"
|
|
69
|
+
},
|
|
70
|
+
anthropic: {
|
|
71
|
+
name: "Anthropic",
|
|
72
|
+
website: "https://anthropic.com"
|
|
73
|
+
},
|
|
74
|
+
meta: {
|
|
75
|
+
name: "Meta",
|
|
76
|
+
website: "https://ai.meta.com"
|
|
77
|
+
},
|
|
78
|
+
mistral: {
|
|
79
|
+
name: "Mistral AI",
|
|
80
|
+
website: "https://mistral.ai"
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var creators$1 = {
|
|
84
|
+
creators: creators
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
declare const models: ModelsAPI;
|
|
35
88
|
|
|
36
|
-
export {
|
|
89
|
+
export { creators$1 as creators, models };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,89 @@
|
|
|
1
|
-
interface
|
|
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
|
-
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Defines all possible model capabilities
|
|
12
|
+
*/
|
|
13
|
+
type Capability = "chat" | "reason" | "text-in" | "text-out" | "img-in" | "img-out" | "sound-in" | "sound-out" | "json-out" | "function-out" | "vectors-out";
|
|
14
|
+
|
|
15
|
+
declare class ModelCollection extends Array<Model> {
|
|
16
|
+
constructor(models: Model[]);
|
|
17
|
+
can(...capabilities: Capability[]): ModelCollection;
|
|
18
|
+
know(...languages: string[]): ModelCollection;
|
|
19
|
+
filter(predicate: (value: Model, index: number, array: Model[]) => boolean): ModelCollection;
|
|
20
|
+
slice(start?: number, end?: number): ModelCollection;
|
|
21
|
+
}
|
|
22
|
+
interface ModelContext {
|
|
23
|
+
/** Maximum total tokens (input + output) */
|
|
24
|
+
total: number;
|
|
25
|
+
/** Maximum output tokens */
|
|
26
|
+
maxOutput: number;
|
|
27
|
+
}
|
|
28
|
+
interface Model {
|
|
29
|
+
/** Unique identifier */
|
|
6
30
|
id: string;
|
|
31
|
+
/** Display name */
|
|
7
32
|
name: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
/** License type (e.g., "proprietary", "apache-2.0", "llama-2-community") */
|
|
34
|
+
license: string;
|
|
35
|
+
/** List of providers that can serve this model */
|
|
36
|
+
providers: string[];
|
|
37
|
+
/** Model capabilities */
|
|
38
|
+
can: Capability[];
|
|
39
|
+
/** Languages the model knows */
|
|
40
|
+
languages?: string[];
|
|
41
|
+
/** Context window information */
|
|
42
|
+
context: ModelContext;
|
|
16
43
|
}
|
|
17
|
-
interface
|
|
44
|
+
interface ModelsAPI {
|
|
18
45
|
/** All available models */
|
|
19
|
-
all:
|
|
20
|
-
/** List of all
|
|
46
|
+
all: ModelCollection;
|
|
47
|
+
/** List of all creators */
|
|
48
|
+
creators: string[];
|
|
49
|
+
/** List of all providers */
|
|
21
50
|
providers: string[];
|
|
51
|
+
/** Get models from a specific creator */
|
|
52
|
+
fromCreator(creator: string): ModelCollection;
|
|
22
53
|
/** Get models from a specific provider */
|
|
23
|
-
|
|
54
|
+
fromProvider(provider: string): ModelCollection;
|
|
24
55
|
/** Find a specific model by ID */
|
|
25
|
-
find(id: string):
|
|
26
|
-
/** Filter models by
|
|
27
|
-
|
|
56
|
+
find(id: string): Model | undefined;
|
|
57
|
+
/** Filter models by one or more capabilities (all must be present) */
|
|
58
|
+
can(...capabilities: string[]): ModelCollection;
|
|
28
59
|
/** Filter models by minimum context window */
|
|
29
|
-
withMinContext(tokens: number):
|
|
30
|
-
/**
|
|
31
|
-
|
|
60
|
+
withMinContext(tokens: number): ModelCollection;
|
|
61
|
+
/** Get pricing for a model from a specific provider */
|
|
62
|
+
getPrice(modelId: string, provider: string): ModelPrice | undefined;
|
|
32
63
|
}
|
|
33
64
|
|
|
34
|
-
|
|
65
|
+
var creators = {
|
|
66
|
+
openai: {
|
|
67
|
+
name: "OpenAI",
|
|
68
|
+
website: "https://openai.com"
|
|
69
|
+
},
|
|
70
|
+
anthropic: {
|
|
71
|
+
name: "Anthropic",
|
|
72
|
+
website: "https://anthropic.com"
|
|
73
|
+
},
|
|
74
|
+
meta: {
|
|
75
|
+
name: "Meta",
|
|
76
|
+
website: "https://ai.meta.com"
|
|
77
|
+
},
|
|
78
|
+
mistral: {
|
|
79
|
+
name: "Mistral AI",
|
|
80
|
+
website: "https://mistral.ai"
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var creators$1 = {
|
|
84
|
+
creators: creators
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
declare const models: ModelsAPI;
|
|
35
88
|
|
|
36
|
-
export {
|
|
89
|
+
export { creators$1 as creators, models };
|