@use-lattice/litmus 0.121.3

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 (199) hide show
  1. package/LICENSE +19 -0
  2. package/dist/src/accounts-Bt1oJb1Z.cjs +219 -0
  3. package/dist/src/accounts-DjOU8Rm3.js +178 -0
  4. package/dist/src/agentic-utils-D03IiXQc.js +153 -0
  5. package/dist/src/agentic-utils-Dh7xaMQM.cjs +180 -0
  6. package/dist/src/agents-C6BIMlZa.js +231 -0
  7. package/dist/src/agents-DvIpNX1L.cjs +666 -0
  8. package/dist/src/agents-ZP0RP9vV.cjs +231 -0
  9. package/dist/src/agents-maJXdjbR.js +665 -0
  10. package/dist/src/aimlapi-BTbQjG2E.cjs +30 -0
  11. package/dist/src/aimlapi-CwMxqfXP.js +30 -0
  12. package/dist/src/audio-BBUdvsde.cjs +97 -0
  13. package/dist/src/audio-D5DPZ7I-.js +97 -0
  14. package/dist/src/base-BEysXrkq.cjs +222 -0
  15. package/dist/src/base-C451JQfq.js +193 -0
  16. package/dist/src/blobs-BY8MDmpo.js +230 -0
  17. package/dist/src/blobs-BgcNn97m.cjs +256 -0
  18. package/dist/src/cache-BBE_lsTA.cjs +4 -0
  19. package/dist/src/cache-BkrqU5Ba.js +237 -0
  20. package/dist/src/cache-DsCxFlsZ.cjs +297 -0
  21. package/dist/src/chat-CPJWDP6a.cjs +289 -0
  22. package/dist/src/chat-CXX3xzkk.cjs +811 -0
  23. package/dist/src/chat-CcDgZFJ4.js +787 -0
  24. package/dist/src/chat-Dz5ZeGO2.js +289 -0
  25. package/dist/src/chatkit-Dw0mKkML.cjs +1158 -0
  26. package/dist/src/chatkit-swAIVuea.js +1157 -0
  27. package/dist/src/chunk-DEq-mXcV.js +15 -0
  28. package/dist/src/claude-agent-sdk-BXZJtOg6.js +379 -0
  29. package/dist/src/claude-agent-sdk-CkfyjDoG.cjs +383 -0
  30. package/dist/src/cloudflare-ai-BzpJcqUH.js +161 -0
  31. package/dist/src/cloudflare-ai-Cmy_R1y2.cjs +161 -0
  32. package/dist/src/cloudflare-gateway-B9tVQKok.cjs +272 -0
  33. package/dist/src/cloudflare-gateway-DrD3ew3H.js +272 -0
  34. package/dist/src/codex-sdk-Dezj9Nwm.js +1056 -0
  35. package/dist/src/codex-sdk-Dl9D4k5B.cjs +1060 -0
  36. package/dist/src/cometapi-C-9YvCHC.js +54 -0
  37. package/dist/src/cometapi-DHgDKoO2.cjs +54 -0
  38. package/dist/src/completion-B8Ctyxpr.js +120 -0
  39. package/dist/src/completion-Cxrt08sj.cjs +131 -0
  40. package/dist/src/createHash-BwgE13yv.cjs +27 -0
  41. package/dist/src/createHash-DmPQkvBh.js +15 -0
  42. package/dist/src/docker-BiqcTwLv.js +80 -0
  43. package/dist/src/docker-C7tEJnP-.cjs +80 -0
  44. package/dist/src/esm-C62Zofr1.cjs +409 -0
  45. package/dist/src/esm-DMVc93eh.js +379 -0
  46. package/dist/src/evalResult-C3NJPQOo.cjs +301 -0
  47. package/dist/src/evalResult-C7JJAPBb.js +295 -0
  48. package/dist/src/evalResult-DoVTZZWI.cjs +2 -0
  49. package/dist/src/extractor-DnMD3fwt.cjs +391 -0
  50. package/dist/src/extractor-DtlL28vL.js +374 -0
  51. package/dist/src/fetch-BTxakTSg.cjs +1133 -0
  52. package/dist/src/fetch-DQckpUFz.js +928 -0
  53. package/dist/src/fileExtensions-DnqA1y9x.js +85 -0
  54. package/dist/src/fileExtensions-bYh77CN8.cjs +114 -0
  55. package/dist/src/genaiTracer-CyZrmaK0.cjs +268 -0
  56. package/dist/src/genaiTracer-D3fD9dNV.js +256 -0
  57. package/dist/src/graders-BNscxFrU.js +13644 -0
  58. package/dist/src/graders-D2oE9Msq.js +2 -0
  59. package/dist/src/graders-c0Ez_w-9.cjs +2 -0
  60. package/dist/src/graders-d0F2M3e9.cjs +14056 -0
  61. package/dist/src/image-0ZhE0VlR.cjs +280 -0
  62. package/dist/src/image-CWE1pdNv.js +257 -0
  63. package/dist/src/image-D9ZK6hwL.js +163 -0
  64. package/dist/src/image-DKZgZITg.cjs +163 -0
  65. package/dist/src/index.cjs +11366 -0
  66. package/dist/src/index.d.cts +19640 -0
  67. package/dist/src/index.d.ts +19641 -0
  68. package/dist/src/index.js +11306 -0
  69. package/dist/src/invariant-Ddh24eXh.js +25 -0
  70. package/dist/src/invariant-kfQ8Bu82.cjs +30 -0
  71. package/dist/src/knowledgeBase-BgPyGFUd.cjs +122 -0
  72. package/dist/src/knowledgeBase-DyHilYaP.js +122 -0
  73. package/dist/src/litellm-CyMeneHS.js +135 -0
  74. package/dist/src/litellm-DWDF73yF.cjs +135 -0
  75. package/dist/src/logger-C40ZGil9.js +717 -0
  76. package/dist/src/logger-DyfK9PBt.cjs +917 -0
  77. package/dist/src/luma-ray-BAU9X_ep.cjs +315 -0
  78. package/dist/src/luma-ray-nwVseBbv.js +313 -0
  79. package/dist/src/messages-B5ADWTTv.js +245 -0
  80. package/dist/src/messages-BCnZfqrS.cjs +257 -0
  81. package/dist/src/meteor-DLZZ3osF.cjs +134 -0
  82. package/dist/src/meteor-DUiCJRC-.js +134 -0
  83. package/dist/src/modelslab-00cveB8L.cjs +163 -0
  84. package/dist/src/modelslab-D9sCU_L7.js +163 -0
  85. package/dist/src/nova-reel-CTapvqYH.js +276 -0
  86. package/dist/src/nova-reel-DlWuuroF.cjs +278 -0
  87. package/dist/src/nova-sonic-5UPWfeMv.cjs +363 -0
  88. package/dist/src/nova-sonic-BhSwQNym.js +363 -0
  89. package/dist/src/openai-BWrJK9d8.cjs +52 -0
  90. package/dist/src/openai-DumO8WQn.js +47 -0
  91. package/dist/src/openclaw-B8brrjC_.cjs +577 -0
  92. package/dist/src/openclaw-Bkayww9q.js +571 -0
  93. package/dist/src/opencode-sdk-7xjoDNiM.cjs +562 -0
  94. package/dist/src/opencode-sdk-SGwAPxht.js +558 -0
  95. package/dist/src/otlpReceiver-CoAHfAN9.cjs +15 -0
  96. package/dist/src/otlpReceiver-oO3EQwI9.js +14 -0
  97. package/dist/src/providerRegistry-4yjhaEM8.js +45 -0
  98. package/dist/src/providerRegistry-DhV4rJIc.cjs +50 -0
  99. package/dist/src/providers-B5RJVG-7.cjs +33609 -0
  100. package/dist/src/providers-BdmZCLzV.js +33262 -0
  101. package/dist/src/providers-CxtRxn8e.js +2 -0
  102. package/dist/src/providers-DnQLNbx1.cjs +3 -0
  103. package/dist/src/pythonUtils-BD0druiM.cjs +275 -0
  104. package/dist/src/pythonUtils-IBhn5YGR.js +249 -0
  105. package/dist/src/quiverai-BDOwZBsM.cjs +213 -0
  106. package/dist/src/quiverai-D3JTF5lD.js +213 -0
  107. package/dist/src/responses-B2LCDCXZ.js +667 -0
  108. package/dist/src/responses-BvNm4Xv9.cjs +685 -0
  109. package/dist/src/rubyUtils-B0NwnfpY.cjs +245 -0
  110. package/dist/src/rubyUtils-BroxzZ7c.cjs +2 -0
  111. package/dist/src/rubyUtils-hqVw5UvJ.js +222 -0
  112. package/dist/src/sagemaker-Cno2V-Sx.js +689 -0
  113. package/dist/src/sagemaker-fV_KUgs5.cjs +691 -0
  114. package/dist/src/server-BOuAXb06.cjs +238 -0
  115. package/dist/src/server-CtI-EWzm.cjs +2 -0
  116. package/dist/src/server-Cy3DZymt.js +189 -0
  117. package/dist/src/slack-CP8xBePa.js +135 -0
  118. package/dist/src/slack-DSQ1yXVb.cjs +135 -0
  119. package/dist/src/store-BwDDaBjb.cjs +246 -0
  120. package/dist/src/store-DcbLC593.cjs +2 -0
  121. package/dist/src/store-IGpqMIkv.js +240 -0
  122. package/dist/src/tables-3Q2cL7So.cjs +373 -0
  123. package/dist/src/tables-Bi2fjr4W.js +288 -0
  124. package/dist/src/telemetry-Bg2WqF79.js +161 -0
  125. package/dist/src/telemetry-D0x6u5kX.cjs +166 -0
  126. package/dist/src/telemetry-DXNimrI0.cjs +2 -0
  127. package/dist/src/text-B_UCRPp2.js +22 -0
  128. package/dist/src/text-CW1cyrwj.cjs +33 -0
  129. package/dist/src/tokenUsageUtils-NYT-WKS6.js +138 -0
  130. package/dist/src/tokenUsageUtils-bVa1ga6f.cjs +173 -0
  131. package/dist/src/transcription-Cl_W16Pr.js +122 -0
  132. package/dist/src/transcription-yt1EecY8.cjs +124 -0
  133. package/dist/src/transform-BCtGrl_W.cjs +228 -0
  134. package/dist/src/transform-Bv6gG2MJ.cjs +1688 -0
  135. package/dist/src/transform-CY1wbpRy.js +1507 -0
  136. package/dist/src/transform-DU8rUL9P.cjs +2 -0
  137. package/dist/src/transform-yWaShiKr.js +216 -0
  138. package/dist/src/transformersAvailability-BGkzavwb.js +35 -0
  139. package/dist/src/transformersAvailability-DKoRtQLy.cjs +35 -0
  140. package/dist/src/types-5aqHpBwE.cjs +3769 -0
  141. package/dist/src/types-Bn6D9c4U.js +3300 -0
  142. package/dist/src/util-BkKlTkI2.js +293 -0
  143. package/dist/src/util-CTh0bfOm.cjs +1119 -0
  144. package/dist/src/util-D17oBwo7.cjs +328 -0
  145. package/dist/src/util-DsS_-v4p.js +613 -0
  146. package/dist/src/util-DuntT1Ga.js +951 -0
  147. package/dist/src/util-aWjdCYMI.cjs +667 -0
  148. package/dist/src/utils-CisQwpjA.js +94 -0
  149. package/dist/src/utils-yWamDvmz.cjs +123 -0
  150. package/dist/tsconfig.tsbuildinfo +1 -0
  151. package/drizzle/0000_lush_hellion.sql +36 -0
  152. package/drizzle/0001_wide_calypso.sql +3 -0
  153. package/drizzle/0002_tidy_juggernaut.sql +1 -0
  154. package/drizzle/0003_lively_naoko.sql +8 -0
  155. package/drizzle/0004_minor_peter_quill.sql +19 -0
  156. package/drizzle/0005_silky_millenium_guard.sql +2 -0
  157. package/drizzle/0006_harsh_caretaker.sql +42 -0
  158. package/drizzle/0007_cloudy_wong.sql +1 -0
  159. package/drizzle/0008_broad_boomer.sql +2 -0
  160. package/drizzle/0009_strong_marten_broadcloak.sql +19 -0
  161. package/drizzle/0010_needy_bishop.sql +11 -0
  162. package/drizzle/0011_moaning_millenium_guard.sql +1 -0
  163. package/drizzle/0012_late_marten_broadcloak.sql +2 -0
  164. package/drizzle/0013_previous_dormammu.sql +9 -0
  165. package/drizzle/0014_lazy_captain_universe.sql +2 -0
  166. package/drizzle/0015_zippy_wallop.sql +29 -0
  167. package/drizzle/0016_jazzy_zemo.sql +2 -0
  168. package/drizzle/0017_reflective_praxagora.sql +4 -0
  169. package/drizzle/0018_fat_vanisher.sql +22 -0
  170. package/drizzle/0019_new_clint_barton.sql +8 -0
  171. package/drizzle/0020_skinny_maverick.sql +1 -0
  172. package/drizzle/0021_mysterious_madelyne_pryor.sql +13 -0
  173. package/drizzle/0022_sleepy_ultimo.sql +25 -0
  174. package/drizzle/0023_wooden_mandrill.sql +2 -0
  175. package/drizzle/AGENTS.md +68 -0
  176. package/drizzle/CLAUDE.md +1 -0
  177. package/drizzle/meta/0000_snapshot.json +221 -0
  178. package/drizzle/meta/0001_snapshot.json +214 -0
  179. package/drizzle/meta/0002_snapshot.json +221 -0
  180. package/drizzle/meta/0005_snapshot.json +369 -0
  181. package/drizzle/meta/0006_snapshot.json +638 -0
  182. package/drizzle/meta/0007_snapshot.json +640 -0
  183. package/drizzle/meta/0008_snapshot.json +649 -0
  184. package/drizzle/meta/0009_snapshot.json +554 -0
  185. package/drizzle/meta/0010_snapshot.json +619 -0
  186. package/drizzle/meta/0011_snapshot.json +627 -0
  187. package/drizzle/meta/0012_snapshot.json +639 -0
  188. package/drizzle/meta/0013_snapshot.json +717 -0
  189. package/drizzle/meta/0014_snapshot.json +717 -0
  190. package/drizzle/meta/0015_snapshot.json +897 -0
  191. package/drizzle/meta/0016_snapshot.json +1031 -0
  192. package/drizzle/meta/0018_snapshot.json +1210 -0
  193. package/drizzle/meta/0019_snapshot.json +1165 -0
  194. package/drizzle/meta/0020_snapshot.json +1232 -0
  195. package/drizzle/meta/0021_snapshot.json +1311 -0
  196. package/drizzle/meta/0022_snapshot.json +1481 -0
  197. package/drizzle/meta/0023_snapshot.json +1496 -0
  198. package/drizzle/meta/_journal.json +174 -0
  199. package/package.json +240 -0
@@ -0,0 +1,613 @@
1
+ import { f as getAjv, h as safeJsonStringify } from "./logger-C40ZGil9.js";
2
+ import { l as maybeLoadFromExternalFileWithVars } from "./util-DuntT1Ga.js";
3
+ import { g as calculateCost } from "./fetch-DQckpUFz.js";
4
+ import OpenAI from "openai";
5
+ //#region src/providers/openai/util.ts
6
+ const ajv = getAjv();
7
+ const OPENAI_CHAT_MODELS = [
8
+ {
9
+ id: "gpt-4o-mini-tts",
10
+ cost: {
11
+ input: .6 / 1e6,
12
+ output: 0 / 1e6,
13
+ audioOutput: 12 / 1e6
14
+ }
15
+ },
16
+ ...["gpt-4o-search-preview", "gpt-4o-search-preview-2025-03-11"].map((model) => ({
17
+ id: model,
18
+ cost: {
19
+ input: 2.5 / 1e6,
20
+ output: 10 / 1e6
21
+ }
22
+ })),
23
+ ...["gpt-4o-mini-search-preview", "gpt-4o-mini-search-preview-2025-03-11"].map((model) => ({
24
+ id: model,
25
+ cost: {
26
+ input: .15 / 1e6,
27
+ output: .6 / 1e6
28
+ }
29
+ })),
30
+ ...["computer-use-preview", "computer-use-preview-2025-03-11"].map((model) => ({
31
+ id: model,
32
+ cost: {
33
+ input: 3 / 1e6,
34
+ output: 12 / 1e6
35
+ }
36
+ })),
37
+ ...["chatgpt-4o-latest"].map((model) => ({
38
+ id: model,
39
+ cost: {
40
+ input: 5 / 1e6,
41
+ output: 15 / 1e6
42
+ }
43
+ })),
44
+ ...["gpt-4.1", "gpt-4.1-2025-04-14"].map((model) => ({
45
+ id: model,
46
+ cost: {
47
+ input: 2 / 1e6,
48
+ output: 8 / 1e6
49
+ }
50
+ })),
51
+ ...["gpt-4.1-mini", "gpt-4.1-mini-2025-04-14"].map((model) => ({
52
+ id: model,
53
+ cost: {
54
+ input: .4 / 1e6,
55
+ output: 1.6 / 1e6
56
+ }
57
+ })),
58
+ ...["gpt-4.1-nano", "gpt-4.1-nano-2025-04-14"].map((model) => ({
59
+ id: model,
60
+ cost: {
61
+ input: .1 / 1e6,
62
+ output: .4 / 1e6
63
+ }
64
+ })),
65
+ ...["o1-pro", "o1-pro-2025-03-19"].map((model) => ({
66
+ id: model,
67
+ cost: {
68
+ input: 150 / 1e6,
69
+ output: 600 / 1e6
70
+ }
71
+ })),
72
+ ...[
73
+ "o1",
74
+ "o1-2024-12-17",
75
+ "o1-preview",
76
+ "o1-preview-2024-09-12"
77
+ ].map((model) => ({
78
+ id: model,
79
+ cost: {
80
+ input: 15 / 1e6,
81
+ output: 60 / 1e6
82
+ }
83
+ })),
84
+ ...["o1-mini", "o1-mini-2024-09-12"].map((model) => ({
85
+ id: model,
86
+ cost: {
87
+ input: 1.1 / 1e6,
88
+ output: 4.4 / 1e6
89
+ }
90
+ })),
91
+ ...["o3", "o3-2025-04-16"].map((model) => ({
92
+ id: model,
93
+ cost: {
94
+ input: 2 / 1e6,
95
+ output: 8 / 1e6
96
+ }
97
+ })),
98
+ ...["o3-pro", "o3-pro-2025-06-10"].map((model) => ({
99
+ id: model,
100
+ cost: {
101
+ input: 20 / 1e6,
102
+ output: 80 / 1e6
103
+ }
104
+ })),
105
+ ...["o3-mini", "o3-mini-2025-01-31"].map((model) => ({
106
+ id: model,
107
+ cost: {
108
+ input: 1.1 / 1e6,
109
+ output: 4.4 / 1e6
110
+ }
111
+ })),
112
+ ...[
113
+ "gpt-4o-audio-preview",
114
+ "gpt-4o-audio-preview-2024-12-17",
115
+ "gpt-4o-audio-preview-2024-10-01",
116
+ "gpt-4o-audio-preview-2025-06-03"
117
+ ].map((model) => ({
118
+ id: model,
119
+ cost: {
120
+ input: 2.5 / 1e6,
121
+ output: 10 / 1e6,
122
+ audioInput: 40 / 1e6,
123
+ audioOutput: 80 / 1e6
124
+ }
125
+ })),
126
+ ...["gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17"].map((model) => ({
127
+ id: model,
128
+ cost: {
129
+ input: .15 / 1e6,
130
+ output: .6 / 1e6,
131
+ audioInput: 10 / 1e6,
132
+ audioOutput: 20 / 1e6
133
+ }
134
+ })),
135
+ ...[
136
+ "gpt-4o",
137
+ "gpt-4o-2024-11-20",
138
+ "gpt-4o-2024-08-06"
139
+ ].map((model) => ({
140
+ id: model,
141
+ cost: {
142
+ input: 2.5 / 1e6,
143
+ output: 10 / 1e6
144
+ }
145
+ })),
146
+ ...["gpt-4o-2024-05-13"].map((model) => ({
147
+ id: model,
148
+ cost: {
149
+ input: 5 / 1e6,
150
+ output: 15 / 1e6
151
+ }
152
+ })),
153
+ ...["gpt-4o-mini", "gpt-4o-mini-2024-07-18"].map((model) => ({
154
+ id: model,
155
+ cost: {
156
+ input: .15 / 1e6,
157
+ output: .6 / 1e6
158
+ }
159
+ })),
160
+ ...[
161
+ "gpt-4",
162
+ "gpt-4-0613",
163
+ "gpt-4-0314"
164
+ ].map((model) => ({
165
+ id: model,
166
+ cost: {
167
+ input: 30 / 1e6,
168
+ output: 60 / 1e6
169
+ }
170
+ })),
171
+ ...[
172
+ "gpt-4-32k",
173
+ "gpt-4-32k-0314",
174
+ "gpt-4-32k-0613"
175
+ ].map((model) => ({
176
+ id: model,
177
+ cost: {
178
+ input: 60 / 1e6,
179
+ output: 120 / 1e6
180
+ }
181
+ })),
182
+ ...[
183
+ "gpt-4-turbo",
184
+ "gpt-4-turbo-2024-04-09",
185
+ "gpt-4-turbo-preview",
186
+ "gpt-4-0125-preview",
187
+ "gpt-4-1106-preview",
188
+ "gpt-4-1106-vision-preview",
189
+ "gpt-4-vision-preview"
190
+ ].map((model) => ({
191
+ id: model,
192
+ cost: {
193
+ input: 10 / 1e6,
194
+ output: 30 / 1e6
195
+ }
196
+ })),
197
+ {
198
+ id: "gpt-3.5-turbo",
199
+ cost: {
200
+ input: .5 / 1e6,
201
+ output: 1.5 / 1e6
202
+ }
203
+ },
204
+ {
205
+ id: "gpt-3.5-turbo-0125",
206
+ cost: {
207
+ input: .5 / 1e6,
208
+ output: 1.5 / 1e6
209
+ }
210
+ },
211
+ {
212
+ id: "gpt-3.5-turbo-1106",
213
+ cost: {
214
+ input: 1 / 1e6,
215
+ output: 2 / 1e6
216
+ }
217
+ },
218
+ ...["gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613"].map((model) => ({
219
+ id: model,
220
+ cost: {
221
+ input: 1.5 / 1e6,
222
+ output: 2 / 1e6
223
+ }
224
+ })),
225
+ ...["gpt-3.5-turbo-16k", "gpt-3.5-turbo-16k-0613"].map((model) => ({
226
+ id: model,
227
+ cost: {
228
+ input: 3 / 1e6,
229
+ output: 4 / 1e6
230
+ }
231
+ })),
232
+ ...["gpt-3.5-turbo-instruct"].map((model) => ({
233
+ id: model,
234
+ cost: {
235
+ input: 1.5 / 1e6,
236
+ output: 2 / 1e6
237
+ }
238
+ })),
239
+ ...["o4-mini", "o4-mini-2025-04-16"].map((model) => ({
240
+ id: model,
241
+ cost: {
242
+ input: 1.1 / 1e6,
243
+ output: 4.4 / 1e6
244
+ }
245
+ })),
246
+ ...[
247
+ "gpt-5",
248
+ "gpt-5-2025-08-07",
249
+ "gpt-5-chat",
250
+ "gpt-5-chat-latest"
251
+ ].map((model) => ({
252
+ id: model,
253
+ cost: {
254
+ input: 1.25 / 1e6,
255
+ output: 10 / 1e6
256
+ }
257
+ })),
258
+ ...["gpt-5-nano", "gpt-5-nano-2025-08-07"].map((model) => ({
259
+ id: model,
260
+ cost: {
261
+ input: .05 / 1e6,
262
+ output: .4 / 1e6
263
+ }
264
+ })),
265
+ ...["gpt-5-mini", "gpt-5-mini-2025-08-07"].map((model) => ({
266
+ id: model,
267
+ cost: {
268
+ input: .25 / 1e6,
269
+ output: 2 / 1e6
270
+ }
271
+ })),
272
+ ...["codex-mini-latest"].map((model) => ({
273
+ id: model,
274
+ cost: {
275
+ input: 1.5 / 1e6,
276
+ output: 6 / 1e6
277
+ }
278
+ })),
279
+ ...["gpt-5-codex"].map((model) => ({
280
+ id: model,
281
+ cost: {
282
+ input: 1.25 / 1e6,
283
+ output: 10 / 1e6
284
+ }
285
+ })),
286
+ ...["gpt-5-pro", "gpt-5-pro-2025-10-06"].map((model) => ({
287
+ id: model,
288
+ cost: {
289
+ input: 15 / 1e6,
290
+ output: 120 / 1e6
291
+ }
292
+ })),
293
+ ...[
294
+ "gpt-5.1",
295
+ "gpt-5.1-2025-11-13",
296
+ "gpt-5.1-chat-latest"
297
+ ].map((model) => ({
298
+ id: model,
299
+ cost: {
300
+ input: 1.25 / 1e6,
301
+ output: 10 / 1e6
302
+ }
303
+ })),
304
+ ...["gpt-5.1-nano"].map((model) => ({
305
+ id: model,
306
+ cost: {
307
+ input: .05 / 1e6,
308
+ output: .4 / 1e6
309
+ }
310
+ })),
311
+ ...["gpt-5.1-mini"].map((model) => ({
312
+ id: model,
313
+ cost: {
314
+ input: .25 / 1e6,
315
+ output: 2 / 1e6
316
+ }
317
+ })),
318
+ ...["gpt-5.1-codex", "gpt-5.1-codex-max"].map((model) => ({
319
+ id: model,
320
+ cost: {
321
+ input: 1.25 / 1e6,
322
+ output: 10 / 1e6
323
+ }
324
+ })),
325
+ ...[
326
+ "gpt-5.2",
327
+ "gpt-5.2-2025-12-11",
328
+ "gpt-5.2-chat-latest",
329
+ "gpt-5.2-codex"
330
+ ].map((model) => ({
331
+ id: model,
332
+ cost: {
333
+ input: 1.75 / 1e6,
334
+ output: 14 / 1e6
335
+ }
336
+ })),
337
+ ...["gpt-5.2-pro", "gpt-5.2-pro-2025-12-11"].map((model) => ({
338
+ id: model,
339
+ cost: {
340
+ input: 15 / 1e6,
341
+ output: 120 / 1e6
342
+ }
343
+ })),
344
+ ...["gpt-5.3-chat-latest", "gpt-5.3-codex"].map((model) => ({
345
+ id: model,
346
+ cost: {
347
+ input: 1.75 / 1e6,
348
+ output: 14 / 1e6
349
+ }
350
+ })),
351
+ ...["gpt-5.3-codex-spark"].map((model) => ({
352
+ id: model,
353
+ cost: {
354
+ input: .5 / 1e6,
355
+ output: 4 / 1e6
356
+ }
357
+ })),
358
+ ...["gpt-5.4", "gpt-5.4-2026-03-05"].map((model) => ({
359
+ id: model,
360
+ cost: {
361
+ input: 2.5 / 1e6,
362
+ output: 15 / 1e6
363
+ }
364
+ })),
365
+ ...["gpt-5.4-mini", "gpt-5.4-mini-2026-03-17"].map((model) => ({
366
+ id: model,
367
+ cost: {
368
+ input: .75 / 1e6,
369
+ output: 4.5 / 1e6
370
+ }
371
+ })),
372
+ ...["gpt-5.4-nano", "gpt-5.4-nano-2026-03-17"].map((model) => ({
373
+ id: model,
374
+ cost: {
375
+ input: .2 / 1e6,
376
+ output: 1.25 / 1e6
377
+ }
378
+ })),
379
+ ...["gpt-5.4-pro", "gpt-5.4-pro-2026-03-05"].map((model) => ({
380
+ id: model,
381
+ cost: {
382
+ input: 30 / 1e6,
383
+ output: 180 / 1e6
384
+ }
385
+ })),
386
+ ...["gpt-audio", "gpt-audio-2025-08-28"].map((model) => ({
387
+ id: model,
388
+ cost: {
389
+ input: 2.5 / 1e6,
390
+ output: 10 / 1e6,
391
+ audioInput: 40 / 1e6,
392
+ audioOutput: 80 / 1e6
393
+ }
394
+ })),
395
+ ...["gpt-audio-mini", "gpt-audio-mini-2025-10-06"].map((model) => ({
396
+ id: model,
397
+ cost: {
398
+ input: .6 / 1e6,
399
+ output: 2.4 / 1e6,
400
+ audioInput: 10 / 1e6,
401
+ audioOutput: 20 / 1e6
402
+ }
403
+ }))
404
+ ];
405
+ const OPENAI_DEEP_RESEARCH_MODELS = [...["o3-deep-research", "o3-deep-research-2025-06-26"].map((model) => ({
406
+ id: model,
407
+ cost: {
408
+ input: 10 / 1e6,
409
+ output: 40 / 1e6
410
+ }
411
+ })), ...["o4-mini-deep-research", "o4-mini-deep-research-2025-06-26"].map((model) => ({
412
+ id: model,
413
+ cost: {
414
+ input: 2 / 1e6,
415
+ output: 8 / 1e6
416
+ }
417
+ }))];
418
+ const OPENAI_COMPLETION_MODELS = [
419
+ {
420
+ id: "gpt-3.5-turbo-instruct",
421
+ cost: {
422
+ input: 1.5 / 1e6,
423
+ output: 2 / 1e6
424
+ }
425
+ },
426
+ { id: "text-davinci-002" },
427
+ { id: "text-babbage-002" }
428
+ ];
429
+ const OPENAI_REALTIME_MODELS = [
430
+ {
431
+ id: "gpt-realtime",
432
+ type: "chat",
433
+ cost: {
434
+ input: 32 / 1e6,
435
+ output: 64 / 1e6,
436
+ audioInput: 32 / 1e6,
437
+ audioOutput: 64 / 1e6
438
+ }
439
+ },
440
+ {
441
+ id: "gpt-realtime",
442
+ type: "chat",
443
+ cost: {
444
+ input: 4 / 1e6,
445
+ output: 16 / 1e6,
446
+ audioInput: 40 / 1e6,
447
+ audioOutput: 80 / 1e6
448
+ }
449
+ },
450
+ {
451
+ id: "gpt-4o-realtime-preview",
452
+ type: "chat",
453
+ cost: {
454
+ input: 5 / 1e6,
455
+ output: 20 / 1e6,
456
+ audioInput: 40 / 1e6,
457
+ audioOutput: 80 / 1e6
458
+ }
459
+ },
460
+ {
461
+ id: "gpt-4o-realtime-preview-2024-12-17",
462
+ type: "chat",
463
+ cost: {
464
+ input: 5 / 1e6,
465
+ output: 20 / 1e6,
466
+ audioInput: 40 / 1e6,
467
+ audioOutput: 80 / 1e6
468
+ }
469
+ },
470
+ {
471
+ id: "gpt-4o-realtime-preview-2024-10-01",
472
+ type: "chat",
473
+ cost: {
474
+ input: 5 / 1e6,
475
+ output: 20 / 1e6,
476
+ audioInput: 100 / 1e6,
477
+ audioOutput: 200 / 1e6
478
+ }
479
+ },
480
+ {
481
+ id: "gpt-4o-mini-realtime-preview",
482
+ type: "chat",
483
+ cost: {
484
+ input: .6 / 1e6,
485
+ output: 2.4 / 1e6,
486
+ audioInput: 10 / 1e6,
487
+ audioOutput: 20 / 1e6
488
+ }
489
+ },
490
+ {
491
+ id: "gpt-4o-mini-realtime-preview-2024-12-17",
492
+ type: "chat",
493
+ cost: {
494
+ input: .6 / 1e6,
495
+ output: 2.4 / 1e6,
496
+ audioInput: 10 / 1e6,
497
+ audioOutput: 20 / 1e6
498
+ }
499
+ },
500
+ {
501
+ id: "gpt-realtime-mini",
502
+ type: "chat",
503
+ cost: {
504
+ input: .6 / 1e6,
505
+ output: 2.4 / 1e6,
506
+ audioInput: 10 / 1e6,
507
+ audioOutput: 20 / 1e6
508
+ }
509
+ },
510
+ {
511
+ id: "gpt-realtime-mini-2025-10-06",
512
+ type: "chat",
513
+ cost: {
514
+ input: .6 / 1e6,
515
+ output: 2.4 / 1e6,
516
+ audioInput: 10 / 1e6,
517
+ audioOutput: 20 / 1e6
518
+ }
519
+ }
520
+ ];
521
+ const OPENAI_TRANSCRIPTION_MODELS = [
522
+ {
523
+ id: "gpt-4o-transcribe",
524
+ cost: { perMinute: .006 }
525
+ },
526
+ {
527
+ id: "gpt-4o-mini-transcribe",
528
+ cost: { perMinute: .003 }
529
+ },
530
+ {
531
+ id: "gpt-4o-transcribe-diarize",
532
+ cost: { perMinute: .006 }
533
+ },
534
+ {
535
+ id: "whisper-1",
536
+ cost: { perMinute: .006 }
537
+ }
538
+ ];
539
+ function calculateOpenAICost(modelName, config, promptTokens, completionTokens, audioPromptTokens, audioCompletionTokens) {
540
+ if (!audioPromptTokens && !audioCompletionTokens) return calculateCost(modelName, config, promptTokens, completionTokens, [
541
+ ...OPENAI_CHAT_MODELS,
542
+ ...OPENAI_COMPLETION_MODELS,
543
+ ...OPENAI_REALTIME_MODELS,
544
+ ...OPENAI_DEEP_RESEARCH_MODELS
545
+ ]);
546
+ if (!Number.isFinite(promptTokens) || !Number.isFinite(completionTokens) || !Number.isFinite(audioPromptTokens) || !Number.isFinite(audioCompletionTokens) || typeof promptTokens === "undefined" || typeof completionTokens === "undefined" || typeof audioPromptTokens === "undefined" || typeof audioCompletionTokens === "undefined") return;
547
+ const model = [
548
+ ...OPENAI_CHAT_MODELS,
549
+ ...OPENAI_COMPLETION_MODELS,
550
+ ...OPENAI_REALTIME_MODELS,
551
+ ...OPENAI_DEEP_RESEARCH_MODELS
552
+ ].find((m) => m.id === modelName);
553
+ if (!model || !model.cost) return;
554
+ let totalCost = 0;
555
+ const inputCost = config.cost ?? model.cost.input;
556
+ const outputCost = config.cost ?? model.cost.output;
557
+ totalCost += inputCost * promptTokens + outputCost * completionTokens;
558
+ if ("audioInput" in model.cost || "audioOutput" in model.cost) {
559
+ const audioInputCost = config.audioCost ?? model.cost.audioInput ?? 0;
560
+ const audioOutputCost = config.audioCost ?? model.cost.audioOutput ?? 0;
561
+ totalCost += audioInputCost * audioPromptTokens + audioOutputCost * audioCompletionTokens;
562
+ }
563
+ return totalCost;
564
+ }
565
+ function failApiCall(err) {
566
+ if (err instanceof OpenAI.APIError) {
567
+ const errorType = err.error?.type || err.type || "unknown";
568
+ const errorMessage = err.error?.message || err.message || "Unknown error";
569
+ return { error: `API error: ${errorType}${err.status ? ` ${err.status}` : ""} ${errorMessage}` };
570
+ }
571
+ return { error: `API error: ${String(err)}` };
572
+ }
573
+ function getTokenUsage(data, cached) {
574
+ if (data.usage) if (cached) return {
575
+ cached: data.usage.total_tokens,
576
+ total: data.usage.total_tokens
577
+ };
578
+ else return {
579
+ total: data.usage.total_tokens,
580
+ prompt: data.usage.prompt_tokens || 0,
581
+ completion: data.usage.completion_tokens || 0,
582
+ numRequests: 1,
583
+ ...data.usage.completion_tokens_details ? { completionDetails: {
584
+ reasoning: data.usage.completion_tokens_details.reasoning_tokens,
585
+ acceptedPrediction: data.usage.completion_tokens_details.accepted_prediction_tokens,
586
+ rejectedPrediction: data.usage.completion_tokens_details.rejected_prediction_tokens
587
+ } } : {}
588
+ };
589
+ return {};
590
+ }
591
+ function validateFunctionCall(output, functions, vars) {
592
+ if (typeof output === "object" && "function_call" in output) output = output.function_call;
593
+ const functionCall = output;
594
+ if (typeof functionCall !== "object" || typeof functionCall.name !== "string" || typeof functionCall.arguments !== "string") throw new Error(`OpenAI did not return a valid-looking function call: ${JSON.stringify(functionCall)}`);
595
+ const interpolatedFunctions = maybeLoadFromExternalFileWithVars(functions, vars);
596
+ const functionArgs = JSON.parse(functionCall.arguments);
597
+ const functionName = functionCall.name;
598
+ const functionSchema = interpolatedFunctions?.find((f) => f.name === functionName)?.parameters;
599
+ if (!functionSchema) throw new Error(`Called "${functionName}", but there is no function with that name`);
600
+ const validate = ajv.compile(functionSchema);
601
+ if (!validate(functionArgs)) throw new Error(`Call to "${functionName}" does not match schema: ${JSON.stringify(validate.errors)}`);
602
+ }
603
+ function formatOpenAiError(data) {
604
+ let errorMessage = `API error: ${data.error.message}`;
605
+ if (data.error.type) errorMessage += `, Type: ${data.error.type}`;
606
+ if (data.error.code) errorMessage += `, Code: ${data.error.code}`;
607
+ errorMessage += "\n\n" + safeJsonStringify(data, true);
608
+ return errorMessage;
609
+ }
610
+ //#endregion
611
+ export { calculateOpenAICost as a, getTokenUsage as c, OPENAI_TRANSCRIPTION_MODELS as i, validateFunctionCall as l, OPENAI_COMPLETION_MODELS as n, failApiCall as o, OPENAI_REALTIME_MODELS as r, formatOpenAiError as s, OPENAI_CHAT_MODELS as t };
612
+
613
+ //# sourceMappingURL=util-DsS_-v4p.js.map