@tashiscool/providers 0.1.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 ADDED
@@ -0,0 +1,177 @@
1
+ # @llm-utils/providers
2
+
3
+ LLM provider registry with comprehensive model metadata and capabilities. Easily discover and manage models across 14+ providers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @llm-utils/providers
9
+ # or
10
+ npm install @llm-utils/providers
11
+ ```
12
+
13
+ ## Features
14
+
15
+ - **14+ Provider Support** - OpenAI, Anthropic, Google, Mistral, Groq, DeepSeek, xAI, and more
16
+ - **Model Metadata** - Context windows, capabilities, pricing, and release dates
17
+ - **Capability Filtering** - Find models with vision, tool calling, streaming, etc.
18
+ - **Credential Management** - Auto-detection from environment variables
19
+ - **Type-Safe** - Full TypeScript support with comprehensive types
20
+
21
+ ## Usage
22
+
23
+ ### Quick Start
24
+
25
+ ```typescript
26
+ import {
27
+ getModelById,
28
+ getModelsWithCapability,
29
+ ProviderRegistry
30
+ } from '@llm-utils/providers';
31
+
32
+ // Get a specific model
33
+ const gpt4o = getModelById('gpt-4o');
34
+ console.log(gpt4o?.contextWindow); // 128000
35
+ console.log(gpt4o?.capabilities.vision); // true
36
+
37
+ // Find all models with vision capability
38
+ const visionModels = getModelsWithCapability('vision');
39
+ console.log(visionModels.length); // Multiple models
40
+
41
+ // Create a registry from environment
42
+ const registry = new ProviderRegistry();
43
+ registry.registerFromEnv();
44
+
45
+ // Find models across registered providers
46
+ const streamingModels = registry.findModelsWithCapability('streaming');
47
+ ```
48
+
49
+ ### Provider Registry
50
+
51
+ ```typescript
52
+ import { ProviderRegistry, createProviderInstance } from '@llm-utils/providers';
53
+
54
+ // Create a registry
55
+ const registry = new ProviderRegistry();
56
+
57
+ // Register with explicit credentials
58
+ registry.register('openai', { apiKey: 'sk-...' });
59
+ registry.register('anthropic', { apiKey: 'sk-ant-...' });
60
+
61
+ // Or register all from environment
62
+ registry.registerFromEnv();
63
+
64
+ // Get a provider instance
65
+ const openai = registry.get('openai');
66
+ if (openai?.isConfigured()) {
67
+ const models = openai.listModels();
68
+ const visionModels = openai.listModelsWithCapability('vision');
69
+ }
70
+ ```
71
+
72
+ ### Model Discovery
73
+
74
+ ```typescript
75
+ import {
76
+ allModels,
77
+ getModelsByProvider,
78
+ getModelsWithCapability
79
+ } from '@llm-utils/providers';
80
+
81
+ // Get all models
82
+ console.log(allModels.length);
83
+
84
+ // Get models by provider
85
+ const anthropicModels = getModelsByProvider('anthropic');
86
+ const openaiModels = getModelsByProvider('openai');
87
+
88
+ // Filter by capability
89
+ const toolCallingModels = getModelsWithCapability('toolCalling');
90
+ const jsonModeModels = getModelsWithCapability('jsonMode');
91
+ const embeddingModels = getModelsWithCapability('embeddings');
92
+ ```
93
+
94
+ ### Provider Configuration
95
+
96
+ ```typescript
97
+ import { getProvider, getAllProviders, isProviderConfigured } from '@llm-utils/providers';
98
+
99
+ // Get provider config
100
+ const openai = getProvider('openai');
101
+ console.log(openai.baseUrl); // https://api.openai.com/v1
102
+ console.log(openai.requiredEnvVars); // ['OPENAI_API_KEY']
103
+
104
+ // List all providers
105
+ const providers = getAllProviders();
106
+ providers.forEach(p => console.log(`${p.name}: ${p.description}`));
107
+
108
+ // Check if configured from environment
109
+ if (isProviderConfigured('anthropic')) {
110
+ console.log('Anthropic is ready to use');
111
+ }
112
+ ```
113
+
114
+ ## Supported Providers
115
+
116
+ | Provider | ID | Models |
117
+ |----------|-----|--------|
118
+ | OpenAI | `openai` | GPT-4o, GPT-4, o1, DALL-E, Embeddings |
119
+ | Anthropic | `anthropic` | Claude 3.5 Sonnet, Claude 3 Opus, Haiku |
120
+ | Google | `google` | Gemini 2.0, Gemini 1.5 Pro/Flash |
121
+ | Mistral | `mistral` | Mistral Large, Small, Codestral |
122
+ | Groq | `groq` | Llama 3.3, Mixtral, Gemma |
123
+ | DeepSeek | `deepseek` | DeepSeek V3, R1 |
124
+ | xAI | `xai` | Grok 2, Grok Vision |
125
+ | Azure OpenAI | `azure-openai` | OpenAI models on Azure |
126
+ | AWS Bedrock | `aws-bedrock` | Claude, Mistral on AWS |
127
+ | Ollama | `ollama` | Local models |
128
+ | Together AI | `together-ai` | Open models |
129
+ | Replicate | `replicate` | Various models |
130
+ | Hugging Face | `huggingface` | Inference API |
131
+ | Cohere | `cohere` | Command, Embed |
132
+
133
+ ## Model Capabilities
134
+
135
+ Each model includes capability flags:
136
+
137
+ ```typescript
138
+ interface ModelCapabilities {
139
+ chat: boolean; // Text generation
140
+ vision: boolean; // Image input
141
+ toolCalling: boolean; // Function calling
142
+ jsonMode: boolean; // JSON output mode
143
+ structuredOutput: boolean; // Schema-based output
144
+ streaming: boolean; // Stream responses
145
+ embeddings: boolean; // Vector embeddings
146
+ imageGeneration: boolean; // Image creation
147
+ audio: boolean; // Audio I/O
148
+ }
149
+ ```
150
+
151
+ ## API Reference
152
+
153
+ ### Types
154
+
155
+ - `ProviderId` - Provider identifier union type
156
+ - `ModelMetadata` - Model information including capabilities and pricing
157
+ - `ProviderConfig` - Provider configuration including base URL and env vars
158
+ - `ProviderCredentials` - API keys and connection options
159
+ - `ProviderInstance` - Configured provider with methods
160
+
161
+ ### Functions
162
+
163
+ - `getModelById(id)` - Get model by ID
164
+ - `getModelsByProvider(provider)` - Get all models for a provider
165
+ - `getModelsWithCapability(cap)` - Filter models by capability
166
+ - `getProvider(id)` - Get provider configuration
167
+ - `getAllProviders()` - List all provider configs
168
+ - `isProviderConfigured(id)` - Check env var configuration
169
+ - `createProviderInstance(id, creds?)` - Create provider instance
170
+
171
+ ### Classes
172
+
173
+ - `ProviderRegistry` - Manage multiple provider instances
174
+
175
+ ## License
176
+
177
+ MIT
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @llm-utils/providers
3
+ * LLM provider registry with model metadata and capabilities
4
+ */
5
+ export type { ProviderId, ModelCapabilities, TokenPricing, ModelMetadata, ProviderConfig, ProviderCredentials, ProviderInstance, } from './types.js';
6
+ export { openaiModels, anthropicModels, googleModels, mistralModels, groqModels, deepseekModels, xaiModels, allModels, getModelsByProvider, getModelById, getModelsWithCapability, } from './models.js';
7
+ export { getProvider, getAllProviders, isProviderConfigured, getCredentialsFromEnv, createProviderInstance, ProviderRegistry, defaultRegistry, } from './registry.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @llm-utils/providers
3
+ * LLM provider registry with model metadata and capabilities
4
+ */
5
+ // Models
6
+ export { openaiModels, anthropicModels, googleModels, mistralModels, groqModels, deepseekModels, xaiModels, allModels, getModelsByProvider, getModelById, getModelsWithCapability, } from './models.js';
7
+ // Registry
8
+ export { getProvider, getAllProviders, isProviderConfigured, getCredentialsFromEnv, createProviderInstance, ProviderRegistry, defaultRegistry, } from './registry.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,SAAS;AACT,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,WAAW;AACX,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Model Definitions
3
+ * Comprehensive model metadata for major LLM providers
4
+ */
5
+ import type { ModelMetadata, ModelCapabilities } from './types.js';
6
+ /**
7
+ * OpenAI Models
8
+ */
9
+ export declare const openaiModels: ModelMetadata[];
10
+ /**
11
+ * Anthropic Models
12
+ */
13
+ export declare const anthropicModels: ModelMetadata[];
14
+ /**
15
+ * Google Models
16
+ */
17
+ export declare const googleModels: ModelMetadata[];
18
+ /**
19
+ * Mistral Models
20
+ */
21
+ export declare const mistralModels: ModelMetadata[];
22
+ /**
23
+ * Groq Models
24
+ */
25
+ export declare const groqModels: ModelMetadata[];
26
+ /**
27
+ * DeepSeek Models
28
+ */
29
+ export declare const deepseekModels: ModelMetadata[];
30
+ /**
31
+ * xAI Models
32
+ */
33
+ export declare const xaiModels: ModelMetadata[];
34
+ /**
35
+ * All models combined
36
+ */
37
+ export declare const allModels: ModelMetadata[];
38
+ /**
39
+ * Get models by provider
40
+ */
41
+ export declare function getModelsByProvider(provider: ModelMetadata['provider']): ModelMetadata[];
42
+ /**
43
+ * Get model by ID
44
+ */
45
+ export declare function getModelById(id: string): ModelMetadata | undefined;
46
+ /**
47
+ * Get models with specific capability
48
+ */
49
+ export declare function getModelsWithCapability(capability: keyof ModelCapabilities): ModelMetadata[];
50
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BnE;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,aAAa,EA0KvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,EA+F1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,aAAa,EA6EvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,EAgExC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,aAAa,EA+DrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,EAmCzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,aAAa,EAiCpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,aAAa,EAQpC,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,GAClC,aAAa,EAAE,CAEjB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAElE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,iBAAiB,GAClC,aAAa,EAAE,CAEjB"}