@clinebot/llms 0.0.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.
Files changed (219) hide show
  1. package/README.md +198 -0
  2. package/dist/config-browser.d.ts +3 -0
  3. package/dist/config.d.ts +3 -0
  4. package/dist/index.browser.d.ts +4 -0
  5. package/dist/index.browser.js +1 -0
  6. package/dist/index.d.ts +5 -0
  7. package/dist/index.js +7 -0
  8. package/dist/models/generated-access.d.ts +4 -0
  9. package/dist/models/generated-provider-loaders.d.ts +13 -0
  10. package/dist/models/generated.d.ts +14 -0
  11. package/dist/models/index.d.ts +43 -0
  12. package/dist/models/models-dev-catalog.d.ts +32 -0
  13. package/dist/models/providers/aihubmix.d.ts +5 -0
  14. package/dist/models/providers/anthropic.d.ts +53 -0
  15. package/dist/models/providers/asksage.d.ts +5 -0
  16. package/dist/models/providers/baseten.d.ts +5 -0
  17. package/dist/models/providers/bedrock.d.ts +7 -0
  18. package/dist/models/providers/cerebras.d.ts +7 -0
  19. package/dist/models/providers/claude-code.d.ts +4 -0
  20. package/dist/models/providers/cline.d.ts +34 -0
  21. package/dist/models/providers/deepseek.d.ts +8 -0
  22. package/dist/models/providers/dify.d.ts +5 -0
  23. package/dist/models/providers/doubao.d.ts +7 -0
  24. package/dist/models/providers/fireworks.d.ts +8 -0
  25. package/dist/models/providers/gemini.d.ts +9 -0
  26. package/dist/models/providers/groq.d.ts +8 -0
  27. package/dist/models/providers/hicap.d.ts +5 -0
  28. package/dist/models/providers/huawei-cloud-maas.d.ts +5 -0
  29. package/dist/models/providers/huggingface.d.ts +6 -0
  30. package/dist/models/providers/index.d.ts +45 -0
  31. package/dist/models/providers/litellm.d.ts +5 -0
  32. package/dist/models/providers/lmstudio.d.ts +5 -0
  33. package/dist/models/providers/minimax.d.ts +7 -0
  34. package/dist/models/providers/mistral.d.ts +5 -0
  35. package/dist/models/providers/moonshot.d.ts +7 -0
  36. package/dist/models/providers/nebius.d.ts +7 -0
  37. package/dist/models/providers/nous-research.d.ts +7 -0
  38. package/dist/models/providers/oca.d.ts +9 -0
  39. package/dist/models/providers/ollama.d.ts +5 -0
  40. package/dist/models/providers/openai-codex.d.ts +10 -0
  41. package/dist/models/providers/openai.d.ts +9 -0
  42. package/dist/models/providers/opencode.d.ts +10 -0
  43. package/dist/models/providers/openrouter.d.ts +7 -0
  44. package/dist/models/providers/qwen-code.d.ts +7 -0
  45. package/dist/models/providers/qwen.d.ts +7 -0
  46. package/dist/models/providers/requesty.d.ts +6 -0
  47. package/dist/models/providers/sambanova.d.ts +7 -0
  48. package/dist/models/providers/sapaicore.d.ts +7 -0
  49. package/dist/models/providers/together.d.ts +8 -0
  50. package/dist/models/providers/vercel-ai-gateway.d.ts +5 -0
  51. package/dist/models/providers/vertex.d.ts +7 -0
  52. package/dist/models/providers/xai.d.ts +8 -0
  53. package/dist/models/providers/zai.d.ts +7 -0
  54. package/dist/models/query.d.ts +181 -0
  55. package/dist/models/registry.d.ts +123 -0
  56. package/dist/models/schemas/index.d.ts +7 -0
  57. package/dist/models/schemas/model.d.ts +340 -0
  58. package/dist/models/schemas/query.d.ts +191 -0
  59. package/dist/providers/handlers/ai-sdk-community.d.ts +46 -0
  60. package/dist/providers/handlers/ai-sdk-provider-base.d.ts +32 -0
  61. package/dist/providers/handlers/anthropic-base.d.ts +26 -0
  62. package/dist/providers/handlers/asksage.d.ts +12 -0
  63. package/dist/providers/handlers/auth.d.ts +5 -0
  64. package/dist/providers/handlers/base.d.ts +55 -0
  65. package/dist/providers/handlers/bedrock-base.d.ts +23 -0
  66. package/dist/providers/handlers/bedrock-client.d.ts +4 -0
  67. package/dist/providers/handlers/community-sdk.d.ts +97 -0
  68. package/dist/providers/handlers/fetch-base.d.ts +18 -0
  69. package/dist/providers/handlers/gemini-base.d.ts +25 -0
  70. package/dist/providers/handlers/index.d.ts +19 -0
  71. package/dist/providers/handlers/openai-base.d.ts +54 -0
  72. package/dist/providers/handlers/openai-responses.d.ts +64 -0
  73. package/dist/providers/handlers/providers.d.ts +43 -0
  74. package/dist/providers/handlers/r1-base.d.ts +62 -0
  75. package/dist/providers/handlers/registry.d.ts +106 -0
  76. package/dist/providers/handlers/vertex.d.ts +32 -0
  77. package/dist/providers/index.d.ts +100 -0
  78. package/dist/providers/public.browser.d.ts +2 -0
  79. package/dist/providers/public.d.ts +3 -0
  80. package/dist/providers/shared/openai-compatible.d.ts +10 -0
  81. package/dist/providers/transform/ai-sdk-community-format.d.ts +9 -0
  82. package/dist/providers/transform/anthropic-format.d.ts +24 -0
  83. package/dist/providers/transform/content-format.d.ts +3 -0
  84. package/dist/providers/transform/gemini-format.d.ts +19 -0
  85. package/dist/providers/transform/index.d.ts +10 -0
  86. package/dist/providers/transform/openai-format.d.ts +36 -0
  87. package/dist/providers/transform/r1-format.d.ts +26 -0
  88. package/dist/providers/types/config.d.ts +261 -0
  89. package/dist/providers/types/handler.d.ts +71 -0
  90. package/dist/providers/types/index.d.ts +11 -0
  91. package/dist/providers/types/messages.d.ts +139 -0
  92. package/dist/providers/types/model-info.d.ts +32 -0
  93. package/dist/providers/types/provider-ids.d.ts +63 -0
  94. package/dist/providers/types/settings.d.ts +308 -0
  95. package/dist/providers/types/stream.d.ts +106 -0
  96. package/dist/providers/utils/index.d.ts +7 -0
  97. package/dist/providers/utils/retry.d.ts +38 -0
  98. package/dist/providers/utils/stream-processor.d.ts +110 -0
  99. package/dist/providers/utils/tool-processor.d.ts +34 -0
  100. package/dist/sdk.d.ts +18 -0
  101. package/dist/types.d.ts +60 -0
  102. package/package.json +66 -0
  103. package/src/catalog.ts +20 -0
  104. package/src/config-browser.ts +11 -0
  105. package/src/config.ts +49 -0
  106. package/src/index.browser.ts +9 -0
  107. package/src/index.ts +10 -0
  108. package/src/live-providers.test.ts +137 -0
  109. package/src/models/generated-access.ts +41 -0
  110. package/src/models/generated-provider-loaders.ts +166 -0
  111. package/src/models/generated.ts +11997 -0
  112. package/src/models/index.ts +271 -0
  113. package/src/models/models-dev-catalog.test.ts +161 -0
  114. package/src/models/models-dev-catalog.ts +161 -0
  115. package/src/models/providers/aihubmix.ts +19 -0
  116. package/src/models/providers/anthropic.ts +60 -0
  117. package/src/models/providers/asksage.ts +19 -0
  118. package/src/models/providers/baseten.ts +21 -0
  119. package/src/models/providers/bedrock.ts +30 -0
  120. package/src/models/providers/cerebras.ts +24 -0
  121. package/src/models/providers/claude-code.ts +51 -0
  122. package/src/models/providers/cline.ts +25 -0
  123. package/src/models/providers/deepseek.ts +33 -0
  124. package/src/models/providers/dify.ts +17 -0
  125. package/src/models/providers/doubao.ts +33 -0
  126. package/src/models/providers/fireworks.ts +34 -0
  127. package/src/models/providers/gemini.ts +43 -0
  128. package/src/models/providers/groq.ts +33 -0
  129. package/src/models/providers/hicap.ts +18 -0
  130. package/src/models/providers/huawei-cloud-maas.ts +18 -0
  131. package/src/models/providers/huggingface.ts +22 -0
  132. package/src/models/providers/index.ts +162 -0
  133. package/src/models/providers/litellm.ts +19 -0
  134. package/src/models/providers/lmstudio.ts +22 -0
  135. package/src/models/providers/minimax.ts +34 -0
  136. package/src/models/providers/mistral.ts +19 -0
  137. package/src/models/providers/moonshot.ts +34 -0
  138. package/src/models/providers/nebius.ts +24 -0
  139. package/src/models/providers/nous-research.ts +21 -0
  140. package/src/models/providers/oca.ts +30 -0
  141. package/src/models/providers/ollama.ts +18 -0
  142. package/src/models/providers/openai-codex.ts +30 -0
  143. package/src/models/providers/openai.ts +43 -0
  144. package/src/models/providers/opencode.ts +28 -0
  145. package/src/models/providers/openrouter.ts +24 -0
  146. package/src/models/providers/qwen-code.ts +33 -0
  147. package/src/models/providers/qwen.ts +34 -0
  148. package/src/models/providers/requesty.ts +23 -0
  149. package/src/models/providers/sambanova.ts +23 -0
  150. package/src/models/providers/sapaicore.ts +34 -0
  151. package/src/models/providers/together.ts +35 -0
  152. package/src/models/providers/vercel-ai-gateway.ts +23 -0
  153. package/src/models/providers/vertex.ts +36 -0
  154. package/src/models/providers/xai.ts +34 -0
  155. package/src/models/providers/zai.ts +25 -0
  156. package/src/models/query.ts +407 -0
  157. package/src/models/registry.ts +511 -0
  158. package/src/models/schemas/index.ts +62 -0
  159. package/src/models/schemas/model.ts +308 -0
  160. package/src/models/schemas/query.ts +336 -0
  161. package/src/providers/browser.ts +4 -0
  162. package/src/providers/handlers/ai-sdk-community.ts +226 -0
  163. package/src/providers/handlers/ai-sdk-provider-base.ts +193 -0
  164. package/src/providers/handlers/anthropic-base.ts +372 -0
  165. package/src/providers/handlers/asksage.test.ts +103 -0
  166. package/src/providers/handlers/asksage.ts +138 -0
  167. package/src/providers/handlers/auth.test.ts +19 -0
  168. package/src/providers/handlers/auth.ts +121 -0
  169. package/src/providers/handlers/base.test.ts +46 -0
  170. package/src/providers/handlers/base.ts +160 -0
  171. package/src/providers/handlers/bedrock-base.ts +390 -0
  172. package/src/providers/handlers/bedrock-client.ts +100 -0
  173. package/src/providers/handlers/codex.test.ts +123 -0
  174. package/src/providers/handlers/community-sdk.test.ts +288 -0
  175. package/src/providers/handlers/community-sdk.ts +392 -0
  176. package/src/providers/handlers/fetch-base.ts +68 -0
  177. package/src/providers/handlers/gemini-base.ts +302 -0
  178. package/src/providers/handlers/index.ts +67 -0
  179. package/src/providers/handlers/openai-base.ts +277 -0
  180. package/src/providers/handlers/openai-responses.ts +598 -0
  181. package/src/providers/handlers/providers.test.ts +120 -0
  182. package/src/providers/handlers/providers.ts +563 -0
  183. package/src/providers/handlers/r1-base.ts +280 -0
  184. package/src/providers/handlers/registry.ts +185 -0
  185. package/src/providers/handlers/vertex.test.ts +124 -0
  186. package/src/providers/handlers/vertex.ts +292 -0
  187. package/src/providers/index.ts +534 -0
  188. package/src/providers/public.browser.ts +20 -0
  189. package/src/providers/public.ts +51 -0
  190. package/src/providers/shared/openai-compatible.ts +63 -0
  191. package/src/providers/transform/ai-sdk-community-format.test.ts +73 -0
  192. package/src/providers/transform/ai-sdk-community-format.ts +115 -0
  193. package/src/providers/transform/anthropic-format.ts +218 -0
  194. package/src/providers/transform/content-format.ts +34 -0
  195. package/src/providers/transform/format-conversion.test.ts +310 -0
  196. package/src/providers/transform/gemini-format.ts +167 -0
  197. package/src/providers/transform/index.ts +22 -0
  198. package/src/providers/transform/openai-format.ts +247 -0
  199. package/src/providers/transform/r1-format.ts +287 -0
  200. package/src/providers/types/config.ts +388 -0
  201. package/src/providers/types/handler.ts +87 -0
  202. package/src/providers/types/index.ts +120 -0
  203. package/src/providers/types/messages.ts +158 -0
  204. package/src/providers/types/model-info.test.ts +57 -0
  205. package/src/providers/types/model-info.ts +65 -0
  206. package/src/providers/types/provider-ids.test.ts +12 -0
  207. package/src/providers/types/provider-ids.ts +89 -0
  208. package/src/providers/types/settings.test.ts +49 -0
  209. package/src/providers/types/settings.ts +533 -0
  210. package/src/providers/types/stream.ts +117 -0
  211. package/src/providers/utils/index.ts +27 -0
  212. package/src/providers/utils/retry.test.ts +140 -0
  213. package/src/providers/utils/retry.ts +188 -0
  214. package/src/providers/utils/stream-processor.test.ts +232 -0
  215. package/src/providers/utils/stream-processor.ts +472 -0
  216. package/src/providers/utils/tool-processor.test.ts +34 -0
  217. package/src/providers/utils/tool-processor.ts +111 -0
  218. package/src/sdk.ts +264 -0
  219. package/src/types.ts +79 -0
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Model Query API
3
+ *
4
+ * High-level API for querying and filtering models across all providers.
5
+ * Uses the registry and schema validation for type-safe queries.
6
+ */
7
+ import { type ModelMatch, type ModelQueryConfig } from "./schemas/index";
8
+ /**
9
+ * Query models using a configuration object
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Get all models with image support
14
+ * const imageModels = queryModels({
15
+ * capabilities: ["images"],
16
+ * })
17
+ *
18
+ * // Get cheap reasoning models
19
+ * const cheapReasoning = queryModels({
20
+ * capabilities: ["reasoning"],
21
+ * maxInputPrice: 1,
22
+ * sortBy: "inputPrice",
23
+ * })
24
+ *
25
+ * // Get Anthropic and OpenAI models
26
+ * const models = queryModels({
27
+ * providers: ["anthropic", "openai"],
28
+ * includeDeprecated: false,
29
+ * })
30
+ * ```
31
+ */
32
+ export declare function queryModels(config: ModelQueryConfig): ModelMatch[];
33
+ /**
34
+ * Get all models with vision/image capabilities
35
+ */
36
+ export declare function getVisionModels(): ModelMatch[];
37
+ /**
38
+ * Get all models with reasoning/thinking capabilities
39
+ */
40
+ export declare function getReasoningModels(): ModelMatch[];
41
+ /**
42
+ * Get all models with prompt caching support
43
+ */
44
+ export declare function getCachingModels(): ModelMatch[];
45
+ /**
46
+ * Get all models with tool/function calling support
47
+ */
48
+ export declare function getToolModels(): ModelMatch[];
49
+ /**
50
+ * Get all models supporting computer use
51
+ */
52
+ export declare function getComputerUseModels(): ModelMatch[];
53
+ /**
54
+ * Get all active (non-deprecated) models
55
+ */
56
+ export declare function getActiveModels(): ModelMatch[];
57
+ /**
58
+ * Get all deprecated models
59
+ */
60
+ export declare function getDeprecatedModels(): ModelMatch[];
61
+ /**
62
+ * Get models within a price range (input price per million tokens)
63
+ */
64
+ export declare function getModelsInPriceRange(maxInputPrice: number, maxOutputPrice?: number): ModelMatch[];
65
+ /**
66
+ * Get models with minimum context window size
67
+ */
68
+ export declare function getModelsWithContextWindow(minTokens: number): ModelMatch[];
69
+ /**
70
+ * Get models by provider
71
+ */
72
+ export declare function getModelsByProvider(providerId: string): ModelMatch[];
73
+ /**
74
+ * Search models by name or ID
75
+ */
76
+ export declare function searchModels(searchTerm: string): ModelMatch[];
77
+ /**
78
+ * Fluent query builder for constructing model queries
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const models = createQuery()
83
+ * .fromProviders(["anthropic", "openai"])
84
+ * .withCapabilities(["images", "reasoning"])
85
+ * .maxPrice({ input: 5 })
86
+ * .sortBy("inputPrice")
87
+ * .limit(10)
88
+ * .execute()
89
+ * ```
90
+ */
91
+ export declare class ModelQueryBuilder {
92
+ private config;
93
+ /**
94
+ * Filter by provider IDs
95
+ */
96
+ fromProviders(providers: string[]): this;
97
+ /**
98
+ * Require all specified capabilities
99
+ */
100
+ withCapabilities(capabilities: ModelQueryConfig["capabilities"]): this;
101
+ /**
102
+ * Require at least one of the specified capabilities
103
+ */
104
+ withAnyCapabilities(capabilities: ModelQueryConfig["anyCapabilities"]): this;
105
+ /**
106
+ * Exclude models with specified capabilities
107
+ */
108
+ excludeCapabilities(capabilities: ModelQueryConfig["excludeCapabilities"]): this;
109
+ /**
110
+ * Filter by model status
111
+ */
112
+ withStatus(status: ModelQueryConfig["status"]): this;
113
+ /**
114
+ * Include deprecated models
115
+ */
116
+ includeDeprecated(include?: boolean): this;
117
+ /**
118
+ * Filter by API format
119
+ */
120
+ withApiFormat(format: ModelQueryConfig["apiFormat"]): this;
121
+ /**
122
+ * Filter by context window size
123
+ */
124
+ contextWindow(options: {
125
+ min?: number;
126
+ max?: number;
127
+ }): this;
128
+ /**
129
+ * Filter by minimum output tokens
130
+ */
131
+ minMaxTokens(tokens: number): this;
132
+ /**
133
+ * Filter by maximum price
134
+ */
135
+ maxPrice(options: {
136
+ input?: number;
137
+ output?: number;
138
+ }): this;
139
+ /**
140
+ * Search by name or ID
141
+ */
142
+ search(term: string): this;
143
+ /**
144
+ * Filter by thinking/reasoning support
145
+ */
146
+ hasThinking(has?: boolean): this;
147
+ /**
148
+ * Sort results
149
+ */
150
+ sortBy(field: ModelQueryConfig["sortBy"], direction?: ModelQueryConfig["sortDirection"]): this;
151
+ /**
152
+ * Limit number of results
153
+ */
154
+ limit(count: number): this;
155
+ /**
156
+ * Get the current config
157
+ */
158
+ getConfig(): ModelQueryConfig;
159
+ /**
160
+ * Execute the query
161
+ */
162
+ execute(): ModelMatch[];
163
+ }
164
+ /**
165
+ * Create a new query builder
166
+ */
167
+ export declare function createQuery(): ModelQueryBuilder;
168
+ /**
169
+ * Get statistics about registered models
170
+ */
171
+ export declare function getModelStatistics(): Promise<{
172
+ totalModels: number;
173
+ modelsByProvider: Record<string, number>;
174
+ modelsByCapability: Record<string, number>;
175
+ modelsByStatus: Record<string, number>;
176
+ priceRange: {
177
+ min: number;
178
+ max: number;
179
+ avg: number;
180
+ };
181
+ }>;
@@ -0,0 +1,123 @@
1
+ import type { ModelCollection, ModelInfo, ProviderInfo } from "./schemas/index";
2
+ /**
3
+ * Get all registered provider IDs (does not load providers)
4
+ */
5
+ export declare function getProviderIds(): string[];
6
+ /**
7
+ * Check if a provider is registered (does not load it)
8
+ */
9
+ export declare function hasProvider(providerId: string): boolean;
10
+ /**
11
+ * Get provider by ID (async - loads if needed)
12
+ */
13
+ export declare function getProvider(providerId: string): Promise<ProviderInfo | undefined>;
14
+ /**
15
+ * Get provider collection by ID (async - loads if needed)
16
+ */
17
+ export declare function getProviderCollection(providerId: string): Promise<ModelCollection | undefined>;
18
+ /**
19
+ * Get all providers (async - loads all providers)
20
+ */
21
+ export declare function getAllProviders(): Promise<ProviderInfo[]>;
22
+ /**
23
+ * Preload specific providers into cache
24
+ */
25
+ export declare function preloadProviders(providerIds: string[]): Promise<void>;
26
+ /**
27
+ * Preload all providers into cache
28
+ */
29
+ export declare function preloadAllProviders(): Promise<void>;
30
+ /**
31
+ * Get provider from cache (sync) - returns undefined if not loaded yet
32
+ * Use this when you know the provider has been preloaded
33
+ */
34
+ export declare function getProviderSync(providerId: string): ProviderInfo | undefined;
35
+ /**
36
+ * Get provider collection from cache (sync) - returns undefined if not loaded yet
37
+ * Use this when you know the provider has been preloaded
38
+ */
39
+ export declare function getProviderCollectionSync(providerId: string): ModelCollection | undefined;
40
+ /**
41
+ * Get all loaded providers (sync) - only returns already-loaded providers
42
+ */
43
+ export declare function getLoadedProviders(): ProviderInfo[];
44
+ /**
45
+ * Check if a provider is loaded in cache
46
+ */
47
+ export declare function isProviderLoaded(providerId: string): boolean;
48
+ /**
49
+ * Get all models for a provider (async - loads provider if needed)
50
+ */
51
+ export declare function getModelsForProvider(providerId: string): Promise<Record<string, ModelInfo>>;
52
+ /**
53
+ * Get a specific model by provider and model ID (async)
54
+ */
55
+ export declare function getModel(providerId: string, modelId: string): Promise<ModelInfo | undefined>;
56
+ /**
57
+ * Get the default model for a provider (async)
58
+ */
59
+ export declare function getDefaultModel(providerId: string): Promise<{
60
+ id: string;
61
+ info: ModelInfo;
62
+ } | undefined>;
63
+ /**
64
+ * Get all models across all providers (async - loads all providers)
65
+ */
66
+ export declare function getAllModels(): Promise<Array<{
67
+ providerId: string;
68
+ modelId: string;
69
+ info: ModelInfo;
70
+ }>>;
71
+ /**
72
+ * Get total count of registered models (async - loads all providers)
73
+ */
74
+ export declare function getModelCount(): Promise<number>;
75
+ /**
76
+ * Get models for an already-loaded provider (sync)
77
+ * Returns empty object if provider is not loaded
78
+ */
79
+ export declare function getModelsForProviderSync(providerId: string): Record<string, ModelInfo>;
80
+ /**
81
+ * Get a specific model from an already-loaded provider (sync)
82
+ */
83
+ export declare function getModelSync(providerId: string, modelId: string): ModelInfo | undefined;
84
+ /**
85
+ * Register a custom provider (immediately available, not lazy loaded)
86
+ */
87
+ export declare function registerProvider(collection: ModelCollection): void;
88
+ /**
89
+ * Register a custom model for a provider
90
+ */
91
+ export declare function registerModel(providerId: string, modelId: string, info: ModelInfo): void;
92
+ /**
93
+ * Unregister a custom model
94
+ */
95
+ export declare function unregisterModel(providerId: string, modelId: string): boolean;
96
+ /**
97
+ * Unregister a provider
98
+ */
99
+ export declare function unregisterProvider(providerId: string): boolean;
100
+ /**
101
+ * Clear all custom models (keeps built-in)
102
+ */
103
+ export declare function clearCustomModels(): void;
104
+ /**
105
+ * Reset registry to initial state (clears cache, keeps loaders)
106
+ */
107
+ export declare function resetRegistry(): void;
108
+ /**
109
+ * Register multiple models at once
110
+ */
111
+ export declare function registerModels(providerId: string, models: Record<string, ModelInfo>): void;
112
+ /**
113
+ * Update model info (merges with existing) - async
114
+ */
115
+ export declare function updateModel(providerId: string, modelId: string, updates: Partial<ModelInfo>): Promise<ModelInfo | undefined>;
116
+ /**
117
+ * Mark a model as deprecated - async
118
+ */
119
+ export declare function deprecateModel(providerId: string, modelId: string, options?: {
120
+ notice?: string;
121
+ replacedBy?: string;
122
+ deprecationDate?: string;
123
+ }): Promise<ModelInfo | undefined>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Schema Exports
3
+ *
4
+ * Re-exports all Zod schemas and types for model definitions.
5
+ */
6
+ export { ApiFormat, type ApiFormat as ApiFormatType, ApiFormatSchema, getPricing, hasCapability, isActive, isDeprecated, type ModelCapability, ModelCapabilitySchema, type ModelCollection, ModelCollectionSchema, type ModelEntry, ModelEntrySchema, type ModelInfo, ModelInfoSchema, type ModelPricing, ModelPricingSchema, type ModelStatus, ModelStatusSchema, type ProviderCapability, ProviderCapabilitySchema, type ProviderInfo, ProviderInfoSchema, type ProviderProtocol, ProviderProtocolSchema, safeValidateModelInfo, type ThinkingConfig, ThinkingConfigSchema, validateModelInfo, } from "./model";
7
+ export { type ModelMatch, type ModelQueryConfig, ModelQueryConfigSchema, type ModelQueryResult, ModelQueryResultSchema, matchesQuery, safeValidateQueryConfig, sortModels, validateQueryConfig, } from "./query";
@@ -0,0 +1,340 @@
1
+ /**
2
+ * Model Schema Definitions
3
+ *
4
+ * Zod schemas for validating model information, capabilities, and pricing.
5
+ * These schemas are the source of truth for all model type definitions.
6
+ */
7
+ import { z } from "zod";
8
+ /**
9
+ * API format variants for different provider protocols
10
+ */
11
+ export declare const ApiFormatSchema: z.ZodEnum<{
12
+ default: "default";
13
+ "openai-responses": "openai-responses";
14
+ r1: "r1";
15
+ }>;
16
+ export type ApiFormat = z.infer<typeof ApiFormatSchema>;
17
+ export declare const ApiFormat: {
18
+ readonly DEFAULT: "default";
19
+ readonly OPENAI_RESPONSES: "openai-responses";
20
+ readonly R1: "r1";
21
+ };
22
+ /**
23
+ * Capabilities a model may support
24
+ */
25
+ export declare const ModelCapabilitySchema: z.ZodEnum<{
26
+ images: "images";
27
+ tools: "tools";
28
+ streaming: "streaming";
29
+ "prompt-cache": "prompt-cache";
30
+ reasoning: "reasoning";
31
+ "reasoning-effort": "reasoning-effort";
32
+ "computer-use": "computer-use";
33
+ "global-endpoint": "global-endpoint";
34
+ structured_output: "structured_output";
35
+ temperature: "temperature";
36
+ files: "files";
37
+ }>;
38
+ export type ModelCapability = z.infer<typeof ModelCapabilitySchema>;
39
+ /**
40
+ * Model lifecycle status
41
+ */
42
+ export declare const ModelStatusSchema: z.ZodEnum<{
43
+ active: "active";
44
+ preview: "preview";
45
+ deprecated: "deprecated";
46
+ legacy: "legacy";
47
+ }>;
48
+ export type ModelStatus = z.infer<typeof ModelStatusSchema>;
49
+ /**
50
+ * Token pricing configuration (per million tokens)
51
+ */
52
+ export declare const ModelPricingSchema: z.ZodObject<{
53
+ input: z.ZodOptional<z.ZodNumber>;
54
+ output: z.ZodOptional<z.ZodNumber>;
55
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
56
+ cacheRead: z.ZodOptional<z.ZodNumber>;
57
+ }, z.core.$strip>;
58
+ export type ModelPricing = z.infer<typeof ModelPricingSchema>;
59
+ /**
60
+ * Configuration for models with thinking/reasoning capabilities
61
+ */
62
+ export declare const ThinkingConfigSchema: z.ZodObject<{
63
+ maxBudget: z.ZodOptional<z.ZodNumber>;
64
+ outputPrice: z.ZodOptional<z.ZodNumber>;
65
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
66
+ low: "low";
67
+ high: "high";
68
+ }>>;
69
+ }, z.core.$strip>;
70
+ export type ThinkingConfig = z.infer<typeof ThinkingConfigSchema>;
71
+ /**
72
+ * Complete model information schema
73
+ */
74
+ export declare const ModelInfoSchema: z.ZodObject<{
75
+ id: z.ZodString;
76
+ name: z.ZodOptional<z.ZodString>;
77
+ description: z.ZodOptional<z.ZodString>;
78
+ maxTokens: z.ZodOptional<z.ZodNumber>;
79
+ contextWindow: z.ZodOptional<z.ZodNumber>;
80
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
81
+ images: "images";
82
+ tools: "tools";
83
+ streaming: "streaming";
84
+ "prompt-cache": "prompt-cache";
85
+ reasoning: "reasoning";
86
+ "reasoning-effort": "reasoning-effort";
87
+ "computer-use": "computer-use";
88
+ "global-endpoint": "global-endpoint";
89
+ structured_output: "structured_output";
90
+ temperature: "temperature";
91
+ files: "files";
92
+ }>>>;
93
+ apiFormat: z.ZodOptional<z.ZodEnum<{
94
+ default: "default";
95
+ "openai-responses": "openai-responses";
96
+ r1: "r1";
97
+ }>>;
98
+ systemRole: z.ZodOptional<z.ZodEnum<{
99
+ system: "system";
100
+ developer: "developer";
101
+ }>>;
102
+ temperature: z.ZodOptional<z.ZodNumber>;
103
+ pricing: z.ZodOptional<z.ZodObject<{
104
+ input: z.ZodOptional<z.ZodNumber>;
105
+ output: z.ZodOptional<z.ZodNumber>;
106
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
107
+ cacheRead: z.ZodOptional<z.ZodNumber>;
108
+ }, z.core.$strip>>;
109
+ thinkingConfig: z.ZodOptional<z.ZodObject<{
110
+ maxBudget: z.ZodOptional<z.ZodNumber>;
111
+ outputPrice: z.ZodOptional<z.ZodNumber>;
112
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
113
+ low: "low";
114
+ high: "high";
115
+ }>>;
116
+ }, z.core.$strip>>;
117
+ status: z.ZodOptional<z.ZodEnum<{
118
+ active: "active";
119
+ preview: "preview";
120
+ deprecated: "deprecated";
121
+ legacy: "legacy";
122
+ }>>;
123
+ deprecationNotice: z.ZodOptional<z.ZodString>;
124
+ replacedBy: z.ZodOptional<z.ZodString>;
125
+ releaseDate: z.ZodOptional<z.ZodString>;
126
+ deprecationDate: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strip>;
128
+ export type ModelInfo = z.infer<typeof ModelInfoSchema>;
129
+ /**
130
+ * A model entry with its ID and info
131
+ */
132
+ export declare const ModelEntrySchema: z.ZodObject<{
133
+ id: z.ZodString;
134
+ info: z.ZodObject<{
135
+ id: z.ZodString;
136
+ name: z.ZodOptional<z.ZodString>;
137
+ description: z.ZodOptional<z.ZodString>;
138
+ maxTokens: z.ZodOptional<z.ZodNumber>;
139
+ contextWindow: z.ZodOptional<z.ZodNumber>;
140
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
141
+ images: "images";
142
+ tools: "tools";
143
+ streaming: "streaming";
144
+ "prompt-cache": "prompt-cache";
145
+ reasoning: "reasoning";
146
+ "reasoning-effort": "reasoning-effort";
147
+ "computer-use": "computer-use";
148
+ "global-endpoint": "global-endpoint";
149
+ structured_output: "structured_output";
150
+ temperature: "temperature";
151
+ files: "files";
152
+ }>>>;
153
+ apiFormat: z.ZodOptional<z.ZodEnum<{
154
+ default: "default";
155
+ "openai-responses": "openai-responses";
156
+ r1: "r1";
157
+ }>>;
158
+ systemRole: z.ZodOptional<z.ZodEnum<{
159
+ system: "system";
160
+ developer: "developer";
161
+ }>>;
162
+ temperature: z.ZodOptional<z.ZodNumber>;
163
+ pricing: z.ZodOptional<z.ZodObject<{
164
+ input: z.ZodOptional<z.ZodNumber>;
165
+ output: z.ZodOptional<z.ZodNumber>;
166
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
167
+ cacheRead: z.ZodOptional<z.ZodNumber>;
168
+ }, z.core.$strip>>;
169
+ thinkingConfig: z.ZodOptional<z.ZodObject<{
170
+ maxBudget: z.ZodOptional<z.ZodNumber>;
171
+ outputPrice: z.ZodOptional<z.ZodNumber>;
172
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
173
+ low: "low";
174
+ high: "high";
175
+ }>>;
176
+ }, z.core.$strip>>;
177
+ status: z.ZodOptional<z.ZodEnum<{
178
+ active: "active";
179
+ preview: "preview";
180
+ deprecated: "deprecated";
181
+ legacy: "legacy";
182
+ }>>;
183
+ deprecationNotice: z.ZodOptional<z.ZodString>;
184
+ replacedBy: z.ZodOptional<z.ZodString>;
185
+ releaseDate: z.ZodOptional<z.ZodString>;
186
+ deprecationDate: z.ZodOptional<z.ZodString>;
187
+ }, z.core.$strip>;
188
+ }, z.core.$strip>;
189
+ export type ModelEntry = z.infer<typeof ModelEntrySchema>;
190
+ /**
191
+ * Provider capability (applies to all models from this provider)
192
+ */
193
+ export declare const ProviderCapabilitySchema: z.ZodEnum<{
194
+ tools: "tools";
195
+ "prompt-cache": "prompt-cache";
196
+ reasoning: "reasoning";
197
+ oauth: "oauth";
198
+ }>;
199
+ export type ProviderCapability = z.infer<typeof ProviderCapabilitySchema>;
200
+ /**
201
+ * Provider protocol/transport family
202
+ */
203
+ export declare const ProviderProtocolSchema: z.ZodEnum<{
204
+ "openai-responses": "openai-responses";
205
+ anthropic: "anthropic";
206
+ gemini: "gemini";
207
+ "openai-chat": "openai-chat";
208
+ "openai-r1": "openai-r1";
209
+ }>;
210
+ export type ProviderProtocol = z.infer<typeof ProviderProtocolSchema>;
211
+ /**
212
+ * Provider configuration
213
+ */
214
+ export declare const ProviderInfoSchema: z.ZodObject<{
215
+ id: z.ZodString;
216
+ name: z.ZodString;
217
+ description: z.ZodOptional<z.ZodString>;
218
+ protocol: z.ZodOptional<z.ZodEnum<{
219
+ "openai-responses": "openai-responses";
220
+ anthropic: "anthropic";
221
+ gemini: "gemini";
222
+ "openai-chat": "openai-chat";
223
+ "openai-r1": "openai-r1";
224
+ }>>;
225
+ baseUrl: z.ZodOptional<z.ZodString>;
226
+ defaultModelId: z.ZodString;
227
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
228
+ tools: "tools";
229
+ "prompt-cache": "prompt-cache";
230
+ reasoning: "reasoning";
231
+ oauth: "oauth";
232
+ }>>>;
233
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
234
+ }, z.core.$strip>;
235
+ export type ProviderInfo = z.infer<typeof ProviderInfoSchema>;
236
+ /**
237
+ * A collection of models from a provider
238
+ */
239
+ export declare const ModelCollectionSchema: z.ZodObject<{
240
+ provider: z.ZodObject<{
241
+ id: z.ZodString;
242
+ name: z.ZodString;
243
+ description: z.ZodOptional<z.ZodString>;
244
+ protocol: z.ZodOptional<z.ZodEnum<{
245
+ "openai-responses": "openai-responses";
246
+ anthropic: "anthropic";
247
+ gemini: "gemini";
248
+ "openai-chat": "openai-chat";
249
+ "openai-r1": "openai-r1";
250
+ }>>;
251
+ baseUrl: z.ZodOptional<z.ZodString>;
252
+ defaultModelId: z.ZodString;
253
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
254
+ tools: "tools";
255
+ "prompt-cache": "prompt-cache";
256
+ reasoning: "reasoning";
257
+ oauth: "oauth";
258
+ }>>>;
259
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
260
+ }, z.core.$strip>;
261
+ models: z.ZodRecord<z.ZodString, z.ZodObject<{
262
+ id: z.ZodString;
263
+ name: z.ZodOptional<z.ZodString>;
264
+ description: z.ZodOptional<z.ZodString>;
265
+ maxTokens: z.ZodOptional<z.ZodNumber>;
266
+ contextWindow: z.ZodOptional<z.ZodNumber>;
267
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
268
+ images: "images";
269
+ tools: "tools";
270
+ streaming: "streaming";
271
+ "prompt-cache": "prompt-cache";
272
+ reasoning: "reasoning";
273
+ "reasoning-effort": "reasoning-effort";
274
+ "computer-use": "computer-use";
275
+ "global-endpoint": "global-endpoint";
276
+ structured_output: "structured_output";
277
+ temperature: "temperature";
278
+ files: "files";
279
+ }>>>;
280
+ apiFormat: z.ZodOptional<z.ZodEnum<{
281
+ default: "default";
282
+ "openai-responses": "openai-responses";
283
+ r1: "r1";
284
+ }>>;
285
+ systemRole: z.ZodOptional<z.ZodEnum<{
286
+ system: "system";
287
+ developer: "developer";
288
+ }>>;
289
+ temperature: z.ZodOptional<z.ZodNumber>;
290
+ pricing: z.ZodOptional<z.ZodObject<{
291
+ input: z.ZodOptional<z.ZodNumber>;
292
+ output: z.ZodOptional<z.ZodNumber>;
293
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
294
+ cacheRead: z.ZodOptional<z.ZodNumber>;
295
+ }, z.core.$strip>>;
296
+ thinkingConfig: z.ZodOptional<z.ZodObject<{
297
+ maxBudget: z.ZodOptional<z.ZodNumber>;
298
+ outputPrice: z.ZodOptional<z.ZodNumber>;
299
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
300
+ low: "low";
301
+ high: "high";
302
+ }>>;
303
+ }, z.core.$strip>>;
304
+ status: z.ZodOptional<z.ZodEnum<{
305
+ active: "active";
306
+ preview: "preview";
307
+ deprecated: "deprecated";
308
+ legacy: "legacy";
309
+ }>>;
310
+ deprecationNotice: z.ZodOptional<z.ZodString>;
311
+ replacedBy: z.ZodOptional<z.ZodString>;
312
+ releaseDate: z.ZodOptional<z.ZodString>;
313
+ deprecationDate: z.ZodOptional<z.ZodString>;
314
+ }, z.core.$strip>>;
315
+ }, z.core.$strip>;
316
+ export type ModelCollection = z.infer<typeof ModelCollectionSchema>;
317
+ /**
318
+ * Check if a model has a specific capability
319
+ */
320
+ export declare function hasCapability(info: ModelInfo, capability: ModelCapability): boolean;
321
+ /**
322
+ * Check if a model is deprecated
323
+ */
324
+ export declare function isDeprecated(info: ModelInfo): boolean;
325
+ /**
326
+ * Check if a model is active (not deprecated or legacy)
327
+ */
328
+ export declare function isActive(info: ModelInfo): boolean;
329
+ /**
330
+ * Get pricing for a model
331
+ */
332
+ export declare function getPricing(info: ModelInfo): ModelPricing;
333
+ /**
334
+ * Validate model info against schema
335
+ */
336
+ export declare function validateModelInfo(data: unknown): ModelInfo;
337
+ /**
338
+ * Safely validate model info (returns undefined on failure)
339
+ */
340
+ export declare function safeValidateModelInfo(data: unknown): ModelInfo | undefined;