@tyvm/knowhow 0.0.105 → 0.0.107

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/CONFIG.md +8 -5
  2. package/package.json +3 -2
  3. package/scripts/check-model-pricing.ts +509 -0
  4. package/scripts/compare-openrouter-coverage.ts +576 -0
  5. package/src/agents/base/base.ts +169 -5
  6. package/src/agents/tools/execCommand.ts +4 -0
  7. package/src/agents/tools/executeScript/definition.ts +1 -1
  8. package/src/agents/tools/index.ts +0 -1
  9. package/src/agents/tools/list.ts +3 -43
  10. package/src/agents/tools/writeFile.ts +1 -1
  11. package/src/auth/browserLogin.ts +9 -4
  12. package/src/chat/modules/RemoteSyncModule.ts +3 -0
  13. package/src/cli.ts +31 -1
  14. package/src/clients/anthropic.ts +8 -2
  15. package/src/clients/cerebras.ts +10 -0
  16. package/src/clients/contextLimits.ts +7 -2
  17. package/src/clients/copilot.ts +23 -0
  18. package/src/clients/deepseek.ts +16 -0
  19. package/src/clients/fireworks.ts +15 -0
  20. package/src/clients/gemini.ts +59 -4
  21. package/src/clients/github.ts +16 -0
  22. package/src/clients/groq.ts +15 -0
  23. package/src/clients/http.ts +194 -6
  24. package/src/clients/index.ts +116 -4
  25. package/src/clients/llama.ts +16 -0
  26. package/src/clients/mistral.ts +16 -0
  27. package/src/clients/nvidia.ts +16 -0
  28. package/src/clients/openai.ts +53 -12
  29. package/src/clients/openrouter.ts +17 -0
  30. package/src/clients/pricing/anthropic.ts +105 -78
  31. package/src/clients/pricing/cerebras.ts +11 -0
  32. package/src/clients/pricing/copilot.ts +60 -0
  33. package/src/clients/pricing/deepseek.ts +15 -0
  34. package/src/clients/pricing/fireworks.ts +32 -0
  35. package/src/clients/pricing/github.ts +69 -0
  36. package/src/clients/pricing/google.ts +245 -206
  37. package/src/clients/pricing/groq.ts +56 -0
  38. package/src/clients/pricing/index.ts +42 -5
  39. package/src/clients/pricing/llama.ts +18 -0
  40. package/src/clients/pricing/mistral.ts +34 -0
  41. package/src/clients/pricing/models.ts +7 -236
  42. package/src/clients/pricing/nvidia.ts +102 -0
  43. package/src/clients/pricing/openai.ts +348 -171
  44. package/src/clients/pricing/openrouter.ts +36 -0
  45. package/src/clients/pricing/types.ts +83 -2
  46. package/src/clients/pricing/xai.ts +121 -65
  47. package/src/clients/types.ts +28 -1
  48. package/src/clients/xai.ts +161 -1
  49. package/src/fileSync.ts +8 -2
  50. package/src/login.ts +11 -3
  51. package/src/services/AgentSyncFs.ts +36 -12
  52. package/src/services/KnowhowClient.ts +11 -0
  53. package/src/services/LazyToolsService.ts +6 -0
  54. package/src/services/S3.ts +0 -7
  55. package/src/services/modules/index.ts +11 -2
  56. package/src/types.ts +56 -279
  57. package/src/worker.ts +174 -0
  58. package/tests/clients/AIClient.test.ts +1 -1
  59. package/tests/clients/anthropic.test.ts +202 -0
  60. package/tests/clients/pricing.test.ts +37 -0
  61. package/tests/manual/clients/completions.json +838 -226
  62. package/tests/manual/clients/completions.test.ts +46 -31
  63. package/ts_build/package.json +3 -2
  64. package/ts_build/src/agents/base/base.d.ts +18 -1
  65. package/ts_build/src/agents/base/base.js +111 -4
  66. package/ts_build/src/agents/base/base.js.map +1 -1
  67. package/ts_build/src/agents/tools/execCommand.js +3 -0
  68. package/ts_build/src/agents/tools/execCommand.js.map +1 -1
  69. package/ts_build/src/agents/tools/executeScript/definition.js +1 -1
  70. package/ts_build/src/agents/tools/executeScript/definition.js.map +1 -1
  71. package/ts_build/src/agents/tools/index.d.ts +0 -1
  72. package/ts_build/src/agents/tools/index.js +0 -1
  73. package/ts_build/src/agents/tools/index.js.map +1 -1
  74. package/ts_build/src/agents/tools/list.js +3 -38
  75. package/ts_build/src/agents/tools/list.js.map +1 -1
  76. package/ts_build/src/agents/tools/visionTool.d.ts +1 -1
  77. package/ts_build/src/agents/tools/writeFile.js +1 -1
  78. package/ts_build/src/agents/tools/writeFile.js.map +1 -1
  79. package/ts_build/src/ai.d.ts +1 -1
  80. package/ts_build/src/auth/browserLogin.d.ts +2 -1
  81. package/ts_build/src/auth/browserLogin.js +10 -3
  82. package/ts_build/src/auth/browserLogin.js.map +1 -1
  83. package/ts_build/src/chat/modules/RemoteSyncModule.js +1 -0
  84. package/ts_build/src/chat/modules/RemoteSyncModule.js.map +1 -1
  85. package/ts_build/src/cli.js +19 -0
  86. package/ts_build/src/cli.js.map +1 -1
  87. package/ts_build/src/clients/anthropic.d.ts +1 -82
  88. package/ts_build/src/clients/anthropic.js +8 -2
  89. package/ts_build/src/clients/anthropic.js.map +1 -1
  90. package/ts_build/src/clients/cerebras.d.ts +4 -0
  91. package/ts_build/src/clients/cerebras.js +14 -0
  92. package/ts_build/src/clients/cerebras.js.map +1 -0
  93. package/ts_build/src/clients/contextLimits.js +7 -2
  94. package/ts_build/src/clients/contextLimits.js.map +1 -1
  95. package/ts_build/src/clients/copilot.d.ts +4 -0
  96. package/ts_build/src/clients/copilot.js +15 -0
  97. package/ts_build/src/clients/copilot.js.map +1 -0
  98. package/ts_build/src/clients/deepseek.d.ts +4 -0
  99. package/ts_build/src/clients/deepseek.js +15 -0
  100. package/ts_build/src/clients/deepseek.js.map +1 -0
  101. package/ts_build/src/clients/fireworks.d.ts +4 -0
  102. package/ts_build/src/clients/fireworks.js +15 -0
  103. package/ts_build/src/clients/fireworks.js.map +1 -0
  104. package/ts_build/src/clients/gemini.d.ts +1 -0
  105. package/ts_build/src/clients/gemini.js +38 -2
  106. package/ts_build/src/clients/gemini.js.map +1 -1
  107. package/ts_build/src/clients/github.d.ts +4 -0
  108. package/ts_build/src/clients/github.js +15 -0
  109. package/ts_build/src/clients/github.js.map +1 -0
  110. package/ts_build/src/clients/groq.d.ts +4 -0
  111. package/ts_build/src/clients/groq.js +15 -0
  112. package/ts_build/src/clients/groq.js.map +1 -0
  113. package/ts_build/src/clients/http.d.ts +22 -1
  114. package/ts_build/src/clients/http.js +135 -7
  115. package/ts_build/src/clients/http.js.map +1 -1
  116. package/ts_build/src/clients/index.d.ts +14 -0
  117. package/ts_build/src/clients/index.js +94 -4
  118. package/ts_build/src/clients/index.js.map +1 -1
  119. package/ts_build/src/clients/llama.d.ts +4 -0
  120. package/ts_build/src/clients/llama.js +15 -0
  121. package/ts_build/src/clients/llama.js.map +1 -0
  122. package/ts_build/src/clients/mistral.d.ts +4 -0
  123. package/ts_build/src/clients/mistral.js +15 -0
  124. package/ts_build/src/clients/mistral.js.map +1 -0
  125. package/ts_build/src/clients/nvidia.d.ts +4 -0
  126. package/ts_build/src/clients/nvidia.js +15 -0
  127. package/ts_build/src/clients/nvidia.js.map +1 -0
  128. package/ts_build/src/clients/openai.d.ts +4 -206
  129. package/ts_build/src/clients/openai.js +38 -10
  130. package/ts_build/src/clients/openai.js.map +1 -1
  131. package/ts_build/src/clients/openrouter.d.ts +4 -0
  132. package/ts_build/src/clients/openrouter.js +15 -0
  133. package/ts_build/src/clients/openrouter.js.map +1 -0
  134. package/ts_build/src/clients/pricing/anthropic.d.ts +26 -78
  135. package/ts_build/src/clients/pricing/anthropic.js +75 -78
  136. package/ts_build/src/clients/pricing/anthropic.js.map +1 -1
  137. package/ts_build/src/clients/pricing/cerebras.d.ts +4 -0
  138. package/ts_build/src/clients/pricing/cerebras.js +11 -0
  139. package/ts_build/src/clients/pricing/cerebras.js.map +1 -0
  140. package/ts_build/src/clients/pricing/copilot.d.ts +5 -0
  141. package/ts_build/src/clients/pricing/copilot.js +35 -0
  142. package/ts_build/src/clients/pricing/copilot.js.map +1 -0
  143. package/ts_build/src/clients/pricing/deepseek.d.ts +5 -0
  144. package/ts_build/src/clients/pricing/deepseek.js +10 -0
  145. package/ts_build/src/clients/pricing/deepseek.js.map +1 -0
  146. package/ts_build/src/clients/pricing/fireworks.d.ts +5 -0
  147. package/ts_build/src/clients/pricing/fireworks.js +21 -0
  148. package/ts_build/src/clients/pricing/fireworks.js.map +1 -0
  149. package/ts_build/src/clients/pricing/github.d.ts +4 -0
  150. package/ts_build/src/clients/pricing/github.js +58 -0
  151. package/ts_build/src/clients/pricing/github.js.map +1 -0
  152. package/ts_build/src/clients/pricing/google.d.ts +59 -6
  153. package/ts_build/src/clients/pricing/google.js +214 -167
  154. package/ts_build/src/clients/pricing/google.js.map +1 -1
  155. package/ts_build/src/clients/pricing/groq.d.ts +5 -0
  156. package/ts_build/src/clients/pricing/groq.js +41 -0
  157. package/ts_build/src/clients/pricing/groq.js.map +1 -0
  158. package/ts_build/src/clients/pricing/index.d.ts +16 -5
  159. package/ts_build/src/clients/pricing/index.js +62 -7
  160. package/ts_build/src/clients/pricing/index.js.map +1 -1
  161. package/ts_build/src/clients/pricing/llama.d.ts +4 -0
  162. package/ts_build/src/clients/pricing/llama.js +14 -0
  163. package/ts_build/src/clients/pricing/llama.js.map +1 -0
  164. package/ts_build/src/clients/pricing/mistral.d.ts +5 -0
  165. package/ts_build/src/clients/pricing/mistral.js +23 -0
  166. package/ts_build/src/clients/pricing/mistral.js.map +1 -0
  167. package/ts_build/src/clients/pricing/models.d.ts +5 -4
  168. package/ts_build/src/clients/pricing/models.js +8 -162
  169. package/ts_build/src/clients/pricing/models.js.map +1 -1
  170. package/ts_build/src/clients/pricing/nvidia.d.ts +8 -0
  171. package/ts_build/src/clients/pricing/nvidia.js +96 -0
  172. package/ts_build/src/clients/pricing/nvidia.js.map +1 -0
  173. package/ts_build/src/clients/pricing/openai.d.ts +86 -197
  174. package/ts_build/src/clients/pricing/openai.js +295 -168
  175. package/ts_build/src/clients/pricing/openai.js.map +1 -1
  176. package/ts_build/src/clients/pricing/openrouter.d.ts +4 -0
  177. package/ts_build/src/clients/pricing/openrouter.js +29 -0
  178. package/ts_build/src/clients/pricing/openrouter.js.map +1 -0
  179. package/ts_build/src/clients/pricing/types.d.ts +27 -2
  180. package/ts_build/src/clients/pricing/types.js +46 -0
  181. package/ts_build/src/clients/pricing/types.js.map +1 -1
  182. package/ts_build/src/clients/pricing/xai.d.ts +37 -57
  183. package/ts_build/src/clients/pricing/xai.js +92 -59
  184. package/ts_build/src/clients/pricing/xai.js.map +1 -1
  185. package/ts_build/src/clients/types.d.ts +12 -1
  186. package/ts_build/src/clients/xai.d.ts +2 -62
  187. package/ts_build/src/clients/xai.js +132 -1
  188. package/ts_build/src/clients/xai.js.map +1 -1
  189. package/ts_build/src/fileSync.js +7 -2
  190. package/ts_build/src/fileSync.js.map +1 -1
  191. package/ts_build/src/login.js +8 -2
  192. package/ts_build/src/login.js.map +1 -1
  193. package/ts_build/src/services/AgentSyncFs.js +1 -0
  194. package/ts_build/src/services/AgentSyncFs.js.map +1 -1
  195. package/ts_build/src/services/KnowhowClient.d.ts +1 -0
  196. package/ts_build/src/services/KnowhowClient.js +7 -0
  197. package/ts_build/src/services/KnowhowClient.js.map +1 -1
  198. package/ts_build/src/services/LazyToolsService.d.ts +1 -0
  199. package/ts_build/src/services/LazyToolsService.js +3 -0
  200. package/ts_build/src/services/LazyToolsService.js.map +1 -1
  201. package/ts_build/src/services/S3.js +0 -7
  202. package/ts_build/src/services/S3.js.map +1 -1
  203. package/ts_build/src/services/modules/index.js +41 -1
  204. package/ts_build/src/services/modules/index.js.map +1 -1
  205. package/ts_build/src/types.d.ts +163 -124
  206. package/ts_build/src/types.js +33 -213
  207. package/ts_build/src/types.js.map +1 -1
  208. package/ts_build/src/worker.d.ts +4 -0
  209. package/ts_build/src/worker.js +140 -0
  210. package/ts_build/src/worker.js.map +1 -1
  211. package/ts_build/tests/clients/AIClient.test.js +1 -1
  212. package/ts_build/tests/clients/AIClient.test.js.map +1 -1
  213. package/ts_build/tests/clients/anthropic.test.d.ts +1 -0
  214. package/ts_build/tests/clients/anthropic.test.js +159 -0
  215. package/ts_build/tests/clients/anthropic.test.js.map +1 -0
  216. package/ts_build/tests/clients/pricing.test.js +21 -0
  217. package/ts_build/tests/clients/pricing.test.js.map +1 -1
  218. package/ts_build/tests/manual/clients/completions.test.js +27 -24
  219. package/ts_build/tests/manual/clients/completions.test.js.map +1 -1
@@ -34,12 +34,14 @@ import {
34
34
  EmbeddingModels,
35
35
  Models,
36
36
  OpenAiReasoningModels,
37
+ OpenAiChatModels,
37
38
  OpenAiResponsesOnlyModels,
38
39
  OpenAiImageModels,
39
40
  OpenAiVideoModels,
40
41
  OpenAiTTSModels,
41
42
  OpenAiTranscriptionModels,
42
- OpenAiEmbeddingModels,
43
+ OpenAiEmbeddingModelsList,
44
+ OpenAiRealtimeModels,
43
45
  } from "../types";
44
46
  import { ModelModality } from "./types";
45
47
 
@@ -64,7 +66,11 @@ export class GenericOpenAiClient implements GenericClient {
64
66
  reasoningEffort(
65
67
  messages: CompletionOptions["messages"]
66
68
  ): "low" | "medium" | "high" {
67
- const effortMap = {
69
+ return this.detectReasoningEffort(messages);
70
+ }
71
+
72
+ detectReasoningEffort(messages: CompletionOptions["messages"]): "low" | "medium" | "high" {
73
+ const effortMap: Record<string, "low" | "medium" | "high"> = {
68
74
  ultrathink: "high",
69
75
  "think hard": "high",
70
76
  "reason hard": "high",
@@ -96,6 +102,30 @@ export class GenericOpenAiClient implements GenericClient {
96
102
  return "medium"; // Default to medium if no specific effort is mentioned
97
103
  }
98
104
 
105
+ resolveReasoningEffort(options: CompletionOptions): "low" | "medium" | "high" {
106
+ return options.reasoning_effort ?? this.detectReasoningEffort(options.messages);
107
+ }
108
+
109
+ /**
110
+ * Resolves the reasoning effort for a specific model, clamping to the model's
111
+ * supported levels if `reasoningLevels` is set in its pricing entry.
112
+ * If the requested level is not supported, picks the lowest supported level.
113
+ */
114
+ resolveReasoningEffortForModel(options: CompletionOptions): string {
115
+ const requested = options.reasoning_effort ?? this.detectReasoningEffort(options.messages);
116
+ const pricing = OpenAiTextPricing[options.model];
117
+ const supportedLevels = pricing?.reasoningLevels;
118
+ if (!supportedLevels || supportedLevels.length === 0) {
119
+ return requested;
120
+ }
121
+ // If the requested level is supported, use it
122
+ if (supportedLevels.includes(requested)) {
123
+ return requested;
124
+ }
125
+ // Otherwise use the first (lowest) supported level
126
+ return supportedLevels[0];
127
+ }
128
+
99
129
  async createChatCompletion(
100
130
  options: CompletionOptions
101
131
  ): Promise<CompletionResponse> {
@@ -122,8 +152,8 @@ export class GenericOpenAiClient implements GenericClient {
122
152
  max_tokens: options.max_tokens,
123
153
  ...(OpenAiReasoningModels.includes(options.model) && {
124
154
  max_tokens: undefined,
125
- max_completion_tokens: Math.max(options.max_tokens, 100),
126
- reasoning_effort: this.reasoningEffort(options.messages),
155
+ max_completion_tokens: Math.max(options.max_tokens ?? 0, 16_000),
156
+ reasoning_effort: this.resolveReasoningEffort(options),
127
157
  }),
128
158
 
129
159
  ...(options.tools && {
@@ -146,7 +176,14 @@ export class GenericOpenAiClient implements GenericClient {
146
176
  })),
147
177
 
148
178
  model: options.model,
149
- usage: response.usage,
179
+ usage: response.usage ? {
180
+ prompt_tokens: response.usage.prompt_tokens ?? 0,
181
+ completion_tokens: response.usage.completion_tokens ?? 0,
182
+ total_tokens: response.usage.total_tokens,
183
+ prompt_tokens_details: {
184
+ cached_tokens: response.usage.prompt_tokens_details?.cached_tokens ?? 0,
185
+ },
186
+ } : undefined,
150
187
  usd_cost: usdCost,
151
188
  };
152
189
  }
@@ -254,7 +291,7 @@ export class GenericOpenAiClient implements GenericClient {
254
291
  // Don't limit max_output_tokens for Responses API - codex truncates tool call arguments when limited
255
292
  ...(OpenAiReasoningModels.includes(options.model) && {
256
293
  max_output_tokens: Math.max(options.max_tokens || 0, 16000),
257
- reasoning: { effort: this.reasoningEffort(options.messages) },
294
+ reasoning: { effort: this.resolveReasoningEffortForModel(options) },
258
295
  }),
259
296
  ...(tools?.length && {
260
297
  tools,
@@ -270,6 +307,10 @@ export class GenericOpenAiClient implements GenericClient {
270
307
  completion_tokens: response.usage.output_tokens,
271
308
  total_tokens:
272
309
  response.usage.input_tokens + response.usage.output_tokens,
310
+ prompt_tokens_details: {
311
+ cached_tokens:
312
+ response.usage.input_tokens_details?.cached_tokens ?? 0,
313
+ },
273
314
  }
274
315
  : undefined;
275
316
 
@@ -349,14 +390,14 @@ export class GenericOpenAiClient implements GenericClient {
349
390
  ("prompt_tokens_details" in usage &&
350
391
  usage.prompt_tokens_details?.cached_tokens) ||
351
392
  0;
352
- const cachedInputCost = (cachedInputTokens * pricing.cached_input) / 1e6;
393
+ const cachedInputCost = (cachedInputTokens * (pricing.cached_input ?? 0)) / 1e6;
353
394
 
354
395
  const inputTokens = usage.prompt_tokens;
355
- const inputCost = ((inputTokens - cachedInputCost) * pricing.input) / 1e6;
396
+ const inputCost = ((inputTokens - cachedInputTokens) * (pricing.input ?? 0)) / 1e6;
356
397
 
357
398
  const outputTokens =
358
399
  ("completion_tokens" in usage && usage?.completion_tokens) || 0;
359
- const outputCost = (outputTokens * pricing.output) / 1e6;
400
+ const outputCost = (outputTokens * (pricing.output ?? 0)) / 1e6;
360
401
 
361
402
  const total = cachedInputCost + inputCost + outputCost;
362
403
  return total;
@@ -365,8 +406,8 @@ export class GenericOpenAiClient implements GenericClient {
365
406
  async getModels(modality?: ModelModality): Promise<{ id: string }[]> {
366
407
  if (modality) {
367
408
  const map: Partial<Record<ModelModality, string[]>> = {
368
- completion: Object.values(Models.openai),
369
- embedding: OpenAiEmbeddingModels,
409
+ completion: [...new Set([...OpenAiChatModels, ...OpenAiResponsesOnlyModels])],
410
+ embedding: OpenAiEmbeddingModelsList,
370
411
  image: OpenAiImageModels,
371
412
  audio: [...OpenAiTTSModels, ...OpenAiTranscriptionModels],
372
413
  transcription: OpenAiTranscriptionModels,
@@ -406,7 +447,7 @@ export class GenericOpenAiClient implements GenericClient {
406
447
  }
407
448
 
408
449
  const response = await this.client.audio.transcriptions.create({
409
- file: file,
450
+ file,
410
451
  model: options.model || "whisper-1",
411
452
  language: options.language,
412
453
  prompt: options.prompt,
@@ -0,0 +1,17 @@
1
+ import { HttpClient } from "./http";
2
+ import { OpenRouterTextPricing } from "./pricing/openrouter";
3
+
4
+ /**
5
+ * OpenRouter client — OpenAI-compatible API aggregator
6
+ * https://openrouter.ai/docs
7
+ * 39+ free models; append `:free` suffix to a model id for the free variant.
8
+ * One API key gives access to models from many providers.
9
+ * Set env var OPENROUTER_API_KEY to enable.
10
+ */
11
+ export class GenericOpenRouterClient extends HttpClient {
12
+ constructor(apiKey = process.env.OPENROUTER_API_KEY) {
13
+ super("https://openrouter.ai/api");
14
+ if (apiKey) this.setJwt(apiKey);
15
+ this.setPrices(OpenRouterTextPricing);
16
+ }
17
+ }
@@ -1,80 +1,107 @@
1
- import { Models } from "../../types";
1
+ /**
2
+ * Anthropic model IDs, pricing, and catalog.
3
+ * Single source of truth for all Anthropic/Claude models.
4
+ * Deprecation dates from: https://docs.anthropic.com/en/docs/about-claude/model-deprecations
5
+ */
6
+ import { completions, ModelCatalogEntry, ModelPricing } from "./types";
2
7
 
3
- export const AnthropicTextPricing = {
4
- [Models.anthropic.Opus4_6]: {
5
- input: 5.0,
6
- cache_write: 6.25,
7
- cache_hit: 0.5,
8
- output: 25.0,
9
- },
10
- [Models.anthropic.Sonnet4_6]: {
11
- input: 3.0,
12
- cache_write: 3.75,
13
- cache_hit: 0.3,
14
- output: 15.0,
15
- },
16
- [Models.anthropic.Opus4_5]: {
17
- input: 5.0,
18
- cache_write: 6.25,
19
- cache_hit: 0.5,
20
- output: 25.0,
21
- },
22
- [Models.anthropic.Opus4_1]: {
23
- input: 15.0,
24
- cache_write: 18.75,
25
- cache_hit: 1.5,
26
- output: 75.0,
27
- },
28
- [Models.anthropic.Opus4]: {
29
- input: 15.0,
30
- cache_write: 18.75,
31
- cache_hit: 1.5,
32
- output: 75.0,
33
- },
34
- [Models.anthropic.Sonnet4]: {
35
- input: 3.0,
36
- input_gt_200k: 6.0,
37
- cache_write: 3.75,
38
- cache_hit: 0.3,
39
- output: 15.0,
40
- output_gt_200k: 22.5,
41
- },
42
- [Models.anthropic.Sonnet4_5]: {
43
- input: 3.0,
44
- input_gt_200k: 6.0,
45
- cache_write: 3.75,
46
- cache_hit: 0.3,
47
- output: 15.0,
48
- output_gt_200k: 22.5,
49
- },
50
- [Models.anthropic.Haiku4_5]: {
51
- input: 1,
52
- cache_write: 1.25,
53
- cache_hit: 0.1,
54
- output: 5,
55
- },
56
- [Models.anthropic.Sonnet3_7]: {
57
- input: 3.0,
58
- cache_write: 3.75,
59
- cache_hit: 0.3,
60
- output: 15.0,
61
- },
62
- [Models.anthropic.Sonnet3_5]: {
63
- input: 3.0,
64
- cache_write: 3.75,
65
- cache_hit: 0.3,
66
- output: 15.0,
67
- },
68
- [Models.anthropic.Opus3]: {
69
- input: 15.0,
70
- cache_write: 18.75,
71
- cache_hit: 1.5,
72
- output: 75.0,
73
- },
74
- [Models.anthropic.Haiku3]: {
75
- input: 0.25,
76
- cache_write: 0.3125,
77
- cache_hit: 0.025,
78
- output: 1.25,
79
- },
8
+ // ─── Model IDs ────────────────────────────────────────────────────────────────
9
+
10
+ export const AnthropicModels = {
11
+ // Active models
12
+ Opus4_7: "claude-opus-4-7",
13
+ Opus4_6: "claude-opus-4-6",
14
+ Opus4_6Fast: "claude-opus-4-6-fast",
15
+ Sonnet4_6: "claude-sonnet-4-6",
16
+ Opus4_5: "claude-opus-4-5-20251101",
17
+ Opus4_1: "claude-opus-4-1-20250805",
18
+ Sonnet4_5: "claude-sonnet-4-5-20250929",
19
+ Haiku4_5: "claude-haiku-4-5-20251001",
20
+ // Deprecated models (per Anthropic deprecation page)
21
+ Opus4: "claude-opus-4-20250514", // deprecated 2026-04-14, retirement 2026-06-15
22
+ Sonnet4: "claude-sonnet-4-20250514", // deprecated 2026-04-14, retirement 2026-06-15
23
+ Sonnet3_7: "claude-3-7-sonnet-20250219", // retired 2026-02-19
24
+ Sonnet3_5: "claude-3-5-sonnet-20241022", // retired 2025-10-28
25
+ Sonnet3_5_20240620: "claude-3-5-sonnet-20240620", // earlier version, retired
26
+ Haiku3_5_Latest: "claude-3-5-haiku-latest", // alias → claude-3-5-haiku-20241022, retired
27
+ Sonnet3: "claude-3-sonnet-20240229", // retired
28
+ // models.dev alias IDs (versioned as -0 suffix instead of date)
29
+ Opus4_0: "claude-opus-4-0", // alias for claude-opus-4-20250514, deprecated
30
+ Sonnet4_0: "claude-sonnet-4-0", // alias for claude-sonnet-4-20250514, deprecated
31
+ Haiku3_5: "claude-3-5-haiku-20241022", // retired 2026-02-19
32
+ Opus3: "claude-3-opus-20240229", // retired 2026-01-05
33
+ Haiku3: "claude-3-haiku-20240307", // retired 2026-04-20
34
+ } as const;
35
+
36
+ // ─── Active (non-deprecated) text models ──────────────────────────────────────
37
+
38
+ export const AnthropicTextModels: string[] = [
39
+ AnthropicModels.Opus4_7,
40
+ AnthropicModels.Opus4_6,
41
+ AnthropicModels.Sonnet4_6,
42
+ AnthropicModels.Opus4_5,
43
+ AnthropicModels.Opus4_1,
44
+ AnthropicModels.Sonnet4_5,
45
+ AnthropicModels.Haiku4_5,
46
+ ];
47
+
48
+ // Models in our catalog but not yet publicly available
49
+ export const AnthropicLimitedAvailabilityModels: string[] = [
50
+ AnthropicModels.Opus4_6Fast, // 404 – not publicly available yet
51
+ ];
52
+
53
+ // ─── All models for catalog (active + limited + deprecated/retired) ───────────
54
+ // Deprecation/replacement metadata is embedded in AnthropicTextPricing entries.
55
+ const AnthropicAllModels: string[] = [
56
+ ...AnthropicTextModels,
57
+ ...AnthropicLimitedAvailabilityModels,
58
+ // Deprecated (retirement 2026-06-15)
59
+ AnthropicModels.Opus4,
60
+ AnthropicModels.Sonnet4,
61
+ // Retired — kept for historical cost tracking
62
+ AnthropicModels.Sonnet3_7,
63
+ AnthropicModels.Sonnet3_5,
64
+ AnthropicModels.Sonnet3_5_20240620,
65
+ AnthropicModels.Haiku3_5_Latest,
66
+ AnthropicModels.Sonnet3,
67
+ AnthropicModels.Opus4_0,
68
+ AnthropicModels.Sonnet4_0,
69
+ AnthropicModels.Haiku3_5,
70
+ AnthropicModels.Opus3,
71
+ AnthropicModels.Haiku3,
72
+ ];
73
+
74
+ // ─── Pricing (USD per 1M tokens) ──────────────────────────────────────────────
75
+
76
+ export const AnthropicTextPricing: Record<string, ModelPricing> = {
77
+ [AnthropicModels.Opus4_7]: { input: 5.0, cache_write: 6.25, cache_hit: 0.5, output: 25.0 },
78
+ [AnthropicModels.Opus4_6]: { input: 5.0, cache_write: 6.25, cache_hit: 0.5, output: 25.0 },
79
+ [AnthropicModels.Opus4_6Fast]: { input: 30.0, cache_write: 37.5, cache_hit: 3.0, output: 150.0, limitedAvailability: true },
80
+ [AnthropicModels.Sonnet4_6]: { input: 3.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0 },
81
+ [AnthropicModels.Opus4_5]: { input: 5.0, cache_write: 6.25, cache_hit: 0.5, output: 25.0 },
82
+ [AnthropicModels.Opus4_1]: { input: 15.0, cache_write: 18.75, cache_hit: 1.5, output: 75.0 },
83
+ [AnthropicModels.Sonnet4_5]: { input: 3.0, input_gt_200k: 6.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0, output_gt_200k: 22.5 },
84
+ [AnthropicModels.Haiku4_5]: { input: 1.0, cache_write: 1.25, cache_hit: 0.1, output: 5.0 },
85
+ // Deprecated — pricing retained for cost tracking
86
+ [AnthropicModels.Opus4]: { input: 15.0, cache_write: 18.75, cache_hit: 1.5, output: 75.0, deprecated: true, deprecationDate: "2026-06-15" },
87
+ [AnthropicModels.Sonnet4]: { input: 3.0, input_gt_200k: 6.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0, output_gt_200k: 22.5, deprecated: true, deprecationDate: "2026-06-15" },
88
+ // Retired — pricing retained for cost tracking of historical usage
89
+ [AnthropicModels.Sonnet3_7]: { input: 3.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0, deprecated: true, deprecationDate: "2026-02-19" },
90
+ [AnthropicModels.Sonnet3_5]: { input: 3.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0, deprecated: true, deprecationDate: "2025-10-28" },
91
+ [AnthropicModels.Sonnet3_5_20240620]: { input: 3.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0, deprecated: true, deprecationDate: "2025-10-28" },
92
+ [AnthropicModels.Haiku3_5_Latest]: { input: 0.8, cache_write: 1.0, cache_hit: 0.08, output: 4.0, deprecated: true, deprecationDate: "2026-02-19" },
93
+ [AnthropicModels.Sonnet3]: { input: 3.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0, deprecated: true },
94
+ [AnthropicModels.Opus4_0]: { input: 15.0, cache_write: 18.75, cache_hit: 1.5, output: 75.0, deprecated: true, deprecationDate: "2026-06-15" },
95
+ [AnthropicModels.Sonnet4_0]: { input: 3.0, cache_write: 3.75, cache_hit: 0.3, output: 15.0, deprecated: true, deprecationDate: "2026-06-15" },
96
+ [AnthropicModels.Haiku3_5]: { input: 0.8, cache_write: 1.0, cache_hit: 0.08, output: 4.0, deprecated: true, deprecationDate: "2026-02-19" },
97
+ [AnthropicModels.Opus3]: { input: 15.0, cache_write: 18.75, cache_hit: 1.5, output: 75.0, deprecated: true, deprecationDate: "2026-01-05" },
98
+ [AnthropicModels.Haiku3]: { input: 0.25, cache_write: 0.3125, cache_hit: 0.025, output: 1.25, deprecated: true, deprecationDate: "2026-04-20" },
80
99
  };
100
+
101
+ // ─── Catalog ──────────────────────────────────────────────────────────────────
102
+ // Metadata (deprecated, deprecationDate, limitedAvailability) is read directly
103
+ // from the AnthropicTextPricing entries — no need for separate groups.
104
+
105
+ export const ANTHROPIC_MODEL_CATALOG: ModelCatalogEntry[] = [
106
+ ...completions(AnthropicAllModels, "anthropic", AnthropicTextPricing),
107
+ ];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Cerebras pricing (USD per 1M tokens)
3
+ * Source: https://cerebras.ai/pricing
4
+ */
5
+ export const CerebrasTextPricing: Record<string, { input: number; output: number }> = {
6
+ "llama3.1-8b": { input: 0.10, output: 0.10 },
7
+ "llama3.3-70b": { input: 0.85, output: 1.20 },
8
+ "qwen-3-235b-a22b-instruct-2507": { input: 0.60, output: 1.20 },
9
+ "gpt-oss-120b": { input: 0.25, output: 0.69 },
10
+ "zai-glm-4.7": { input: 2.25, output: 2.75 },
11
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * GitHub Copilot pricing — "premium request" multiplier system.
3
+ *
4
+ * GitHub Copilot does NOT charge per token. Instead each model call costs a
5
+ * certain number of "premium requests" from the subscriber's monthly allowance.
6
+ * All models are effectively $0/token from the perspective of knowhow pricing,
7
+ * but we store the multiplier as metadata for informational purposes.
8
+ *
9
+ * Copilot Individual: 300 premium requests/month
10
+ * Copilot Pro: 300 premium requests/month
11
+ * Copilot Business: 300 premium requests/month (per seat)
12
+ * Copilot Enterprise: 300 premium requests/month (per seat)
13
+ *
14
+ * Model IDs are as returned by https://api.githubcopilot.com/models
15
+ * Source: https://docs.github.com/en/copilot/reference/ai-models/supported-models
16
+ */
17
+
18
+ /** Copilot premium request multipliers (informational only) */
19
+ export const CopilotModelMultipliers: Record<string, number> = {
20
+ // OpenAI models
21
+ "gpt-4o": 0, // free (base request)
22
+ "gpt-4.1": 0, // free (base request)
23
+ "gpt-5-mini": 0, // free (base request)
24
+ "gpt-5.2": 1,
25
+ "gpt-5.2-codex": 1,
26
+ "gpt-5.3-codex": 1,
27
+ "gpt-5.4": 1,
28
+ "gpt-5.4-mini": 0.33,
29
+ "gpt-5.4-nano": 0.25,
30
+ "gpt-5.5": 7.5, // promotional until further notice
31
+ "gpt-5": 1,
32
+ "gpt-5.1": 1,
33
+ "gpt-5.1-codex": 1,
34
+ "gpt-5.1-codex-max": 1,
35
+ "gpt-5.1-codex-mini": 1,
36
+ // Anthropic models
37
+ "claude-haiku-4.5": 0.33,
38
+ "claude-sonnet-4": 1,
39
+ "claude-sonnet-4.5": 1,
40
+ "claude-sonnet-4.6": 1,
41
+ "claude-opus-4.5": 3,
42
+ "claude-opus-4.6": 3,
43
+ "claude-opus-41": 3,
44
+ "claude-opus-4.7": 7.5, // promotional until April 30, 2026
45
+ // Google models
46
+ "gemini-2.5-pro": 1,
47
+ "gemini-3-flash-preview": 0.33,
48
+ "gemini-3.1-pro-preview": 1,
49
+ "gemini-3-pro-preview": 1,
50
+ // xAI models
51
+ "grok-code-fast-1": 0.25,
52
+ };
53
+
54
+ /**
55
+ * Copilot pricing is all $0/token — consumption is via premium request allowance.
56
+ * This map is used by the check-model-pricing script to recognise registered models.
57
+ */
58
+ export const CopilotTextPricing: Record<string, { input: number; output: number }> = Object.fromEntries(
59
+ Object.keys(CopilotModelMultipliers).map((id) => [id, { input: 0.0, output: 0.0 }])
60
+ );
@@ -0,0 +1,15 @@
1
+ /**
2
+ * DeepSeek pricing (USD per 1M tokens)
3
+ * Source: https://platform.deepseek.com/pricing
4
+ */
5
+ export const DeepSeekTextPricing: Record<string, { input: number; output: number; cached_input?: number }> = {
6
+ // DeepSeek V3 / deepseek-chat — updated 2026-04 (now routes to DeepSeek V3-0324)
7
+ // Source: api-docs.deepseek.com/quick_start/pricing
8
+ "deepseek-chat": { input: 0.28, output: 0.42, cached_input: 0.028 },
9
+ // DeepSeek R1 / deepseek-reasoner — same unified pricing as V3
10
+ // Source: api-docs.deepseek.com/quick_start/pricing (costgoat.com verification)
11
+ "deepseek-reasoner": { input: 0.28, output: 0.42, cached_input: 0.028 },
12
+ // DeepSeek V4 Flash & Pro
13
+ "deepseek-v4-flash": { input: 0.14, output: 0.28 },
14
+ "deepseek-v4-pro": { input: 1.74, output: 3.48 },
15
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Fireworks AI pricing (USD per 1M tokens)
3
+ * Source: https://fireworks.ai/pricing
4
+ */
5
+ export const FireworksTextPricing: Record<string, { input: number; output: number; cache_hit?: number }> = {
6
+ // Moonshot AI
7
+ "accounts/fireworks/models/kimi-k2-6": { input: 0.95, cache_hit: 0.16, output: 4.0 },
8
+ "accounts/fireworks/models/kimi-k2-5": { input: 0.60, cache_hit: 0.10, output: 3.0 },
9
+
10
+ // MiniMax
11
+ "accounts/fireworks/models/minimax-m2-7": { input: 0.30, cache_hit: 0.06, output: 1.20 },
12
+ "accounts/fireworks/models/minimax-m2-5": { input: 0.30, cache_hit: 0.03, output: 1.20 },
13
+
14
+ // Qwen
15
+ "accounts/fireworks/models/qwen3-6-plus": { input: 0.50, cache_hit: 0.10, output: 3.0 },
16
+ "accounts/fireworks/models/qwen3p6-plus": { input: 0.50, cache_hit: 0.10, output: 3.0 },
17
+ "accounts/fireworks/models/qwen3-vl-30b-a3b-thinking": { input: 0.15, cache_hit: 0.08, output: 0.60 },
18
+ "accounts/fireworks/models/qwen3-vl-30b-a3b-instruct": { input: 0.15, cache_hit: 0.08, output: 0.60 },
19
+ "accounts/fireworks/models/qwen3-8b": { input: 0.20, cache_hit: 0.10, output: 0.20 },
20
+
21
+ // Z.ai
22
+ "accounts/fireworks/models/glm-5-1": { input: 1.40, cache_hit: 0.26, output: 4.40 },
23
+ "accounts/fireworks/models/glm-5": { input: 1.00, cache_hit: 0.20, output: 3.20 },
24
+ "accounts/fireworks/models/glm-4-7": { input: 0.60, cache_hit: 0.30, output: 2.20 },
25
+
26
+ // DeepSeek AI
27
+ "accounts/fireworks/models/deepseek-v3-2": { input: 0.56, cache_hit: 0.28, output: 1.68 },
28
+ "accounts/fireworks/models/deepseek-v3-1": { input: 0.56, cache_hit: 0.28, output: 1.68 },
29
+
30
+ // OpenAI OSS
31
+ "accounts/fireworks/models/gpt-oss-120b": { input: 0.15, cache_hit: 0.01, output: 0.60 },
32
+ };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * GitHub Models pricing (USD per 1M tokens)
3
+ * Source: https://github.com/marketplace/models
4
+ * All models are free within rate limits for GitHub users.
5
+ * Low-tier (higher rate limits) and high-tier (lower rate limits) exist.
6
+ */
7
+ export const GitHubModelsTextPricing: Record<string, { input: number; output: number }> = {
8
+ // OpenAI via GitHub (free)
9
+ "openai/gpt-4o": { input: 0.0, output: 0.0 },
10
+ "openai/gpt-4o-mini": { input: 0.0, output: 0.0 },
11
+ "openai/o1": { input: 0.0, output: 0.0 },
12
+ "openai/o1-mini": { input: 0.0, output: 0.0 },
13
+ "openai/o3-mini": { input: 0.0, output: 0.0 },
14
+ "openai/o4-mini": { input: 0.0, output: 0.0 },
15
+ "openai/gpt-4.1": { input: 0.0, output: 0.0 },
16
+ "openai/gpt-4.1-mini": { input: 0.0, output: 0.0 },
17
+ "openai/gpt-4.1-nano": { input: 0.0, output: 0.0 },
18
+ "openai/o3": { input: 0.0, output: 0.0 },
19
+ // DeepSeek via GitHub (free)
20
+ "deepseek/deepseek-r1": { input: 0.0, output: 0.0 },
21
+ "deepseek/deepseek-v3-0324": { input: 0.0, output: 0.0 },
22
+ // Microsoft Phi via GitHub (free)
23
+ "microsoft/phi-4": { input: 0.0, output: 0.0 },
24
+ "microsoft/phi-4-mini-instruct": { input: 0.0, output: 0.0 },
25
+ "microsoft/phi-4-multimodal-instruct": { input: 0.0, output: 0.0 },
26
+ "microsoft/phi-4-mini-reasoning": { input: 0.0, output: 0.0 },
27
+ "microsoft/phi-4-reasoning": { input: 0.0, output: 0.0 },
28
+ "microsoft/phi-3-medium-128k-instruct": { input: 0.0, output: 0.0 },
29
+ "microsoft/phi-3-medium-4k-instruct": { input: 0.0, output: 0.0 },
30
+ "microsoft/phi-3-mini-128k-instruct": { input: 0.0, output: 0.0 },
31
+ "microsoft/phi-3-mini-4k-instruct": { input: 0.0, output: 0.0 },
32
+ "microsoft/phi-3-small-128k-instruct": { input: 0.0, output: 0.0 },
33
+ "microsoft/phi-3-small-8k-instruct": { input: 0.0, output: 0.0 },
34
+ "microsoft/phi-3.5-mini-instruct": { input: 0.0, output: 0.0 },
35
+ "microsoft/phi-3.5-moe-instruct": { input: 0.0, output: 0.0 },
36
+ "microsoft/phi-3.5-vision-instruct": { input: 0.0, output: 0.0 },
37
+ "microsoft/mai-ds-r1": { input: 0.0, output: 0.0 },
38
+ // Meta Llama via GitHub (free)
39
+ "meta/llama-3.3-70b-instruct": { input: 0.0, output: 0.0 },
40
+ "meta/llama-3.2-11b-vision-instruct": { input: 0.0, output: 0.0 },
41
+ "meta/llama-3.1-405b-instruct": { input: 0.0, output: 0.0 },
42
+ "meta/llama-3.2-90b-vision-instruct": { input: 0.0, output: 0.0 },
43
+ "meta/llama-4-maverick-17b-128e-instruct-fp8": { input: 0.0, output: 0.0 },
44
+ "meta/llama-4-scout-17b-16e-instruct": { input: 0.0, output: 0.0 },
45
+ "meta/meta-llama-3-70b-instruct": { input: 0.0, output: 0.0 },
46
+ "meta/meta-llama-3-8b-instruct": { input: 0.0, output: 0.0 },
47
+ "meta/meta-llama-3.1-405b-instruct": { input: 0.0, output: 0.0 },
48
+ "meta/meta-llama-3.1-70b-instruct": { input: 0.0, output: 0.0 },
49
+ "meta/meta-llama-3.1-8b-instruct": { input: 0.0, output: 0.0 },
50
+ // Mistral via GitHub (free)
51
+ "mistral-ai/mistral-large-2411": { input: 0.0, output: 0.0 },
52
+ "mistral-ai/mistral-small-2503": { input: 0.0, output: 0.0 },
53
+ "mistral-ai/codestral-2501": { input: 0.0, output: 0.0 },
54
+ "mistral-ai/ministral-3b": { input: 0.0, output: 0.0 },
55
+ "mistral-ai/mistral-medium-2505": { input: 0.0, output: 0.0 },
56
+ "mistral-ai/mistral-nemo": { input: 0.0, output: 0.0 },
57
+ // Cohere via GitHub (free)
58
+ "cohere/cohere-command-r-plus-08-2024": { input: 0.0, output: 0.0 },
59
+ "cohere/cohere-command-r-08-2024": { input: 0.0, output: 0.0 },
60
+ "cohere/cohere-command-a": { input: 0.0, output: 0.0 },
61
+ // AI21 via GitHub (free)
62
+ "ai21-labs/ai21-jamba-1.5-mini": { input: 0.0, output: 0.0 },
63
+ "ai21-labs/ai21-jamba-1.5-large": { input: 0.0, output: 0.0 },
64
+ // Core42
65
+ "core42/jais-30b-chat": { input: 0.0, output: 0.0 },
66
+ // xAI via GitHub (free)
67
+ "xai/grok-3": { input: 0.0, output: 0.0 },
68
+ "xai/grok-3-mini": { input: 0.0, output: 0.0 },
69
+ };