@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,271 @@
1
+ /**
2
+ * @clinebot/models
3
+ *
4
+ * Model definitions and registry for all supported AI providers.
5
+ *
6
+ * This package provides:
7
+ * - Type-safe model definitions using Zod schemas
8
+ * - A central registry for accessing models across providers
9
+ * - Powerful query API for filtering models by capabilities, pricing, etc.
10
+ * - Support for custom models and runtime registration
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import {
15
+ * queryModels,
16
+ * createQuery,
17
+ * getModel,
18
+ * ANTHROPIC_MODELS,
19
+ * } from "@clinebot/models"
20
+ *
21
+ * // Get all models with vision support
22
+ * const visionModels = queryModels({
23
+ * capabilities: ["images"],
24
+ * })
25
+ *
26
+ * // Use fluent query builder
27
+ * const cheapModels = createQuery()
28
+ * .fromProviders(["anthropic", "openai"])
29
+ * .maxPrice({ input: 5 })
30
+ * .withCapabilities(["reasoning"])
31
+ * .execute()
32
+ *
33
+ * // Access specific model info
34
+ * const claude = getModel("anthropic", "claude-sonnet-4-20250514")
35
+ * ```
36
+ *
37
+ * @packageDocumentation
38
+ */
39
+
40
+ // =============================================================================
41
+ // Schema Exports (Types & Validation)
42
+ // =============================================================================
43
+
44
+ export {
45
+ // API Format
46
+ ApiFormat,
47
+ ApiFormatSchema,
48
+ type ApiFormatType,
49
+ getPricing,
50
+ // Model Helpers
51
+ hasCapability,
52
+ isActive,
53
+ isDeprecated,
54
+ type ModelCapability,
55
+ // Model Capabilities
56
+ ModelCapabilitySchema,
57
+ type ModelCollection,
58
+ ModelCollectionSchema,
59
+ type ModelEntry,
60
+ // Model Entry
61
+ ModelEntrySchema,
62
+ type ModelInfo,
63
+ // Model Info
64
+ ModelInfoSchema,
65
+ // Query Match
66
+ type ModelMatch,
67
+ type ModelPricing,
68
+ // Pricing
69
+ ModelPricingSchema,
70
+ type ModelQueryConfig,
71
+ // Query Config
72
+ ModelQueryConfigSchema,
73
+ type ModelQueryResult,
74
+ // Query Result
75
+ ModelQueryResultSchema,
76
+ type ModelStatus,
77
+ // Model Status
78
+ ModelStatusSchema,
79
+ // Query Helpers
80
+ matchesQuery,
81
+ type ProviderCapability,
82
+ // Provider
83
+ ProviderCapabilitySchema,
84
+ type ProviderInfo,
85
+ ProviderInfoSchema,
86
+ safeValidateModelInfo,
87
+ safeValidateQueryConfig,
88
+ sortModels,
89
+ type ThinkingConfig,
90
+ // Thinking Config
91
+ ThinkingConfigSchema,
92
+ validateModelInfo,
93
+ validateQueryConfig,
94
+ } from "./schemas/index";
95
+
96
+ // =============================================================================
97
+ // Registry Exports
98
+ // =============================================================================
99
+
100
+ export {
101
+ clearCustomModels,
102
+ deprecateModel,
103
+ getAllModels,
104
+ // Provider Access
105
+ getAllProviders,
106
+ getDefaultModel,
107
+ getModel,
108
+ getModelCount,
109
+ // Model Access
110
+ getModelsForProvider,
111
+ getProvider,
112
+ getProviderCollection,
113
+ getProviderIds,
114
+ hasProvider,
115
+ registerModel,
116
+ registerModels,
117
+ // Registration
118
+ registerProvider,
119
+ resetRegistry,
120
+ unregisterModel,
121
+ unregisterProvider,
122
+ // Updates
123
+ updateModel,
124
+ } from "./registry";
125
+
126
+ // =============================================================================
127
+ // Query API Exports
128
+ // =============================================================================
129
+
130
+ export {
131
+ createQuery,
132
+ getActiveModels,
133
+ getCachingModels,
134
+ getComputerUseModels,
135
+ getDeprecatedModels,
136
+ // Statistics
137
+ getModelStatistics,
138
+ getModelsByProvider,
139
+ getModelsInPriceRange,
140
+ getModelsWithContextWindow,
141
+ getReasoningModels,
142
+ getToolModels,
143
+ // Convenience Queries
144
+ getVisionModels,
145
+ // Query Builder
146
+ ModelQueryBuilder,
147
+ // Main Query Function
148
+ queryModels,
149
+ searchModels,
150
+ } from "./query";
151
+
152
+ // =============================================================================
153
+ // Generated Catalog Exports
154
+ // =============================================================================
155
+
156
+ export {
157
+ getGeneratedModelsForProvider,
158
+ getGeneratedModelsVersion,
159
+ getGeneratedProviderModels,
160
+ } from "./generated-access";
161
+
162
+ // =============================================================================
163
+ // Provider Model Exports
164
+ // =============================================================================
165
+
166
+ export {
167
+ AIHUBMIX_PROVIDER,
168
+ ANTHROPIC_DEFAULT_MODEL,
169
+ // Anthropic
170
+ ANTHROPIC_MODELS,
171
+ ANTHROPIC_PROVIDER,
172
+ ASKSAGE_PROVIDER,
173
+ // Other Providers
174
+ BASETEN_PROVIDER,
175
+ BEDROCK_DEFAULT_MODEL,
176
+ BEDROCK_MODELS,
177
+ BEDROCK_PROVIDER,
178
+ CEREBRAS_DEFAULT_MODEL,
179
+ // Cerebras
180
+ CEREBRAS_MODELS,
181
+ CEREBRAS_PROVIDER,
182
+ CLAUDE_CODE_DEFAULT_MODEL,
183
+ CLAUDE_CODE_MODELS,
184
+ CLAUDE_CODE_PROVIDER,
185
+ CLINE_DEFAULT_MODEL,
186
+ CLINE_MODELS,
187
+ CLINE_PROVIDER,
188
+ DEEPSEEK_DEFAULT_MODEL,
189
+ // DeepSeek
190
+ DEEPSEEK_MODELS,
191
+ DEEPSEEK_PROVIDER,
192
+ DEFAULT_EXTERNAL_OCA_BASE_URL,
193
+ DEFAULT_INTERNAL_OCA_BASE_URL,
194
+ DIFY_PROVIDER,
195
+ FIREWORKS_DEFAULT_MODEL,
196
+ // Fireworks
197
+ FIREWORKS_MODELS,
198
+ FIREWORKS_PROVIDER,
199
+ GEMINI_DEFAULT_MODEL,
200
+ // Gemini
201
+ GEMINI_MODELS,
202
+ GEMINI_PROVIDER,
203
+ GROQ_DEFAULT_MODEL,
204
+ // Groq
205
+ GROQ_MODELS,
206
+ GROQ_PROVIDER,
207
+ // Helpers
208
+ getActiveAnthropicModels,
209
+ getActiveGeminiModels,
210
+ getActiveOpenAIModels,
211
+ getActiveXAIModels,
212
+ getAnthropicReasoningModels,
213
+ getDeepSeekReasoningModels,
214
+ getFireworksFunctionModels,
215
+ getGeminiThinkingModels,
216
+ getGroqVisionModels,
217
+ getOpenAIReasoningModels,
218
+ getTogetherLlamaModels,
219
+ HICAP_PROVIDER,
220
+ HUAWEI_CLOUD_MAAS_PROVIDER,
221
+ HUGGINGFACE_PROVIDER,
222
+ LITELLM_PROVIDER,
223
+ LMSTUDIO_PROVIDER,
224
+ MINIMAX_DEFAULT_MODEL,
225
+ MINIMAX_MODELS,
226
+ MINIMAX_PROVIDER,
227
+ MISTRAL_PROVIDER,
228
+ MOONSHOT_DEFAULT_MODEL,
229
+ MOONSHOT_MODELS,
230
+ MOONSHOT_PROVIDER,
231
+ NEBIUS_DEFAULT_MODEL,
232
+ // Nebius
233
+ NEBIUS_MODELS,
234
+ NEBIUS_PROVIDER,
235
+ NOUS_RESEARCH_DEFAULT_MODEL,
236
+ // Nous Research
237
+ NOUS_RESEARCH_MODELS,
238
+ NOUS_RESEARCH_PROVIDER,
239
+ OCA_DEFAULT_MODEL,
240
+ OCA_MODELS,
241
+ OCA_PROVIDER,
242
+ // Local Providers
243
+ OLLAMA_PROVIDER,
244
+ OPENAI_CODEX_DEFAULT_MODEL,
245
+ OPENAI_CODEX_PROVIDER,
246
+ OPENAI_DEFAULT_MODEL,
247
+ // OpenAI
248
+ OPENAI_MODELS,
249
+ OPENAI_PROVIDER,
250
+ OPENROUTER_DEFAULT_MODEL,
251
+ OPENROUTER_MODELS,
252
+ OPENROUTER_PROVIDER,
253
+ // Gateway Providers
254
+ REQUESTY_PROVIDER,
255
+ SAMBANOVA_DEFAULT_MODEL,
256
+ // SambaNova
257
+ SAMBANOVA_MODELS,
258
+ SAMBANOVA_PROVIDER,
259
+ TOGETHER_DEFAULT_MODEL,
260
+ // Together
261
+ TOGETHER_MODELS,
262
+ TOGETHER_PROVIDER,
263
+ VERCEL_AI_GATEWAY_PROVIDER,
264
+ VERTEX_DEFAULT_MODEL,
265
+ VERTEX_MODELS,
266
+ VERTEX_PROVIDER,
267
+ XAI_DEFAULT_MODEL,
268
+ // xAI
269
+ XAI_MODELS,
270
+ XAI_PROVIDER,
271
+ } from "./providers/index";
@@ -0,0 +1,161 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import {
3
+ fetchModelsDevProviderModels,
4
+ type ModelsDevPayload,
5
+ normalizeModelsDevProviderModels,
6
+ } from "./models-dev-catalog";
7
+
8
+ describe("models-dev-catalog", () => {
9
+ it("normalizes payload with model filtering and defaults", () => {
10
+ const payload: ModelsDevPayload = {
11
+ openai: {
12
+ models: {
13
+ "gpt-live": {
14
+ name: "GPT Live",
15
+ tool_call: true,
16
+ reasoning: true,
17
+ structured_output: true,
18
+ temperature: true,
19
+ release_date: "2026-01-01",
20
+ modalities: { input: ["text", "image"] },
21
+ limit: { context: 1_000_000 },
22
+ cost: { input: 1, output: 2, cache_read: 0.5, cache_write: 0.8 },
23
+ status: "preview",
24
+ },
25
+ "gpt-no-tools": {
26
+ name: "GPT No Tools",
27
+ tool_call: false,
28
+ },
29
+ "gpt-deprecated": {
30
+ name: "GPT Deprecated",
31
+ tool_call: true,
32
+ status: "deprecated",
33
+ },
34
+ },
35
+ },
36
+ anthropic: {
37
+ models: {
38
+ "claude-defaults": {
39
+ tool_call: true,
40
+ status: "experimental",
41
+ release_date: "2025-02-01",
42
+ },
43
+ "claude-older": {
44
+ tool_call: true,
45
+ release_date: "2024-02-01",
46
+ },
47
+ },
48
+ },
49
+ };
50
+
51
+ const providerModels = normalizeModelsDevProviderModels(payload, {
52
+ openai: "openai-native",
53
+ anthropic: "anthropic",
54
+ });
55
+
56
+ expect(providerModels).toEqual({
57
+ "openai-native": {
58
+ "gpt-live": {
59
+ id: "gpt-live",
60
+ name: "GPT Live",
61
+ contextWindow: 1_000_000,
62
+ maxTokens: 4096,
63
+ capabilities: [
64
+ "images",
65
+ "tools",
66
+ "reasoning",
67
+ "structured_output",
68
+ "temperature",
69
+ ],
70
+ pricing: {
71
+ input: 1,
72
+ output: 2,
73
+ cacheRead: 0.5,
74
+ cacheWrite: 0.8,
75
+ },
76
+ status: "preview",
77
+ releaseDate: "2026-01-01",
78
+ },
79
+ },
80
+ anthropic: {
81
+ "claude-defaults": {
82
+ id: "claude-defaults",
83
+ name: "claude-defaults",
84
+ contextWindow: 4096,
85
+ maxTokens: 4096,
86
+ capabilities: ["tools"],
87
+ pricing: {
88
+ input: 0,
89
+ output: 0,
90
+ cacheRead: 0,
91
+ cacheWrite: 0,
92
+ },
93
+ status: undefined,
94
+ releaseDate: "2025-02-01",
95
+ },
96
+ "claude-older": {
97
+ id: "claude-older",
98
+ name: "claude-older",
99
+ contextWindow: 4096,
100
+ maxTokens: 4096,
101
+ capabilities: ["tools"],
102
+ pricing: {
103
+ input: 0,
104
+ output: 0,
105
+ cacheRead: 0,
106
+ cacheWrite: 0,
107
+ },
108
+ status: undefined,
109
+ releaseDate: "2024-02-01",
110
+ },
111
+ },
112
+ });
113
+ expect(Object.keys(providerModels.anthropic ?? {})).toEqual([
114
+ "claude-defaults",
115
+ "claude-older",
116
+ ]);
117
+ expect(providerModels["openai-native"]).not.toHaveProperty(
118
+ "gpt-deprecated",
119
+ );
120
+ });
121
+
122
+ it("fetches and normalizes models.dev payload", async () => {
123
+ const fetcher = vi.fn(async () => ({
124
+ ok: true,
125
+ json: async () =>
126
+ ({
127
+ openai: {
128
+ models: {
129
+ "gpt-live": { tool_call: true },
130
+ },
131
+ },
132
+ }) satisfies ModelsDevPayload,
133
+ }));
134
+
135
+ const result = await fetchModelsDevProviderModels(
136
+ "https://models.dev/api.json",
137
+ { openai: "openai-native" },
138
+ fetcher as unknown as typeof fetch,
139
+ );
140
+
141
+ expect(fetcher).toHaveBeenCalledWith("https://models.dev/api.json");
142
+ expect(result["openai-native"]).toHaveProperty("gpt-live");
143
+ });
144
+
145
+ it("throws when models.dev request fails", async () => {
146
+ const fetcher = vi.fn(async () => ({
147
+ ok: false,
148
+ status: 503,
149
+ }));
150
+
151
+ await expect(
152
+ fetchModelsDevProviderModels(
153
+ "https://models.dev/api.json",
154
+ { openai: "openai-native" },
155
+ fetcher as unknown as typeof fetch,
156
+ ),
157
+ ).rejects.toThrow(
158
+ "Failed to load model catalog from https://models.dev/api.json: HTTP 503",
159
+ );
160
+ });
161
+ });
@@ -0,0 +1,161 @@
1
+ import type { ModelInfo } from "./schemas/index";
2
+
3
+ export interface ModelsDevModel {
4
+ name?: string;
5
+ tool_call?: boolean;
6
+ reasoning?: boolean;
7
+ structured_output?: boolean;
8
+ temperature?: boolean;
9
+ release_date?: string;
10
+ limit?: {
11
+ context?: number;
12
+ output?: number;
13
+ };
14
+ cost?: {
15
+ input?: number;
16
+ output?: number;
17
+ cache_read?: number;
18
+ cache_write?: number;
19
+ };
20
+ modalities?: {
21
+ input?: string[];
22
+ };
23
+ status?: string;
24
+ }
25
+
26
+ interface ModelsDevProviderPayload {
27
+ models?: Record<string, ModelsDevModel>;
28
+ }
29
+
30
+ export type ModelsDevPayload = Record<string, ModelsDevProviderPayload>;
31
+ export type ModelsDevProviderKeyMap = Record<string, string>;
32
+
33
+ const DEFAULT_CONTEXT_WINDOW = 4096;
34
+ const DEFAULT_MAX_TOKENS = 4096;
35
+
36
+ function parseReleaseDate(value: string | undefined): number {
37
+ if (!value) {
38
+ return Number.NEGATIVE_INFINITY;
39
+ }
40
+
41
+ const timestamp = Date.parse(value);
42
+ return Number.isNaN(timestamp) ? Number.NEGATIVE_INFINITY : timestamp;
43
+ }
44
+
45
+ export function sortModelsByReleaseDate(
46
+ models: Record<string, ModelInfo>,
47
+ ): Record<string, ModelInfo> {
48
+ return Object.fromEntries(
49
+ Object.entries(models).sort(([modelIdA, modelA], [modelIdB, modelB]) => {
50
+ const releaseDateA = parseReleaseDate(modelA.releaseDate);
51
+ const releaseDateB = parseReleaseDate(modelB.releaseDate);
52
+ if (releaseDateA !== releaseDateB) {
53
+ return releaseDateB - releaseDateA;
54
+ }
55
+ return modelIdA.localeCompare(modelIdB);
56
+ }),
57
+ );
58
+ }
59
+
60
+ function toCapabilities(model: ModelsDevModel): ModelInfo["capabilities"] {
61
+ const capabilities: NonNullable<ModelInfo["capabilities"]> = [];
62
+ if (model.modalities?.input?.includes("image")) {
63
+ capabilities.push("images");
64
+ }
65
+ if (model.modalities?.input?.includes("pdf")) {
66
+ capabilities.push("files");
67
+ }
68
+ if (model.tool_call === true) {
69
+ capabilities.push("tools");
70
+ }
71
+ if (model.reasoning === true) {
72
+ capabilities.push("reasoning");
73
+ }
74
+ if (model.structured_output === true) {
75
+ capabilities.push("structured_output");
76
+ }
77
+ if (model.temperature === true) {
78
+ capabilities.push("temperature");
79
+ }
80
+ return capabilities;
81
+ }
82
+
83
+ function toStatus(status: string | undefined): ModelInfo["status"] {
84
+ if (
85
+ status === "active" ||
86
+ status === "preview" ||
87
+ status === "deprecated" ||
88
+ status === "legacy"
89
+ ) {
90
+ return status;
91
+ }
92
+ return undefined;
93
+ }
94
+
95
+ function toModelInfo(modelId: string, model: ModelsDevModel): ModelInfo {
96
+ return {
97
+ id: modelId,
98
+ name: model.name || modelId,
99
+ contextWindow: model.limit?.context ?? DEFAULT_CONTEXT_WINDOW,
100
+ maxTokens: model.limit?.output ?? DEFAULT_MAX_TOKENS,
101
+ capabilities: toCapabilities(model),
102
+ pricing: {
103
+ input: model.cost?.input ?? 0,
104
+ output: model.cost?.output ?? 0,
105
+ cacheRead: model.cost?.cache_read ?? 0,
106
+ cacheWrite: model.cost?.cache_write ?? 0,
107
+ },
108
+ status: toStatus(model.status),
109
+ releaseDate: model.release_date,
110
+ };
111
+ }
112
+
113
+ function isDeprecatedModel(model: ModelsDevModel): boolean {
114
+ return model.status === "deprecated";
115
+ }
116
+
117
+ export function normalizeModelsDevProviderModels(
118
+ payload: ModelsDevPayload,
119
+ providerKeyMap: ModelsDevProviderKeyMap,
120
+ ): Record<string, Record<string, ModelInfo>> {
121
+ const providerModels: Record<string, Record<string, ModelInfo>> = {};
122
+
123
+ for (const [sourceProviderKey, targetProviderId] of Object.entries(
124
+ providerKeyMap,
125
+ )) {
126
+ const source = payload[sourceProviderKey];
127
+ if (!source?.models) {
128
+ continue;
129
+ }
130
+
131
+ const models: Record<string, ModelInfo> = {};
132
+ for (const [modelId, model] of Object.entries(source.models)) {
133
+ if (model.tool_call !== true || isDeprecatedModel(model)) {
134
+ continue;
135
+ }
136
+ models[modelId] = toModelInfo(modelId, model);
137
+ }
138
+
139
+ if (Object.keys(models).length > 0) {
140
+ providerModels[targetProviderId] = sortModelsByReleaseDate(models);
141
+ }
142
+ }
143
+
144
+ return providerModels;
145
+ }
146
+
147
+ export async function fetchModelsDevProviderModels(
148
+ url: string,
149
+ providerKeyMap: ModelsDevProviderKeyMap,
150
+ fetcher: typeof fetch = fetch,
151
+ ): Promise<Record<string, Record<string, ModelInfo>>> {
152
+ const response = await fetcher(url);
153
+ if (!response.ok) {
154
+ throw new Error(
155
+ `Failed to load model catalog from ${url}: HTTP ${response.status}`,
156
+ );
157
+ }
158
+
159
+ const payload = (await response.json()) as ModelsDevPayload;
160
+ return normalizeModelsDevProviderModels(payload, providerKeyMap);
161
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * AIhubmix Provider
3
+ */
4
+
5
+ import { getGeneratedModelsForProvider } from "../generated-access";
6
+ import type { ModelCollection } from "../schemas/index";
7
+
8
+ export const AIHUBMIX_PROVIDER: ModelCollection = {
9
+ provider: {
10
+ id: "aihubmix",
11
+ name: "AI Hub Mix",
12
+ description: "AI model aggregator",
13
+ protocol: "openai-chat",
14
+ baseUrl: "https://api.aihubmix.com/v1",
15
+ defaultModelId: "gpt-4o",
16
+ env: ["AIHUBMIX_API_KEY"],
17
+ },
18
+ models: getGeneratedModelsForProvider("aihubmix"),
19
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Anthropic Models
3
+ *
4
+ * Model definitions for Anthropic's Claude family of models.
5
+ * https://docs.anthropic.com/en/docs/about-claude/models
6
+ */
7
+
8
+ import { getGeneratedModelsForProvider } from "../generated-access";
9
+ import type { ModelCollection, ModelInfo } from "../schemas/index";
10
+
11
+ /**
12
+ * Anthropic model definitions
13
+ */
14
+ export const ANTHROPIC_MODELS = getGeneratedModelsForProvider("anthropic");
15
+
16
+ /**
17
+ * Default Anthropic model ID
18
+ */
19
+ export const ANTHROPIC_DEFAULT_MODEL =
20
+ Object.keys(ANTHROPIC_MODELS)[0] ?? "claude-sonnet-4-6";
21
+
22
+ /**
23
+ * Anthropic provider information
24
+ */
25
+ export const ANTHROPIC_PROVIDER: ModelCollection = {
26
+ provider: {
27
+ id: "anthropic",
28
+ name: "Anthropic",
29
+ description: "Creator of Claude, the AI assistant",
30
+ protocol: "anthropic",
31
+ baseUrl: "https://api.anthropic.com",
32
+ defaultModelId: ANTHROPIC_DEFAULT_MODEL,
33
+ capabilities: ["reasoning", "prompt-cache"],
34
+ env: ["ANTHROPIC_API_KEY"],
35
+ },
36
+ models: ANTHROPIC_MODELS,
37
+ };
38
+
39
+ /**
40
+ * Get all active Anthropic models
41
+ */
42
+ export function getActiveAnthropicModels(): Record<string, ModelInfo> {
43
+ return Object.fromEntries(
44
+ Object.entries(ANTHROPIC_MODELS).filter(
45
+ ([, info]) =>
46
+ !info.status || info.status === "active" || info.status === "preview",
47
+ ),
48
+ );
49
+ }
50
+
51
+ /**
52
+ * Get Anthropic models with reasoning/thinking support
53
+ */
54
+ export function getAnthropicReasoningModels(): Record<string, ModelInfo> {
55
+ return Object.fromEntries(
56
+ Object.entries(ANTHROPIC_MODELS).filter(
57
+ ([, info]) => info.thinkingConfig !== undefined,
58
+ ),
59
+ );
60
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * AskSage Provider
3
+ */
4
+
5
+ import type { ModelCollection } from "../schemas/index";
6
+
7
+ export const ASKSAGE_PROVIDER: ModelCollection = {
8
+ provider: {
9
+ id: "asksage",
10
+ name: "AskSage",
11
+ description: "AskSage platform",
12
+ protocol: "openai-chat",
13
+ baseUrl: "https://api.asksage.ai/server",
14
+ defaultModelId: "gpt-4o",
15
+ capabilities: ["tools"],
16
+ env: ["ASKSAGE_API_KEY"],
17
+ },
18
+ models: {},
19
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Baseten Provider
3
+ */
4
+
5
+ import { getGeneratedModelsForProvider } from "../generated-access";
6
+ import type { ModelCollection } from "../schemas/index";
7
+
8
+ const BASETEN_MODELS = getGeneratedModelsForProvider("baseten");
9
+
10
+ export const BASETEN_PROVIDER: ModelCollection = {
11
+ provider: {
12
+ id: "baseten",
13
+ name: "Baseten",
14
+ description: "ML inference platform",
15
+ protocol: "openai-chat",
16
+ baseUrl: "https://model-api.baseten.co/v1",
17
+ defaultModelId: Object.keys(BASETEN_MODELS)[0],
18
+ env: ["BASETEN_API_KEY"],
19
+ },
20
+ models: BASETEN_MODELS,
21
+ };