@ainative/cody-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (770) hide show
  1. package/.github/logo.svg +3 -0
  2. package/CHANGELOG.md +2345 -0
  3. package/LICENSE +8 -0
  4. package/README.md +45 -0
  5. package/_vendor/partial-json-parser/parser.d.mts +3 -0
  6. package/_vendor/partial-json-parser/parser.d.mts.map +1 -0
  7. package/_vendor/partial-json-parser/parser.d.ts +3 -0
  8. package/_vendor/partial-json-parser/parser.d.ts.map +1 -0
  9. package/_vendor/partial-json-parser/parser.js +226 -0
  10. package/_vendor/partial-json-parser/parser.js.map +1 -0
  11. package/_vendor/partial-json-parser/parser.mjs +223 -0
  12. package/_vendor/partial-json-parser/parser.mjs.map +1 -0
  13. package/ainative.d.mts +32 -0
  14. package/ainative.d.mts.map +1 -0
  15. package/ainative.d.ts +32 -0
  16. package/ainative.d.ts.map +1 -0
  17. package/ainative.js +78 -0
  18. package/ainative.js.map +1 -0
  19. package/ainative.mjs +71 -0
  20. package/ainative.mjs.map +1 -0
  21. package/api-promise.d.mts +2 -0
  22. package/api-promise.d.mts.map +1 -0
  23. package/api-promise.d.ts +2 -0
  24. package/api-promise.d.ts.map +1 -0
  25. package/api-promise.js +6 -0
  26. package/api-promise.js.map +1 -0
  27. package/api-promise.mjs +2 -0
  28. package/api-promise.mjs.map +1 -0
  29. package/bin/cli +53 -0
  30. package/bin/migration-config.json +82 -0
  31. package/client.d.mts +247 -0
  32. package/client.d.mts.map +1 -0
  33. package/client.d.ts +247 -0
  34. package/client.d.ts.map +1 -0
  35. package/client.js +567 -0
  36. package/client.js.map +1 -0
  37. package/client.mjs +562 -0
  38. package/client.mjs.map +1 -0
  39. package/core/api-promise.d.mts +49 -0
  40. package/core/api-promise.d.mts.map +1 -0
  41. package/core/api-promise.d.ts +49 -0
  42. package/core/api-promise.d.ts.map +1 -0
  43. package/core/api-promise.js +76 -0
  44. package/core/api-promise.js.map +1 -0
  45. package/core/api-promise.mjs +72 -0
  46. package/core/api-promise.mjs.map +1 -0
  47. package/core/error.d.mts +50 -0
  48. package/core/error.d.mts.map +1 -0
  49. package/core/error.d.ts +50 -0
  50. package/core/error.d.ts.map +1 -0
  51. package/core/error.js +116 -0
  52. package/core/error.js.map +1 -0
  53. package/core/error.mjs +100 -0
  54. package/core/error.mjs.map +1 -0
  55. package/core/pagination.d.mts +105 -0
  56. package/core/pagination.d.mts.map +1 -0
  57. package/core/pagination.d.ts +105 -0
  58. package/core/pagination.d.ts.map +1 -0
  59. package/core/pagination.js +185 -0
  60. package/core/pagination.js.map +1 -0
  61. package/core/pagination.mjs +177 -0
  62. package/core/pagination.mjs.map +1 -0
  63. package/core/resource.d.mts +6 -0
  64. package/core/resource.d.mts.map +1 -0
  65. package/core/resource.d.ts +6 -0
  66. package/core/resource.d.ts.map +1 -0
  67. package/core/resource.js +11 -0
  68. package/core/resource.js.map +1 -0
  69. package/core/resource.mjs +7 -0
  70. package/core/resource.mjs.map +1 -0
  71. package/core/streaming.d.mts +33 -0
  72. package/core/streaming.d.mts.map +1 -0
  73. package/core/streaming.d.ts +33 -0
  74. package/core/streaming.d.ts.map +1 -0
  75. package/core/streaming.js +290 -0
  76. package/core/streaming.js.map +1 -0
  77. package/core/streaming.mjs +285 -0
  78. package/core/streaming.mjs.map +1 -0
  79. package/core/uploads.d.mts +3 -0
  80. package/core/uploads.d.mts.map +1 -0
  81. package/core/uploads.d.ts +3 -0
  82. package/core/uploads.d.ts.map +1 -0
  83. package/core/uploads.js +6 -0
  84. package/core/uploads.js.map +1 -0
  85. package/core/uploads.mjs +2 -0
  86. package/core/uploads.mjs.map +1 -0
  87. package/error.d.mts +2 -0
  88. package/error.d.mts.map +1 -0
  89. package/error.d.ts +2 -0
  90. package/error.d.ts.map +1 -0
  91. package/error.js +6 -0
  92. package/error.js.map +1 -0
  93. package/error.mjs +2 -0
  94. package/error.mjs.map +1 -0
  95. package/helpers/beta/json-schema.d.mts +31 -0
  96. package/helpers/beta/json-schema.d.mts.map +1 -0
  97. package/helpers/beta/json-schema.d.ts +31 -0
  98. package/helpers/beta/json-schema.d.ts.map +1 -0
  99. package/helpers/beta/json-schema.js +56 -0
  100. package/helpers/beta/json-schema.js.map +1 -0
  101. package/helpers/beta/json-schema.mjs +52 -0
  102. package/helpers/beta/json-schema.mjs.map +1 -0
  103. package/helpers/beta/mcp.d.mts +303 -0
  104. package/helpers/beta/mcp.d.mts.map +1 -0
  105. package/helpers/beta/mcp.d.ts +303 -0
  106. package/helpers/beta/mcp.d.ts.map +1 -0
  107. package/helpers/beta/mcp.js +419 -0
  108. package/helpers/beta/mcp.js.map +1 -0
  109. package/helpers/beta/mcp.mjs +406 -0
  110. package/helpers/beta/mcp.mjs.map +1 -0
  111. package/helpers/beta/memory.d.mts +11 -0
  112. package/helpers/beta/memory.d.mts.map +1 -0
  113. package/helpers/beta/memory.d.ts +11 -0
  114. package/helpers/beta/memory.d.ts.map +1 -0
  115. package/helpers/beta/memory.js +18 -0
  116. package/helpers/beta/memory.js.map +1 -0
  117. package/helpers/beta/memory.mjs +15 -0
  118. package/helpers/beta/memory.mjs.map +1 -0
  119. package/helpers/beta/zod.d.mts +27 -0
  120. package/helpers/beta/zod.d.mts.map +1 -0
  121. package/helpers/beta/zod.d.ts +27 -0
  122. package/helpers/beta/zod.d.ts.map +1 -0
  123. package/helpers/beta/zod.js +57 -0
  124. package/helpers/beta/zod.js.map +1 -0
  125. package/helpers/beta/zod.mjs +52 -0
  126. package/helpers/beta/zod.mjs.map +1 -0
  127. package/helpers/index.d.mts +3 -0
  128. package/helpers/index.d.mts.map +1 -0
  129. package/helpers/index.d.ts +3 -0
  130. package/helpers/index.d.ts.map +1 -0
  131. package/helpers/index.js +8 -0
  132. package/helpers/index.js.map +1 -0
  133. package/helpers/index.mjs +3 -0
  134. package/helpers/index.mjs.map +1 -0
  135. package/helpers/json-schema.d.mts +18 -0
  136. package/helpers/json-schema.d.mts.map +1 -0
  137. package/helpers/json-schema.d.ts +18 -0
  138. package/helpers/json-schema.d.ts.map +1 -0
  139. package/helpers/json-schema.js +37 -0
  140. package/helpers/json-schema.js.map +1 -0
  141. package/helpers/json-schema.mjs +34 -0
  142. package/helpers/json-schema.mjs.map +1 -0
  143. package/helpers/zod.d.mts +13 -0
  144. package/helpers/zod.d.mts.map +1 -0
  145. package/helpers/zod.d.ts +13 -0
  146. package/helpers/zod.d.ts.map +1 -0
  147. package/helpers/zod.js +47 -0
  148. package/helpers/zod.js.map +1 -0
  149. package/helpers/zod.mjs +43 -0
  150. package/helpers/zod.mjs.map +1 -0
  151. package/index.d.mts +9 -0
  152. package/index.d.mts.map +1 -0
  153. package/index.d.ts +9 -0
  154. package/index.d.ts.map +1 -0
  155. package/index.js +42 -0
  156. package/index.js.map +1 -0
  157. package/index.mjs +9 -0
  158. package/index.mjs.map +1 -0
  159. package/internal/builtin-types.d.mts +73 -0
  160. package/internal/builtin-types.d.mts.map +1 -0
  161. package/internal/builtin-types.d.ts +73 -0
  162. package/internal/builtin-types.d.ts.map +1 -0
  163. package/internal/builtin-types.js +4 -0
  164. package/internal/builtin-types.js.map +1 -0
  165. package/internal/builtin-types.mjs +3 -0
  166. package/internal/builtin-types.mjs.map +1 -0
  167. package/internal/constants.d.mts +5 -0
  168. package/internal/constants.d.mts.map +1 -0
  169. package/internal/constants.d.ts +5 -0
  170. package/internal/constants.d.ts.map +1 -0
  171. package/internal/constants.js +18 -0
  172. package/internal/constants.js.map +1 -0
  173. package/internal/constants.mjs +15 -0
  174. package/internal/constants.mjs.map +1 -0
  175. package/internal/decoders/jsonl.d.mts +10 -0
  176. package/internal/decoders/jsonl.d.mts.map +1 -0
  177. package/internal/decoders/jsonl.d.ts +10 -0
  178. package/internal/decoders/jsonl.d.ts.map +1 -0
  179. package/internal/decoders/jsonl.js +39 -0
  180. package/internal/decoders/jsonl.js.map +1 -0
  181. package/internal/decoders/jsonl.mjs +35 -0
  182. package/internal/decoders/jsonl.mjs.map +1 -0
  183. package/internal/decoders/line.d.mts +17 -0
  184. package/internal/decoders/line.d.mts.map +1 -0
  185. package/internal/decoders/line.d.ts +17 -0
  186. package/internal/decoders/line.d.ts.map +1 -0
  187. package/internal/decoders/line.js +113 -0
  188. package/internal/decoders/line.js.map +1 -0
  189. package/internal/decoders/line.mjs +108 -0
  190. package/internal/decoders/line.mjs.map +1 -0
  191. package/internal/detect-platform.d.mts +15 -0
  192. package/internal/detect-platform.d.mts.map +1 -0
  193. package/internal/detect-platform.d.ts +15 -0
  194. package/internal/detect-platform.d.ts.map +1 -0
  195. package/internal/detect-platform.js +162 -0
  196. package/internal/detect-platform.js.map +1 -0
  197. package/internal/detect-platform.mjs +157 -0
  198. package/internal/detect-platform.mjs.map +1 -0
  199. package/internal/errors.d.mts +3 -0
  200. package/internal/errors.d.mts.map +1 -0
  201. package/internal/errors.d.ts +3 -0
  202. package/internal/errors.d.ts.map +1 -0
  203. package/internal/errors.js +41 -0
  204. package/internal/errors.js.map +1 -0
  205. package/internal/errors.mjs +36 -0
  206. package/internal/errors.mjs.map +1 -0
  207. package/internal/headers.d.mts +22 -0
  208. package/internal/headers.d.mts.map +1 -0
  209. package/internal/headers.d.ts +22 -0
  210. package/internal/headers.d.ts.map +1 -0
  211. package/internal/headers.js +79 -0
  212. package/internal/headers.js.map +1 -0
  213. package/internal/headers.mjs +74 -0
  214. package/internal/headers.mjs.map +1 -0
  215. package/internal/parse.d.mts +17 -0
  216. package/internal/parse.d.mts.map +1 -0
  217. package/internal/parse.d.ts +17 -0
  218. package/internal/parse.d.ts.map +1 -0
  219. package/internal/parse.js +60 -0
  220. package/internal/parse.js.map +1 -0
  221. package/internal/parse.mjs +56 -0
  222. package/internal/parse.mjs.map +1 -0
  223. package/internal/request-options.d.mts +77 -0
  224. package/internal/request-options.d.mts.map +1 -0
  225. package/internal/request-options.d.ts +77 -0
  226. package/internal/request-options.d.ts.map +1 -0
  227. package/internal/request-options.js +14 -0
  228. package/internal/request-options.js.map +1 -0
  229. package/internal/request-options.mjs +10 -0
  230. package/internal/request-options.mjs.map +1 -0
  231. package/internal/shim-types.d.mts +17 -0
  232. package/internal/shim-types.d.mts.map +1 -0
  233. package/internal/shim-types.d.ts +17 -0
  234. package/internal/shim-types.d.ts.map +1 -0
  235. package/internal/shim-types.js +4 -0
  236. package/internal/shim-types.js.map +1 -0
  237. package/internal/shim-types.mjs +3 -0
  238. package/internal/shim-types.mjs.map +1 -0
  239. package/internal/shims.d.mts +20 -0
  240. package/internal/shims.d.mts.map +1 -0
  241. package/internal/shims.d.ts +20 -0
  242. package/internal/shims.d.ts.map +1 -0
  243. package/internal/shims.js +92 -0
  244. package/internal/shims.js.map +1 -0
  245. package/internal/shims.mjs +85 -0
  246. package/internal/shims.mjs.map +1 -0
  247. package/internal/stream-utils.d.mts +8 -0
  248. package/internal/stream-utils.d.mts.map +1 -0
  249. package/internal/stream-utils.d.ts +8 -0
  250. package/internal/stream-utils.d.ts.map +1 -0
  251. package/internal/stream-utils.js +38 -0
  252. package/internal/stream-utils.js.map +1 -0
  253. package/internal/stream-utils.mjs +35 -0
  254. package/internal/stream-utils.mjs.map +1 -0
  255. package/internal/to-file.d.mts +45 -0
  256. package/internal/to-file.d.mts.map +1 -0
  257. package/internal/to-file.d.ts +45 -0
  258. package/internal/to-file.d.ts.map +1 -0
  259. package/internal/to-file.js +96 -0
  260. package/internal/to-file.js.map +1 -0
  261. package/internal/to-file.mjs +93 -0
  262. package/internal/to-file.mjs.map +1 -0
  263. package/internal/tslib.js +81 -0
  264. package/internal/tslib.mjs +17 -0
  265. package/internal/types.d.mts +69 -0
  266. package/internal/types.d.mts.map +1 -0
  267. package/internal/types.d.ts +69 -0
  268. package/internal/types.d.ts.map +1 -0
  269. package/internal/types.js +4 -0
  270. package/internal/types.js.map +1 -0
  271. package/internal/types.mjs +3 -0
  272. package/internal/types.mjs.map +1 -0
  273. package/internal/uploads.d.mts +42 -0
  274. package/internal/uploads.d.mts.map +1 -0
  275. package/internal/uploads.d.ts +42 -0
  276. package/internal/uploads.d.ts.map +1 -0
  277. package/internal/uploads.js +145 -0
  278. package/internal/uploads.js.map +1 -0
  279. package/internal/uploads.mjs +135 -0
  280. package/internal/uploads.mjs.map +1 -0
  281. package/internal/utils/base64.d.mts +3 -0
  282. package/internal/utils/base64.d.mts.map +1 -0
  283. package/internal/utils/base64.d.ts +3 -0
  284. package/internal/utils/base64.d.ts.map +1 -0
  285. package/internal/utils/base64.js +38 -0
  286. package/internal/utils/base64.js.map +1 -0
  287. package/internal/utils/base64.mjs +33 -0
  288. package/internal/utils/base64.mjs.map +1 -0
  289. package/internal/utils/bytes.d.mts +4 -0
  290. package/internal/utils/bytes.d.mts.map +1 -0
  291. package/internal/utils/bytes.d.ts +4 -0
  292. package/internal/utils/bytes.d.ts.map +1 -0
  293. package/internal/utils/bytes.js +31 -0
  294. package/internal/utils/bytes.js.map +1 -0
  295. package/internal/utils/bytes.mjs +26 -0
  296. package/internal/utils/bytes.mjs.map +1 -0
  297. package/internal/utils/env.d.mts +9 -0
  298. package/internal/utils/env.d.mts.map +1 -0
  299. package/internal/utils/env.d.ts +9 -0
  300. package/internal/utils/env.d.ts.map +1 -0
  301. package/internal/utils/env.js +22 -0
  302. package/internal/utils/env.js.map +1 -0
  303. package/internal/utils/env.mjs +18 -0
  304. package/internal/utils/env.mjs.map +1 -0
  305. package/internal/utils/log.d.mts +37 -0
  306. package/internal/utils/log.d.mts.map +1 -0
  307. package/internal/utils/log.d.ts +37 -0
  308. package/internal/utils/log.d.ts.map +1 -0
  309. package/internal/utils/log.js +86 -0
  310. package/internal/utils/log.js.map +1 -0
  311. package/internal/utils/log.mjs +80 -0
  312. package/internal/utils/log.mjs.map +1 -0
  313. package/internal/utils/path.d.mts +15 -0
  314. package/internal/utils/path.d.mts.map +1 -0
  315. package/internal/utils/path.d.ts +15 -0
  316. package/internal/utils/path.d.ts.map +1 -0
  317. package/internal/utils/path.js +79 -0
  318. package/internal/utils/path.js.map +1 -0
  319. package/internal/utils/path.mjs +74 -0
  320. package/internal/utils/path.mjs.map +1 -0
  321. package/internal/utils/query.d.mts +5 -0
  322. package/internal/utils/query.d.mts.map +1 -0
  323. package/internal/utils/query.d.ts +5 -0
  324. package/internal/utils/query.d.ts.map +1 -0
  325. package/internal/utils/query.js +23 -0
  326. package/internal/utils/query.js.map +1 -0
  327. package/internal/utils/query.mjs +20 -0
  328. package/internal/utils/query.mjs.map +1 -0
  329. package/internal/utils/sleep.d.mts +2 -0
  330. package/internal/utils/sleep.d.mts.map +1 -0
  331. package/internal/utils/sleep.d.ts +2 -0
  332. package/internal/utils/sleep.d.ts.map +1 -0
  333. package/internal/utils/sleep.js +7 -0
  334. package/internal/utils/sleep.js.map +1 -0
  335. package/internal/utils/sleep.mjs +3 -0
  336. package/internal/utils/sleep.mjs.map +1 -0
  337. package/internal/utils/uuid.d.mts +5 -0
  338. package/internal/utils/uuid.d.mts.map +1 -0
  339. package/internal/utils/uuid.d.ts +5 -0
  340. package/internal/utils/uuid.d.ts.map +1 -0
  341. package/internal/utils/uuid.js +19 -0
  342. package/internal/utils/uuid.js.map +1 -0
  343. package/internal/utils/uuid.mjs +15 -0
  344. package/internal/utils/uuid.mjs.map +1 -0
  345. package/internal/utils/values.d.mts +19 -0
  346. package/internal/utils/values.d.mts.map +1 -0
  347. package/internal/utils/values.d.ts +19 -0
  348. package/internal/utils/values.d.ts.map +1 -0
  349. package/internal/utils/values.js +119 -0
  350. package/internal/utils/values.js.map +1 -0
  351. package/internal/utils/values.mjs +100 -0
  352. package/internal/utils/values.mjs.map +1 -0
  353. package/internal/utils.d.mts +8 -0
  354. package/internal/utils.d.mts.map +1 -0
  355. package/internal/utils.d.ts +8 -0
  356. package/internal/utils.d.ts.map +1 -0
  357. package/internal/utils.js +12 -0
  358. package/internal/utils.js.map +1 -0
  359. package/internal/utils.mjs +9 -0
  360. package/internal/utils.mjs.map +1 -0
  361. package/lib/BetaMessageStream.d.mts +122 -0
  362. package/lib/BetaMessageStream.d.mts.map +1 -0
  363. package/lib/BetaMessageStream.d.ts +122 -0
  364. package/lib/BetaMessageStream.d.ts.map +1 -0
  365. package/lib/BetaMessageStream.js +620 -0
  366. package/lib/BetaMessageStream.js.map +1 -0
  367. package/lib/BetaMessageStream.mjs +616 -0
  368. package/lib/BetaMessageStream.mjs.map +1 -0
  369. package/lib/MessageStream.d.mts +121 -0
  370. package/lib/MessageStream.d.mts.map +1 -0
  371. package/lib/MessageStream.d.ts +121 -0
  372. package/lib/MessageStream.d.ts.map +1 -0
  373. package/lib/MessageStream.js +595 -0
  374. package/lib/MessageStream.js.map +1 -0
  375. package/lib/MessageStream.mjs +591 -0
  376. package/lib/MessageStream.mjs.map +1 -0
  377. package/lib/beta-parser.d.mts +37 -0
  378. package/lib/beta-parser.d.mts.map +1 -0
  379. package/lib/beta-parser.d.ts +37 -0
  380. package/lib/beta-parser.d.ts.map +1 -0
  381. package/lib/beta-parser.js +79 -0
  382. package/lib/beta-parser.js.map +1 -0
  383. package/lib/beta-parser.mjs +75 -0
  384. package/lib/beta-parser.mjs.map +1 -0
  385. package/lib/parser.d.mts +32 -0
  386. package/lib/parser.d.mts.map +1 -0
  387. package/lib/parser.d.ts +32 -0
  388. package/lib/parser.d.ts.map +1 -0
  389. package/lib/parser.js +66 -0
  390. package/lib/parser.js.map +1 -0
  391. package/lib/parser.mjs +62 -0
  392. package/lib/parser.mjs.map +1 -0
  393. package/lib/stainless-helper-header.d.mts +34 -0
  394. package/lib/stainless-helper-header.d.mts.map +1 -0
  395. package/lib/stainless-helper-header.d.ts +34 -0
  396. package/lib/stainless-helper-header.d.ts.map +1 -0
  397. package/lib/stainless-helper-header.js +70 -0
  398. package/lib/stainless-helper-header.js.map +1 -0
  399. package/lib/stainless-helper-header.mjs +63 -0
  400. package/lib/stainless-helper-header.mjs.map +1 -0
  401. package/lib/tools/BetaRunnableTool.d.mts +12 -0
  402. package/lib/tools/BetaRunnableTool.d.mts.map +1 -0
  403. package/lib/tools/BetaRunnableTool.d.ts +12 -0
  404. package/lib/tools/BetaRunnableTool.d.ts.map +1 -0
  405. package/lib/tools/BetaRunnableTool.js +3 -0
  406. package/lib/tools/BetaRunnableTool.js.map +1 -0
  407. package/lib/tools/BetaRunnableTool.mjs +2 -0
  408. package/lib/tools/BetaRunnableTool.mjs.map +1 -0
  409. package/lib/tools/BetaToolRunner.d.mts +141 -0
  410. package/lib/tools/BetaToolRunner.d.mts.map +1 -0
  411. package/lib/tools/BetaToolRunner.d.ts +141 -0
  412. package/lib/tools/BetaToolRunner.d.ts.map +1 -0
  413. package/lib/tools/BetaToolRunner.js +381 -0
  414. package/lib/tools/BetaToolRunner.js.map +1 -0
  415. package/lib/tools/BetaToolRunner.mjs +377 -0
  416. package/lib/tools/BetaToolRunner.mjs.map +1 -0
  417. package/lib/tools/CompactionControl.d.mts +30 -0
  418. package/lib/tools/CompactionControl.d.mts.map +1 -0
  419. package/lib/tools/CompactionControl.d.ts +30 -0
  420. package/lib/tools/CompactionControl.d.ts.map +1 -0
  421. package/lib/tools/CompactionControl.js +28 -0
  422. package/lib/tools/CompactionControl.js.map +1 -0
  423. package/lib/tools/CompactionControl.mjs +25 -0
  424. package/lib/tools/CompactionControl.mjs.map +1 -0
  425. package/lib/tools/ToolError.d.mts +33 -0
  426. package/lib/tools/ToolError.d.mts.map +1 -0
  427. package/lib/tools/ToolError.d.ts +33 -0
  428. package/lib/tools/ToolError.d.ts.map +1 -0
  429. package/lib/tools/ToolError.js +42 -0
  430. package/lib/tools/ToolError.js.map +1 -0
  431. package/lib/tools/ToolError.mjs +38 -0
  432. package/lib/tools/ToolError.mjs.map +1 -0
  433. package/lib/tools/ToolRunner.d.mts +132 -0
  434. package/lib/tools/ToolRunner.d.mts.map +1 -0
  435. package/lib/tools/ToolRunner.d.ts +132 -0
  436. package/lib/tools/ToolRunner.d.ts.map +1 -0
  437. package/lib/tools/ToolRunner.js +294 -0
  438. package/lib/tools/ToolRunner.js.map +1 -0
  439. package/lib/tools/ToolRunner.mjs +290 -0
  440. package/lib/tools/ToolRunner.mjs.map +1 -0
  441. package/lib/transform-json-schema.d.mts +3 -0
  442. package/lib/transform-json-schema.d.mts.map +1 -0
  443. package/lib/transform-json-schema.d.ts +3 -0
  444. package/lib/transform-json-schema.d.ts.map +1 -0
  445. package/lib/transform-json-schema.js +114 -0
  446. package/lib/transform-json-schema.js.map +1 -0
  447. package/lib/transform-json-schema.mjs +111 -0
  448. package/lib/transform-json-schema.mjs.map +1 -0
  449. package/package.json +246 -0
  450. package/pagination.d.mts +2 -0
  451. package/pagination.d.mts.map +1 -0
  452. package/pagination.d.ts +2 -0
  453. package/pagination.d.ts.map +1 -0
  454. package/pagination.js +6 -0
  455. package/pagination.js.map +1 -0
  456. package/pagination.mjs +2 -0
  457. package/pagination.mjs.map +1 -0
  458. package/resource.d.mts +2 -0
  459. package/resource.d.mts.map +1 -0
  460. package/resource.d.ts +2 -0
  461. package/resource.d.ts.map +1 -0
  462. package/resource.js +6 -0
  463. package/resource.js.map +1 -0
  464. package/resource.mjs +2 -0
  465. package/resource.mjs.map +1 -0
  466. package/resources/beta/beta.d.mts +66 -0
  467. package/resources/beta/beta.d.mts.map +1 -0
  468. package/resources/beta/beta.d.ts +66 -0
  469. package/resources/beta/beta.d.ts.map +1 -0
  470. package/resources/beta/beta.js +29 -0
  471. package/resources/beta/beta.js.map +1 -0
  472. package/resources/beta/beta.mjs +24 -0
  473. package/resources/beta/beta.mjs.map +1 -0
  474. package/resources/beta/files.d.mts +151 -0
  475. package/resources/beta/files.d.mts.map +1 -0
  476. package/resources/beta/files.d.ts +151 -0
  477. package/resources/beta/files.d.ts.map +1 -0
  478. package/resources/beta/files.js +124 -0
  479. package/resources/beta/files.js.map +1 -0
  480. package/resources/beta/files.mjs +120 -0
  481. package/resources/beta/files.mjs.map +1 -0
  482. package/resources/beta/index.d.mts +6 -0
  483. package/resources/beta/index.d.mts.map +1 -0
  484. package/resources/beta/index.d.ts +6 -0
  485. package/resources/beta/index.d.ts.map +1 -0
  486. package/resources/beta/index.js +15 -0
  487. package/resources/beta/index.js.map +1 -0
  488. package/resources/beta/index.mjs +7 -0
  489. package/resources/beta/index.mjs.map +1 -0
  490. package/resources/beta/messages/batches.d.mts +646 -0
  491. package/resources/beta/messages/batches.d.mts.map +1 -0
  492. package/resources/beta/messages/batches.d.ts +646 -0
  493. package/resources/beta/messages/batches.d.ts.map +1 -0
  494. package/resources/beta/messages/batches.js +204 -0
  495. package/resources/beta/messages/batches.js.map +1 -0
  496. package/resources/beta/messages/batches.mjs +200 -0
  497. package/resources/beta/messages/batches.mjs.map +1 -0
  498. package/resources/beta/messages/index.d.mts +4 -0
  499. package/resources/beta/messages/index.d.mts.map +1 -0
  500. package/resources/beta/messages/index.d.ts +4 -0
  501. package/resources/beta/messages/index.d.ts.map +1 -0
  502. package/resources/beta/messages/index.js +12 -0
  503. package/resources/beta/messages/index.js.map +1 -0
  504. package/resources/beta/messages/index.mjs +5 -0
  505. package/resources/beta/messages/index.mjs.map +1 -0
  506. package/resources/beta/messages/messages.d.mts +2993 -0
  507. package/resources/beta/messages/messages.d.mts.map +1 -0
  508. package/resources/beta/messages/messages.d.ts +2993 -0
  509. package/resources/beta/messages/messages.d.ts.map +1 -0
  510. package/resources/beta/messages/messages.js +163 -0
  511. package/resources/beta/messages/messages.js.map +1 -0
  512. package/resources/beta/messages/messages.mjs +156 -0
  513. package/resources/beta/messages/messages.mjs.map +1 -0
  514. package/resources/beta/messages.d.mts +2 -0
  515. package/resources/beta/messages.d.mts.map +1 -0
  516. package/resources/beta/messages.d.ts +2 -0
  517. package/resources/beta/messages.d.ts.map +1 -0
  518. package/resources/beta/messages.js +6 -0
  519. package/resources/beta/messages.js.map +1 -0
  520. package/resources/beta/messages.mjs +3 -0
  521. package/resources/beta/messages.mjs.map +1 -0
  522. package/resources/beta/models.d.mts +208 -0
  523. package/resources/beta/models.d.mts.map +1 -0
  524. package/resources/beta/models.d.ts +208 -0
  525. package/resources/beta/models.d.ts.map +1 -0
  526. package/resources/beta/models.js +60 -0
  527. package/resources/beta/models.js.map +1 -0
  528. package/resources/beta/models.mjs +56 -0
  529. package/resources/beta/models.mjs.map +1 -0
  530. package/resources/beta/skills/index.d.mts +3 -0
  531. package/resources/beta/skills/index.d.mts.map +1 -0
  532. package/resources/beta/skills/index.d.ts +3 -0
  533. package/resources/beta/skills/index.d.ts.map +1 -0
  534. package/resources/beta/skills/index.js +9 -0
  535. package/resources/beta/skills/index.js.map +1 -0
  536. package/resources/beta/skills/index.mjs +4 -0
  537. package/resources/beta/skills/index.mjs.map +1 -0
  538. package/resources/beta/skills/skills.d.mts +249 -0
  539. package/resources/beta/skills/skills.d.mts.map +1 -0
  540. package/resources/beta/skills/skills.d.ts +249 -0
  541. package/resources/beta/skills/skills.d.ts.map +1 -0
  542. package/resources/beta/skills/skills.js +98 -0
  543. package/resources/beta/skills/skills.js.map +1 -0
  544. package/resources/beta/skills/skills.mjs +93 -0
  545. package/resources/beta/skills/skills.mjs.map +1 -0
  546. package/resources/beta/skills/versions.d.mts +257 -0
  547. package/resources/beta/skills/versions.d.mts.map +1 -0
  548. package/resources/beta/skills/versions.d.ts +257 -0
  549. package/resources/beta/skills/versions.d.ts.map +1 -0
  550. package/resources/beta/skills/versions.js +100 -0
  551. package/resources/beta/skills/versions.js.map +1 -0
  552. package/resources/beta/skills/versions.mjs +96 -0
  553. package/resources/beta/skills/versions.mjs.map +1 -0
  554. package/resources/beta/skills.d.mts +2 -0
  555. package/resources/beta/skills.d.mts.map +1 -0
  556. package/resources/beta/skills.d.ts +2 -0
  557. package/resources/beta/skills.d.ts.map +1 -0
  558. package/resources/beta/skills.js +6 -0
  559. package/resources/beta/skills.js.map +1 -0
  560. package/resources/beta/skills.mjs +3 -0
  561. package/resources/beta/skills.mjs.map +1 -0
  562. package/resources/beta.d.mts +2 -0
  563. package/resources/beta.d.mts.map +1 -0
  564. package/resources/beta.d.ts +2 -0
  565. package/resources/beta.d.ts.map +1 -0
  566. package/resources/beta.js +6 -0
  567. package/resources/beta.js.map +1 -0
  568. package/resources/beta.mjs +3 -0
  569. package/resources/beta.mjs.map +1 -0
  570. package/resources/completions.d.mts +182 -0
  571. package/resources/completions.d.mts.map +1 -0
  572. package/resources/completions.d.ts +182 -0
  573. package/resources/completions.d.ts.map +1 -0
  574. package/resources/completions.js +23 -0
  575. package/resources/completions.js.map +1 -0
  576. package/resources/completions.mjs +19 -0
  577. package/resources/completions.mjs.map +1 -0
  578. package/resources/index.d.mts +6 -0
  579. package/resources/index.d.mts.map +1 -0
  580. package/resources/index.d.ts +6 -0
  581. package/resources/index.d.ts.map +1 -0
  582. package/resources/index.js +15 -0
  583. package/resources/index.js.map +1 -0
  584. package/resources/index.mjs +7 -0
  585. package/resources/index.mjs.map +1 -0
  586. package/resources/messages/batches.d.mts +304 -0
  587. package/resources/messages/batches.d.mts.map +1 -0
  588. package/resources/messages/batches.d.ts +304 -0
  589. package/resources/messages/batches.d.ts.map +1 -0
  590. package/resources/messages/batches.js +153 -0
  591. package/resources/messages/batches.js.map +1 -0
  592. package/resources/messages/batches.mjs +149 -0
  593. package/resources/messages/batches.mjs.map +1 -0
  594. package/resources/messages/index.d.mts +3 -0
  595. package/resources/messages/index.d.mts.map +1 -0
  596. package/resources/messages/index.d.ts +3 -0
  597. package/resources/messages/index.d.ts.map +1 -0
  598. package/resources/messages/index.js +9 -0
  599. package/resources/messages/index.js.map +1 -0
  600. package/resources/messages/index.mjs +4 -0
  601. package/resources/messages/index.mjs.map +1 -0
  602. package/resources/messages/messages.d.mts +2285 -0
  603. package/resources/messages/messages.d.mts.map +1 -0
  604. package/resources/messages/messages.d.ts +2285 -0
  605. package/resources/messages/messages.d.ts.map +1 -0
  606. package/resources/messages/messages.js +128 -0
  607. package/resources/messages/messages.js.map +1 -0
  608. package/resources/messages/messages.mjs +123 -0
  609. package/resources/messages/messages.mjs.map +1 -0
  610. package/resources/messages.d.mts +2 -0
  611. package/resources/messages.d.mts.map +1 -0
  612. package/resources/messages.d.ts +2 -0
  613. package/resources/messages.d.ts.map +1 -0
  614. package/resources/messages.js +6 -0
  615. package/resources/messages.js.map +1 -0
  616. package/resources/messages.mjs +3 -0
  617. package/resources/messages.mjs.map +1 -0
  618. package/resources/models.d.mts +193 -0
  619. package/resources/models.d.mts.map +1 -0
  620. package/resources/models.d.ts +193 -0
  621. package/resources/models.d.ts.map +1 -0
  622. package/resources/models.js +45 -0
  623. package/resources/models.js.map +1 -0
  624. package/resources/models.mjs +41 -0
  625. package/resources/models.mjs.map +1 -0
  626. package/resources/shared.d.mts +44 -0
  627. package/resources/shared.d.mts.map +1 -0
  628. package/resources/shared.d.ts +44 -0
  629. package/resources/shared.d.ts.map +1 -0
  630. package/resources/shared.js +4 -0
  631. package/resources/shared.js.map +1 -0
  632. package/resources/shared.mjs +3 -0
  633. package/resources/shared.mjs.map +1 -0
  634. package/resources/top-level.d.mts +2 -0
  635. package/resources/top-level.d.mts.map +1 -0
  636. package/resources/top-level.d.ts +2 -0
  637. package/resources/top-level.d.ts.map +1 -0
  638. package/resources/top-level.js +4 -0
  639. package/resources/top-level.js.map +1 -0
  640. package/resources/top-level.mjs +3 -0
  641. package/resources/top-level.mjs.map +1 -0
  642. package/resources.d.mts +2 -0
  643. package/resources.d.mts.map +1 -0
  644. package/resources.d.ts +2 -0
  645. package/resources.d.ts.map +1 -0
  646. package/resources.js +5 -0
  647. package/resources.js.map +1 -0
  648. package/resources.mjs +2 -0
  649. package/resources.mjs.map +1 -0
  650. package/src/_vendor/partial-json-parser/README.md +3 -0
  651. package/src/_vendor/partial-json-parser/parser.ts +264 -0
  652. package/src/ainative.ts +85 -0
  653. package/src/api-promise.ts +2 -0
  654. package/src/client.ts +1326 -0
  655. package/src/core/README.md +3 -0
  656. package/src/core/api-promise.ts +101 -0
  657. package/src/core/error.ts +145 -0
  658. package/src/core/pagination.ts +331 -0
  659. package/src/core/resource.ts +11 -0
  660. package/src/core/streaming.ts +348 -0
  661. package/src/core/uploads.ts +2 -0
  662. package/src/error.ts +2 -0
  663. package/src/helpers/beta/json-schema.ts +75 -0
  664. package/src/helpers/beta/mcp.ts +624 -0
  665. package/src/helpers/beta/memory.ts +28 -0
  666. package/src/helpers/beta/zod.ts +72 -0
  667. package/src/helpers/index.ts +2 -0
  668. package/src/helpers/json-schema.ts +48 -0
  669. package/src/helpers/zod.ts +58 -0
  670. package/src/index.ts +40 -0
  671. package/src/internal/README.md +3 -0
  672. package/src/internal/builtin-types.ts +93 -0
  673. package/src/internal/constants.ts +15 -0
  674. package/src/internal/decoders/jsonl.ts +48 -0
  675. package/src/internal/decoders/line.ts +135 -0
  676. package/src/internal/detect-platform.ts +196 -0
  677. package/src/internal/errors.ts +33 -0
  678. package/src/internal/headers.ts +99 -0
  679. package/src/internal/parse.ts +90 -0
  680. package/src/internal/request-options.ts +93 -0
  681. package/src/internal/shim-types.ts +26 -0
  682. package/src/internal/shims.ts +107 -0
  683. package/src/internal/stream-utils.ts +32 -0
  684. package/src/internal/to-file.ts +159 -0
  685. package/src/internal/types.ts +95 -0
  686. package/src/internal/uploads.ts +204 -0
  687. package/src/internal/utils/base64.ts +40 -0
  688. package/src/internal/utils/bytes.ts +32 -0
  689. package/src/internal/utils/env.ts +18 -0
  690. package/src/internal/utils/log.ts +127 -0
  691. package/src/internal/utils/path.ts +88 -0
  692. package/src/internal/utils/query.ts +23 -0
  693. package/src/internal/utils/sleep.ts +3 -0
  694. package/src/internal/utils/uuid.ts +17 -0
  695. package/src/internal/utils/values.ts +112 -0
  696. package/src/internal/utils.ts +9 -0
  697. package/src/lib/.keep +4 -0
  698. package/src/lib/BetaMessageStream.ts +764 -0
  699. package/src/lib/MessageStream.ts +743 -0
  700. package/src/lib/beta-parser.ts +148 -0
  701. package/src/lib/parser.ts +125 -0
  702. package/src/lib/stainless-helper-header.ts +80 -0
  703. package/src/lib/tools/BetaRunnableTool.ts +40 -0
  704. package/src/lib/tools/BetaToolRunner.ts +494 -0
  705. package/src/lib/tools/CompactionControl.ts +57 -0
  706. package/src/lib/tools/ToolError.ts +47 -0
  707. package/src/lib/tools/ToolRunner.ts +381 -0
  708. package/src/lib/transform-json-schema.ts +124 -0
  709. package/src/pagination.ts +2 -0
  710. package/src/resource.ts +2 -0
  711. package/src/resources/beta/beta.ts +603 -0
  712. package/src/resources/beta/files.ts +261 -0
  713. package/src/resources/beta/index.ts +259 -0
  714. package/src/resources/beta/messages/batches.ts +827 -0
  715. package/src/resources/beta/messages/index.ts +229 -0
  716. package/src/resources/beta/messages/messages.ts +4372 -0
  717. package/src/resources/beta/messages.ts +3 -0
  718. package/src/resources/beta/models.ts +284 -0
  719. package/src/resources/beta/skills/index.ts +26 -0
  720. package/src/resources/beta/skills/skills.ts +384 -0
  721. package/src/resources/beta/skills/versions.ts +374 -0
  722. package/src/resources/beta/skills.ts +3 -0
  723. package/src/resources/beta.ts +3 -0
  724. package/src/resources/completions.ts +230 -0
  725. package/src/resources/index.ts +206 -0
  726. package/src/resources/messages/batches.ts +396 -0
  727. package/src/resources/messages/index.ts +189 -0
  728. package/src/resources/messages/messages.ts +3361 -0
  729. package/src/resources/messages.ts +3 -0
  730. package/src/resources/models.ts +269 -0
  731. package/src/resources/shared.ts +85 -0
  732. package/src/resources/top-level.ts +3 -0
  733. package/src/resources.ts +1 -0
  734. package/src/streaming.ts +2 -0
  735. package/src/tools/memory/node.ts +392 -0
  736. package/src/tsconfig.json +11 -0
  737. package/src/uploads.ts +2 -0
  738. package/src/version.ts +1 -0
  739. package/streaming.d.mts +2 -0
  740. package/streaming.d.mts.map +1 -0
  741. package/streaming.d.ts +2 -0
  742. package/streaming.d.ts.map +1 -0
  743. package/streaming.js +6 -0
  744. package/streaming.js.map +1 -0
  745. package/streaming.mjs +2 -0
  746. package/streaming.mjs.map +1 -0
  747. package/tools/memory/node.d.mts +18 -0
  748. package/tools/memory/node.d.mts.map +1 -0
  749. package/tools/memory/node.d.ts +18 -0
  750. package/tools/memory/node.d.ts.map +1 -0
  751. package/tools/memory/node.js +324 -0
  752. package/tools/memory/node.js.map +1 -0
  753. package/tools/memory/node.mjs +318 -0
  754. package/tools/memory/node.mjs.map +1 -0
  755. package/uploads.d.mts +2 -0
  756. package/uploads.d.mts.map +1 -0
  757. package/uploads.d.ts +2 -0
  758. package/uploads.d.ts.map +1 -0
  759. package/uploads.js +6 -0
  760. package/uploads.js.map +1 -0
  761. package/uploads.mjs +2 -0
  762. package/uploads.mjs.map +1 -0
  763. package/version.d.mts +2 -0
  764. package/version.d.mts.map +1 -0
  765. package/version.d.ts +2 -0
  766. package/version.d.ts.map +1 -0
  767. package/version.js +5 -0
  768. package/version.js.map +1 -0
  769. package/version.mjs +2 -0
  770. package/version.mjs.map +1 -0
@@ -0,0 +1,3361 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIPromise } from '../../core/api-promise';
4
+ import { APIResource } from '../../core/resource';
5
+ import { Stream } from '../../core/streaming';
6
+ import { buildHeaders } from '../../internal/headers';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+ import { stainlessHelperHeader } from '../../lib/stainless-helper-header';
9
+ import { MessageStream } from '../../lib/MessageStream';
10
+ import {
11
+ parseMessage,
12
+ type ExtractParsedContentFromParams,
13
+ type ParseableMessageCreateParams,
14
+ type ParsedMessage,
15
+ } from '../../lib/parser';
16
+ import * as BatchesAPI from './batches';
17
+ import {
18
+ BatchCreateParams,
19
+ BatchListParams,
20
+ Batches,
21
+ DeletedMessageBatch,
22
+ MessageBatch,
23
+ MessageBatchCanceledResult,
24
+ MessageBatchErroredResult,
25
+ MessageBatchExpiredResult,
26
+ MessageBatchIndividualResponse,
27
+ MessageBatchRequestCounts,
28
+ MessageBatchResult,
29
+ MessageBatchSucceededResult,
30
+ MessageBatchesPage,
31
+ } from './batches';
32
+ import * as MessagesAPI from './messages';
33
+
34
+ import { MODEL_NONSTREAMING_TOKENS } from '../../internal/constants';
35
+
36
+ export class Messages extends APIResource {
37
+ batches: BatchesAPI.Batches = new BatchesAPI.Batches(this._client);
38
+
39
+ /**
40
+ * Send a structured list of input messages with text and/or image content, and the
41
+ * model will generate the next message in the conversation.
42
+ *
43
+ * The Messages API can be used for either single queries or stateless multi-turn
44
+ * conversations.
45
+ *
46
+ * Learn more about the Messages API in our
47
+ * [user guide](https://docs.claude.com/en/docs/initial-setup)
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const message = await client.messages.create({
52
+ * max_tokens: 1024,
53
+ * messages: [{ content: 'Hello, world', role: 'user' }],
54
+ * model: 'claude-opus-4-6',
55
+ * });
56
+ * ```
57
+ */
58
+ create(body: MessageCreateParamsNonStreaming, options?: RequestOptions): APIPromise<Message>;
59
+ create(
60
+ body: MessageCreateParamsStreaming,
61
+ options?: RequestOptions,
62
+ ): APIPromise<Stream<RawMessageStreamEvent>>;
63
+ create(
64
+ body: MessageCreateParamsBase,
65
+ options?: RequestOptions,
66
+ ): APIPromise<Stream<RawMessageStreamEvent> | Message>;
67
+ create(
68
+ body: MessageCreateParams,
69
+ options?: RequestOptions,
70
+ ): APIPromise<Message> | APIPromise<Stream<RawMessageStreamEvent>> {
71
+ if (body.model in DEPRECATED_MODELS) {
72
+ console.warn(
73
+ `The model '${body.model}' is deprecated and will reach end-of-life on ${
74
+ DEPRECATED_MODELS[body.model]
75
+ }\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`,
76
+ );
77
+ }
78
+ if (
79
+ body.model in MODELS_TO_WARN_WITH_THINKING_ENABLED &&
80
+ body.thinking &&
81
+ body.thinking.type === 'enabled'
82
+ ) {
83
+ console.warn(
84
+ `Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`,
85
+ );
86
+ }
87
+
88
+ let timeout = (this._client as any)._options.timeout as number | null;
89
+ if (!body.stream && timeout == null) {
90
+ const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
91
+ timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
92
+ }
93
+
94
+ // Collect helper info from tools and messages
95
+ const helperHeader = stainlessHelperHeader(body.tools, body.messages);
96
+
97
+ return this._client.post('/v1/messages', {
98
+ body,
99
+ timeout: timeout ?? 600000,
100
+ ...options,
101
+ headers: buildHeaders([helperHeader, options?.headers]),
102
+ stream: body.stream ?? false,
103
+ }) as APIPromise<Message> | APIPromise<Stream<RawMessageStreamEvent>>;
104
+ }
105
+
106
+ /**
107
+ * Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
108
+ * the response will be automatically parsed and available in the `parsed_output` property of the message.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const message = await client.messages.parse({
113
+ * model: 'claude-sonnet-4-5-20250929',
114
+ * max_tokens: 1024,
115
+ * messages: [{ role: 'user', content: 'What is 2+2?' }],
116
+ * output_config: {
117
+ * format: zodOutputFormat(z.object({ answer: z.number() })),
118
+ * },
119
+ * });
120
+ *
121
+ * console.log(message.parsed_output?.answer); // 4
122
+ * ```
123
+ */
124
+ parse<Params extends MessageCreateParamsNonStreaming>(
125
+ params: Params,
126
+ options?: RequestOptions,
127
+ ): APIPromise<ParsedMessage<ExtractParsedContentFromParams<Params>>> {
128
+ return this.create(params, options).then((message) =>
129
+ parseMessage(message, params, { logger: this._client.logger ?? console }),
130
+ ) as APIPromise<ParsedMessage<ExtractParsedContentFromParams<Params>>>;
131
+ }
132
+
133
+ /**
134
+ * Create a Message stream.
135
+ *
136
+ * If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
137
+ * the final message will include a `parsed_output` property with the parsed content.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const stream = client.messages.stream({
142
+ * model: 'claude-sonnet-4-5-20250929',
143
+ * max_tokens: 1024,
144
+ * messages: [{ role: 'user', content: 'What is 2+2?' }],
145
+ * output_config: {
146
+ * format: zodOutputFormat(z.object({ answer: z.number() })),
147
+ * },
148
+ * });
149
+ *
150
+ * const message = await stream.finalMessage();
151
+ * console.log(message.parsed_output?.answer); // 4
152
+ * ```
153
+ */
154
+ stream<Params extends MessageStreamParams>(
155
+ body: Params,
156
+ options?: RequestOptions,
157
+ ): MessageStream<ExtractParsedContentFromParams<Params>> {
158
+ return MessageStream.createMessage<ExtractParsedContentFromParams<Params>>(
159
+ this,
160
+ body as MessageCreateParamsBase,
161
+ options,
162
+ { logger: this._client.logger ?? console },
163
+ );
164
+ }
165
+
166
+ /**
167
+ * Count the number of tokens in a Message.
168
+ *
169
+ * The Token Count API can be used to count the number of tokens in a Message,
170
+ * including tools, images, and documents, without creating it.
171
+ *
172
+ * Learn more about token counting in our
173
+ * [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting)
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * const messageTokensCount =
178
+ * await client.messages.countTokens({
179
+ * messages: [{ content: 'string', role: 'user' }],
180
+ * model: 'claude-opus-4-6',
181
+ * });
182
+ * ```
183
+ */
184
+ countTokens(body: MessageCountTokensParams, options?: RequestOptions): APIPromise<MessageTokensCount> {
185
+ return this._client.post('/v1/messages/count_tokens', { body, ...options });
186
+ }
187
+ }
188
+
189
+ export interface Base64ImageSource {
190
+ data: string;
191
+
192
+ media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
193
+
194
+ type: 'base64';
195
+ }
196
+
197
+ export interface Base64PDFSource {
198
+ data: string;
199
+
200
+ media_type: 'application/pdf';
201
+
202
+ type: 'base64';
203
+ }
204
+
205
+ export interface BashCodeExecutionOutputBlock {
206
+ file_id: string;
207
+
208
+ type: 'bash_code_execution_output';
209
+ }
210
+
211
+ export interface BashCodeExecutionOutputBlockParam {
212
+ file_id: string;
213
+
214
+ type: 'bash_code_execution_output';
215
+ }
216
+
217
+ export interface BashCodeExecutionResultBlock {
218
+ content: Array<BashCodeExecutionOutputBlock>;
219
+
220
+ return_code: number;
221
+
222
+ stderr: string;
223
+
224
+ stdout: string;
225
+
226
+ type: 'bash_code_execution_result';
227
+ }
228
+
229
+ export interface BashCodeExecutionResultBlockParam {
230
+ content: Array<BashCodeExecutionOutputBlockParam>;
231
+
232
+ return_code: number;
233
+
234
+ stderr: string;
235
+
236
+ stdout: string;
237
+
238
+ type: 'bash_code_execution_result';
239
+ }
240
+
241
+ export interface BashCodeExecutionToolResultBlock {
242
+ content: BashCodeExecutionToolResultError | BashCodeExecutionResultBlock;
243
+
244
+ tool_use_id: string;
245
+
246
+ type: 'bash_code_execution_tool_result';
247
+ }
248
+
249
+ export interface BashCodeExecutionToolResultBlockParam {
250
+ content: BashCodeExecutionToolResultErrorParam | BashCodeExecutionResultBlockParam;
251
+
252
+ tool_use_id: string;
253
+
254
+ type: 'bash_code_execution_tool_result';
255
+
256
+ /**
257
+ * Create a cache control breakpoint at this content block.
258
+ */
259
+ cache_control?: CacheControlEphemeral | null;
260
+ }
261
+
262
+ export interface BashCodeExecutionToolResultError {
263
+ error_code: BashCodeExecutionToolResultErrorCode;
264
+
265
+ type: 'bash_code_execution_tool_result_error';
266
+ }
267
+
268
+ export type BashCodeExecutionToolResultErrorCode =
269
+ | 'invalid_tool_input'
270
+ | 'unavailable'
271
+ | 'too_many_requests'
272
+ | 'execution_time_exceeded'
273
+ | 'output_file_too_large';
274
+
275
+ export interface BashCodeExecutionToolResultErrorParam {
276
+ error_code: BashCodeExecutionToolResultErrorCode;
277
+
278
+ type: 'bash_code_execution_tool_result_error';
279
+ }
280
+
281
+ export interface CacheControlEphemeral {
282
+ type: 'ephemeral';
283
+
284
+ /**
285
+ * The time-to-live for the cache control breakpoint.
286
+ *
287
+ * This may be one the following values:
288
+ *
289
+ * - `5m`: 5 minutes
290
+ * - `1h`: 1 hour
291
+ *
292
+ * Defaults to `5m`.
293
+ */
294
+ ttl?: '5m' | '1h';
295
+ }
296
+
297
+ export interface CacheCreation {
298
+ /**
299
+ * The number of input tokens used to create the 1 hour cache entry.
300
+ */
301
+ ephemeral_1h_input_tokens: number;
302
+
303
+ /**
304
+ * The number of input tokens used to create the 5 minute cache entry.
305
+ */
306
+ ephemeral_5m_input_tokens: number;
307
+ }
308
+
309
+ export interface CitationCharLocation {
310
+ cited_text: string;
311
+
312
+ document_index: number;
313
+
314
+ document_title: string | null;
315
+
316
+ end_char_index: number;
317
+
318
+ file_id: string | null;
319
+
320
+ start_char_index: number;
321
+
322
+ type: 'char_location';
323
+ }
324
+
325
+ export interface CitationCharLocationParam {
326
+ cited_text: string;
327
+
328
+ document_index: number;
329
+
330
+ document_title: string | null;
331
+
332
+ end_char_index: number;
333
+
334
+ start_char_index: number;
335
+
336
+ type: 'char_location';
337
+ }
338
+
339
+ export interface CitationContentBlockLocation {
340
+ cited_text: string;
341
+
342
+ document_index: number;
343
+
344
+ document_title: string | null;
345
+
346
+ end_block_index: number;
347
+
348
+ file_id: string | null;
349
+
350
+ start_block_index: number;
351
+
352
+ type: 'content_block_location';
353
+ }
354
+
355
+ export interface CitationContentBlockLocationParam {
356
+ cited_text: string;
357
+
358
+ document_index: number;
359
+
360
+ document_title: string | null;
361
+
362
+ end_block_index: number;
363
+
364
+ start_block_index: number;
365
+
366
+ type: 'content_block_location';
367
+ }
368
+
369
+ export interface CitationPageLocation {
370
+ cited_text: string;
371
+
372
+ document_index: number;
373
+
374
+ document_title: string | null;
375
+
376
+ end_page_number: number;
377
+
378
+ file_id: string | null;
379
+
380
+ start_page_number: number;
381
+
382
+ type: 'page_location';
383
+ }
384
+
385
+ export interface CitationPageLocationParam {
386
+ cited_text: string;
387
+
388
+ document_index: number;
389
+
390
+ document_title: string | null;
391
+
392
+ end_page_number: number;
393
+
394
+ start_page_number: number;
395
+
396
+ type: 'page_location';
397
+ }
398
+
399
+ export interface CitationSearchResultLocationParam {
400
+ cited_text: string;
401
+
402
+ end_block_index: number;
403
+
404
+ search_result_index: number;
405
+
406
+ source: string;
407
+
408
+ start_block_index: number;
409
+
410
+ title: string | null;
411
+
412
+ type: 'search_result_location';
413
+ }
414
+
415
+ export interface CitationWebSearchResultLocationParam {
416
+ cited_text: string;
417
+
418
+ encrypted_index: string;
419
+
420
+ title: string | null;
421
+
422
+ type: 'web_search_result_location';
423
+
424
+ url: string;
425
+ }
426
+
427
+ export interface CitationsConfig {
428
+ enabled: boolean;
429
+ }
430
+
431
+ export interface CitationsConfigParam {
432
+ enabled?: boolean;
433
+ }
434
+
435
+ export interface CitationsDelta {
436
+ citation:
437
+ | CitationCharLocation
438
+ | CitationPageLocation
439
+ | CitationContentBlockLocation
440
+ | CitationsWebSearchResultLocation
441
+ | CitationsSearchResultLocation;
442
+
443
+ type: 'citations_delta';
444
+ }
445
+
446
+ export interface CitationsSearchResultLocation {
447
+ cited_text: string;
448
+
449
+ end_block_index: number;
450
+
451
+ search_result_index: number;
452
+
453
+ source: string;
454
+
455
+ start_block_index: number;
456
+
457
+ title: string | null;
458
+
459
+ type: 'search_result_location';
460
+ }
461
+
462
+ export interface CitationsWebSearchResultLocation {
463
+ cited_text: string;
464
+
465
+ encrypted_index: string;
466
+
467
+ title: string | null;
468
+
469
+ type: 'web_search_result_location';
470
+
471
+ url: string;
472
+ }
473
+
474
+ export interface CodeExecutionOutputBlock {
475
+ file_id: string;
476
+
477
+ type: 'code_execution_output';
478
+ }
479
+
480
+ export interface CodeExecutionOutputBlockParam {
481
+ file_id: string;
482
+
483
+ type: 'code_execution_output';
484
+ }
485
+
486
+ export interface CodeExecutionResultBlock {
487
+ content: Array<CodeExecutionOutputBlock>;
488
+
489
+ return_code: number;
490
+
491
+ stderr: string;
492
+
493
+ stdout: string;
494
+
495
+ type: 'code_execution_result';
496
+ }
497
+
498
+ export interface CodeExecutionResultBlockParam {
499
+ content: Array<CodeExecutionOutputBlockParam>;
500
+
501
+ return_code: number;
502
+
503
+ stderr: string;
504
+
505
+ stdout: string;
506
+
507
+ type: 'code_execution_result';
508
+ }
509
+
510
+ export interface CodeExecutionTool20250522 {
511
+ /**
512
+ * Name of the tool.
513
+ *
514
+ * This is how the tool will be called by the model and in `tool_use` blocks.
515
+ */
516
+ name: 'code_execution';
517
+
518
+ type: 'code_execution_20250522';
519
+
520
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
521
+
522
+ /**
523
+ * Create a cache control breakpoint at this content block.
524
+ */
525
+ cache_control?: CacheControlEphemeral | null;
526
+
527
+ /**
528
+ * If true, tool will not be included in initial system prompt. Only loaded when
529
+ * returned via tool_reference from tool search.
530
+ */
531
+ defer_loading?: boolean;
532
+
533
+ /**
534
+ * When true, guarantees schema validation on tool names and inputs
535
+ */
536
+ strict?: boolean;
537
+ }
538
+
539
+ export interface CodeExecutionTool20250825 {
540
+ /**
541
+ * Name of the tool.
542
+ *
543
+ * This is how the tool will be called by the model and in `tool_use` blocks.
544
+ */
545
+ name: 'code_execution';
546
+
547
+ type: 'code_execution_20250825';
548
+
549
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
550
+
551
+ /**
552
+ * Create a cache control breakpoint at this content block.
553
+ */
554
+ cache_control?: CacheControlEphemeral | null;
555
+
556
+ /**
557
+ * If true, tool will not be included in initial system prompt. Only loaded when
558
+ * returned via tool_reference from tool search.
559
+ */
560
+ defer_loading?: boolean;
561
+
562
+ /**
563
+ * When true, guarantees schema validation on tool names and inputs
564
+ */
565
+ strict?: boolean;
566
+ }
567
+
568
+ /**
569
+ * Code execution tool with REPL state persistence (daemon mode + gVisor
570
+ * checkpoint).
571
+ */
572
+ export interface CodeExecutionTool20260120 {
573
+ /**
574
+ * Name of the tool.
575
+ *
576
+ * This is how the tool will be called by the model and in `tool_use` blocks.
577
+ */
578
+ name: 'code_execution';
579
+
580
+ type: 'code_execution_20260120';
581
+
582
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
583
+
584
+ /**
585
+ * Create a cache control breakpoint at this content block.
586
+ */
587
+ cache_control?: CacheControlEphemeral | null;
588
+
589
+ /**
590
+ * If true, tool will not be included in initial system prompt. Only loaded when
591
+ * returned via tool_reference from tool search.
592
+ */
593
+ defer_loading?: boolean;
594
+
595
+ /**
596
+ * When true, guarantees schema validation on tool names and inputs
597
+ */
598
+ strict?: boolean;
599
+ }
600
+
601
+ export interface CodeExecutionToolResultBlock {
602
+ /**
603
+ * Code execution result with encrypted stdout for PFC + web_search results.
604
+ */
605
+ content: CodeExecutionToolResultBlockContent;
606
+
607
+ tool_use_id: string;
608
+
609
+ type: 'code_execution_tool_result';
610
+ }
611
+
612
+ /**
613
+ * Code execution result with encrypted stdout for PFC + web_search results.
614
+ */
615
+ export type CodeExecutionToolResultBlockContent =
616
+ | CodeExecutionToolResultError
617
+ | CodeExecutionResultBlock
618
+ | EncryptedCodeExecutionResultBlock;
619
+
620
+ export interface CodeExecutionToolResultBlockParam {
621
+ /**
622
+ * Code execution result with encrypted stdout for PFC + web_search results.
623
+ */
624
+ content: CodeExecutionToolResultBlockParamContent;
625
+
626
+ tool_use_id: string;
627
+
628
+ type: 'code_execution_tool_result';
629
+
630
+ /**
631
+ * Create a cache control breakpoint at this content block.
632
+ */
633
+ cache_control?: CacheControlEphemeral | null;
634
+ }
635
+
636
+ /**
637
+ * Code execution result with encrypted stdout for PFC + web_search results.
638
+ */
639
+ export type CodeExecutionToolResultBlockParamContent =
640
+ | CodeExecutionToolResultErrorParam
641
+ | CodeExecutionResultBlockParam
642
+ | EncryptedCodeExecutionResultBlockParam;
643
+
644
+ export interface CodeExecutionToolResultError {
645
+ error_code: CodeExecutionToolResultErrorCode;
646
+
647
+ type: 'code_execution_tool_result_error';
648
+ }
649
+
650
+ export type CodeExecutionToolResultErrorCode =
651
+ | 'invalid_tool_input'
652
+ | 'unavailable'
653
+ | 'too_many_requests'
654
+ | 'execution_time_exceeded';
655
+
656
+ export interface CodeExecutionToolResultErrorParam {
657
+ error_code: CodeExecutionToolResultErrorCode;
658
+
659
+ type: 'code_execution_tool_result_error';
660
+ }
661
+
662
+ /**
663
+ * Information about the container used in the request (for the code execution
664
+ * tool)
665
+ */
666
+ export interface Container {
667
+ /**
668
+ * Identifier for the container used in this request
669
+ */
670
+ id: string;
671
+
672
+ /**
673
+ * The time at which the container will expire.
674
+ */
675
+ expires_at: string;
676
+ }
677
+
678
+ /**
679
+ * Response model for a file uploaded to the container.
680
+ */
681
+ export interface ContainerUploadBlock {
682
+ file_id: string;
683
+
684
+ type: 'container_upload';
685
+ }
686
+
687
+ /**
688
+ * A content block that represents a file to be uploaded to the container Files
689
+ * uploaded via this block will be available in the container's input directory.
690
+ */
691
+ export interface ContainerUploadBlockParam {
692
+ file_id: string;
693
+
694
+ type: 'container_upload';
695
+
696
+ /**
697
+ * Create a cache control breakpoint at this content block.
698
+ */
699
+ cache_control?: CacheControlEphemeral | null;
700
+ }
701
+
702
+ /**
703
+ * Response model for a file uploaded to the container.
704
+ */
705
+ export type ContentBlock =
706
+ | TextBlock
707
+ | ThinkingBlock
708
+ | RedactedThinkingBlock
709
+ | ToolUseBlock
710
+ | ServerToolUseBlock
711
+ | WebSearchToolResultBlock
712
+ | WebFetchToolResultBlock
713
+ | CodeExecutionToolResultBlock
714
+ | BashCodeExecutionToolResultBlock
715
+ | TextEditorCodeExecutionToolResultBlock
716
+ | ToolSearchToolResultBlock
717
+ | ContainerUploadBlock;
718
+
719
+ /**
720
+ * Regular text content.
721
+ */
722
+ export type ContentBlockParam =
723
+ | TextBlockParam
724
+ | ImageBlockParam
725
+ | DocumentBlockParam
726
+ | SearchResultBlockParam
727
+ | ThinkingBlockParam
728
+ | RedactedThinkingBlockParam
729
+ | ToolUseBlockParam
730
+ | ToolResultBlockParam
731
+ | ServerToolUseBlockParam
732
+ | WebSearchToolResultBlockParam
733
+ | WebFetchToolResultBlockParam
734
+ | CodeExecutionToolResultBlockParam
735
+ | BashCodeExecutionToolResultBlockParam
736
+ | TextEditorCodeExecutionToolResultBlockParam
737
+ | ToolSearchToolResultBlockParam
738
+ | ContainerUploadBlockParam;
739
+
740
+ export interface ContentBlockSource {
741
+ content: string | Array<ContentBlockSourceContent>;
742
+
743
+ type: 'content';
744
+ }
745
+
746
+ export type ContentBlockSourceContent = TextBlockParam | ImageBlockParam;
747
+
748
+ /**
749
+ * Tool invocation directly from the model.
750
+ */
751
+ export interface DirectCaller {
752
+ type: 'direct';
753
+ }
754
+
755
+ export interface DocumentBlock {
756
+ /**
757
+ * Citation configuration for the document
758
+ */
759
+ citations: CitationsConfig | null;
760
+
761
+ source: Base64PDFSource | PlainTextSource;
762
+
763
+ /**
764
+ * The title of the document
765
+ */
766
+ title: string | null;
767
+
768
+ type: 'document';
769
+ }
770
+
771
+ export interface DocumentBlockParam {
772
+ source: Base64PDFSource | PlainTextSource | ContentBlockSource | URLPDFSource;
773
+
774
+ type: 'document';
775
+
776
+ /**
777
+ * Create a cache control breakpoint at this content block.
778
+ */
779
+ cache_control?: CacheControlEphemeral | null;
780
+
781
+ citations?: CitationsConfigParam | null;
782
+
783
+ context?: string | null;
784
+
785
+ title?: string | null;
786
+ }
787
+
788
+ /**
789
+ * Code execution result with encrypted stdout for PFC + web_search results.
790
+ */
791
+ export interface EncryptedCodeExecutionResultBlock {
792
+ content: Array<CodeExecutionOutputBlock>;
793
+
794
+ encrypted_stdout: string;
795
+
796
+ return_code: number;
797
+
798
+ stderr: string;
799
+
800
+ type: 'encrypted_code_execution_result';
801
+ }
802
+
803
+ /**
804
+ * Code execution result with encrypted stdout for PFC + web_search results.
805
+ */
806
+ export interface EncryptedCodeExecutionResultBlockParam {
807
+ content: Array<CodeExecutionOutputBlockParam>;
808
+
809
+ encrypted_stdout: string;
810
+
811
+ return_code: number;
812
+
813
+ stderr: string;
814
+
815
+ type: 'encrypted_code_execution_result';
816
+ }
817
+
818
+ export interface ImageBlockParam {
819
+ source: Base64ImageSource | URLImageSource;
820
+
821
+ type: 'image';
822
+
823
+ /**
824
+ * Create a cache control breakpoint at this content block.
825
+ */
826
+ cache_control?: CacheControlEphemeral | null;
827
+ }
828
+
829
+ export interface InputJSONDelta {
830
+ partial_json: string;
831
+
832
+ type: 'input_json_delta';
833
+ }
834
+
835
+ export interface JSONOutputFormat {
836
+ /**
837
+ * The JSON schema of the format
838
+ */
839
+ schema: { [key: string]: unknown };
840
+
841
+ type: 'json_schema';
842
+ }
843
+
844
+ export interface MemoryTool20250818 {
845
+ /**
846
+ * Name of the tool.
847
+ *
848
+ * This is how the tool will be called by the model and in `tool_use` blocks.
849
+ */
850
+ name: 'memory';
851
+
852
+ type: 'memory_20250818';
853
+
854
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
855
+
856
+ /**
857
+ * Create a cache control breakpoint at this content block.
858
+ */
859
+ cache_control?: CacheControlEphemeral | null;
860
+
861
+ /**
862
+ * If true, tool will not be included in initial system prompt. Only loaded when
863
+ * returned via tool_reference from tool search.
864
+ */
865
+ defer_loading?: boolean;
866
+
867
+ input_examples?: Array<{ [key: string]: unknown }>;
868
+
869
+ /**
870
+ * When true, guarantees schema validation on tool names and inputs
871
+ */
872
+ strict?: boolean;
873
+ }
874
+
875
+ export interface Message {
876
+ /**
877
+ * Unique object identifier.
878
+ *
879
+ * The format and length of IDs may change over time.
880
+ */
881
+ id: string;
882
+
883
+ /**
884
+ * Information about the container used in the request (for the code execution
885
+ * tool)
886
+ */
887
+ container: Container | null;
888
+
889
+ /**
890
+ * Content generated by the model.
891
+ *
892
+ * This is an array of content blocks, each of which has a `type` that determines
893
+ * its shape.
894
+ *
895
+ * Example:
896
+ *
897
+ * ```json
898
+ * [{ "type": "text", "text": "Hi, I'm Claude." }]
899
+ * ```
900
+ *
901
+ * If the request input `messages` ended with an `assistant` turn, then the
902
+ * response `content` will continue directly from that last turn. You can use this
903
+ * to constrain the model's output.
904
+ *
905
+ * For example, if the input `messages` were:
906
+ *
907
+ * ```json
908
+ * [
909
+ * {
910
+ * "role": "user",
911
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
912
+ * },
913
+ * { "role": "assistant", "content": "The best answer is (" }
914
+ * ]
915
+ * ```
916
+ *
917
+ * Then the response `content` might be:
918
+ *
919
+ * ```json
920
+ * [{ "type": "text", "text": "B)" }]
921
+ * ```
922
+ */
923
+ content: Array<ContentBlock>;
924
+
925
+ /**
926
+ * The model that will complete your prompt.\n\nSee
927
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
928
+ * details and options.
929
+ */
930
+ model: Model;
931
+
932
+ /**
933
+ * Conversational role of the generated message.
934
+ *
935
+ * This will always be `"assistant"`.
936
+ */
937
+ role: 'assistant';
938
+
939
+ /**
940
+ * Structured information about a refusal.
941
+ */
942
+ stop_details: RefusalStopDetails | null;
943
+
944
+ /**
945
+ * The reason that we stopped.
946
+ *
947
+ * This may be one the following values:
948
+ *
949
+ * - `"end_turn"`: the model reached a natural stopping point
950
+ * - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
951
+ * - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
952
+ * - `"tool_use"`: the model invoked one or more tools
953
+ * - `"pause_turn"`: we paused a long-running turn. You may provide the response
954
+ * back as-is in a subsequent request to let the model continue.
955
+ * - `"refusal"`: when streaming classifiers intervene to handle potential policy
956
+ * violations
957
+ *
958
+ * In non-streaming mode this value is always non-null. In streaming mode, it is
959
+ * null in the `message_start` event and non-null otherwise.
960
+ */
961
+ stop_reason: StopReason | null;
962
+
963
+ /**
964
+ * Which custom stop sequence was generated, if any.
965
+ *
966
+ * This value will be a non-null string if one of your custom stop sequences was
967
+ * generated.
968
+ */
969
+ stop_sequence: string | null;
970
+
971
+ /**
972
+ * Object type.
973
+ *
974
+ * For Messages, this is always `"message"`.
975
+ */
976
+ type: 'message';
977
+
978
+ /**
979
+ * Billing and rate-limit usage.
980
+ *
981
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
982
+ * underlying cost to our systems.
983
+ *
984
+ * Under the hood, the API transforms requests into a format suitable for the
985
+ * model. The model's output then goes through a parsing stage before becoming an
986
+ * API response. As a result, the token counts in `usage` will not match one-to-one
987
+ * with the exact visible content of an API request or response.
988
+ *
989
+ * For example, `output_tokens` will be non-zero, even for an empty string response
990
+ * from Claude.
991
+ *
992
+ * Total input tokens in a request is the summation of `input_tokens`,
993
+ * `cache_creation_input_tokens`, and `cache_read_input_tokens`.
994
+ */
995
+ usage: Usage;
996
+ }
997
+
998
+ /**
999
+ * Code execution tool with REPL state persistence (daemon mode + gVisor
1000
+ * checkpoint).
1001
+ */
1002
+ export type MessageCountTokensTool =
1003
+ | Tool
1004
+ | ToolBash20250124
1005
+ | CodeExecutionTool20250522
1006
+ | CodeExecutionTool20250825
1007
+ | CodeExecutionTool20260120
1008
+ | MemoryTool20250818
1009
+ | ToolTextEditor20250124
1010
+ | ToolTextEditor20250429
1011
+ | ToolTextEditor20250728
1012
+ | WebSearchTool20250305
1013
+ | WebFetchTool20250910
1014
+ | WebSearchTool20260209
1015
+ | WebFetchTool20260209
1016
+ | WebFetchTool20260309
1017
+ | ToolSearchToolBm25_20251119
1018
+ | ToolSearchToolRegex20251119;
1019
+
1020
+ export interface MessageDeltaUsage {
1021
+ /**
1022
+ * The cumulative number of input tokens used to create the cache entry.
1023
+ */
1024
+ cache_creation_input_tokens: number | null;
1025
+
1026
+ /**
1027
+ * The cumulative number of input tokens read from the cache.
1028
+ */
1029
+ cache_read_input_tokens: number | null;
1030
+
1031
+ /**
1032
+ * The cumulative number of input tokens which were used.
1033
+ */
1034
+ input_tokens: number | null;
1035
+
1036
+ /**
1037
+ * The cumulative number of output tokens which were used.
1038
+ */
1039
+ output_tokens: number;
1040
+
1041
+ /**
1042
+ * The number of server tool requests.
1043
+ */
1044
+ server_tool_use: ServerToolUsage | null;
1045
+ }
1046
+
1047
+ export interface MessageParam {
1048
+ content: string | Array<ContentBlockParam>;
1049
+
1050
+ role: 'user' | 'assistant';
1051
+ }
1052
+
1053
+ export interface MessageTokensCount {
1054
+ /**
1055
+ * The total number of tokens across the provided list of messages, system prompt,
1056
+ * and tools.
1057
+ */
1058
+ input_tokens: number;
1059
+ }
1060
+
1061
+ export interface Metadata {
1062
+ /**
1063
+ * An external identifier for the user who is associated with the request.
1064
+ *
1065
+ * This should be a uuid, hash value, or other opaque identifier. Anthropic may use
1066
+ * this id to help detect abuse. Do not include any identifying information such as
1067
+ * name, email address, or phone number.
1068
+ */
1069
+ user_id?: string | null;
1070
+ }
1071
+
1072
+ /**
1073
+ * The model that will complete your prompt.\n\nSee
1074
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1075
+ * details and options.
1076
+ */
1077
+ export type Model =
1078
+ | 'claude-opus-4-6'
1079
+ | 'claude-sonnet-4-6'
1080
+ | 'claude-haiku-4-5'
1081
+ | 'claude-haiku-4-5-20251001'
1082
+ | 'claude-opus-4-5'
1083
+ | 'claude-opus-4-5-20251101'
1084
+ | 'claude-sonnet-4-5'
1085
+ | 'claude-sonnet-4-5-20250929'
1086
+ | 'claude-opus-4-1'
1087
+ | 'claude-opus-4-1-20250805'
1088
+ | 'claude-opus-4-0'
1089
+ | 'claude-opus-4-20250514'
1090
+ | 'claude-sonnet-4-0'
1091
+ | 'claude-sonnet-4-20250514'
1092
+ | 'claude-3-haiku-20240307'
1093
+ | (string & {});
1094
+
1095
+ export interface OutputConfig {
1096
+ /**
1097
+ * All possible effort levels.
1098
+ */
1099
+ effort?: 'low' | 'medium' | 'high' | 'max' | null;
1100
+
1101
+ /**
1102
+ * A schema to specify Claude's output format in responses. See
1103
+ * [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
1104
+ */
1105
+ format?: JSONOutputFormat | null;
1106
+ }
1107
+
1108
+ const DEPRECATED_MODELS: {
1109
+ [K in Model]?: string;
1110
+ } = {
1111
+ 'claude-1.3': 'November 6th, 2024',
1112
+ 'claude-1.3-100k': 'November 6th, 2024',
1113
+ 'claude-instant-1.1': 'November 6th, 2024',
1114
+ 'claude-instant-1.1-100k': 'November 6th, 2024',
1115
+ 'claude-instant-1.2': 'November 6th, 2024',
1116
+ 'claude-3-sonnet-20240229': 'July 21st, 2025',
1117
+ 'claude-3-opus-20240229': 'January 5th, 2026',
1118
+ 'claude-2.1': 'July 21st, 2025',
1119
+ 'claude-2.0': 'July 21st, 2025',
1120
+ 'claude-3-7-sonnet-latest': 'February 19th, 2026',
1121
+ 'claude-3-7-sonnet-20250219': 'February 19th, 2026',
1122
+ 'claude-3-5-haiku-latest': 'February 19th, 2026',
1123
+ 'claude-3-5-haiku-20241022': 'February 19th, 2026',
1124
+ };
1125
+
1126
+ const MODELS_TO_WARN_WITH_THINKING_ENABLED: Model[] = ['claude-opus-4-6'];
1127
+
1128
+ export interface PlainTextSource {
1129
+ data: string;
1130
+
1131
+ media_type: 'text/plain';
1132
+
1133
+ type: 'text';
1134
+ }
1135
+
1136
+ export type RawContentBlockDelta =
1137
+ | TextDelta
1138
+ | InputJSONDelta
1139
+ | CitationsDelta
1140
+ | ThinkingDelta
1141
+ | SignatureDelta;
1142
+
1143
+ export interface RawContentBlockDeltaEvent {
1144
+ delta: RawContentBlockDelta;
1145
+
1146
+ index: number;
1147
+
1148
+ type: 'content_block_delta';
1149
+ }
1150
+
1151
+ export interface RawContentBlockStartEvent {
1152
+ /**
1153
+ * Response model for a file uploaded to the container.
1154
+ */
1155
+ content_block:
1156
+ | TextBlock
1157
+ | ThinkingBlock
1158
+ | RedactedThinkingBlock
1159
+ | ToolUseBlock
1160
+ | ServerToolUseBlock
1161
+ | WebSearchToolResultBlock
1162
+ | WebFetchToolResultBlock
1163
+ | CodeExecutionToolResultBlock
1164
+ | BashCodeExecutionToolResultBlock
1165
+ | TextEditorCodeExecutionToolResultBlock
1166
+ | ToolSearchToolResultBlock
1167
+ | ContainerUploadBlock;
1168
+
1169
+ index: number;
1170
+
1171
+ type: 'content_block_start';
1172
+ }
1173
+
1174
+ export interface RawContentBlockStopEvent {
1175
+ index: number;
1176
+
1177
+ type: 'content_block_stop';
1178
+ }
1179
+
1180
+ export interface RawMessageDeltaEvent {
1181
+ delta: RawMessageDeltaEvent.Delta;
1182
+
1183
+ type: 'message_delta';
1184
+
1185
+ /**
1186
+ * Billing and rate-limit usage.
1187
+ *
1188
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
1189
+ * underlying cost to our systems.
1190
+ *
1191
+ * Under the hood, the API transforms requests into a format suitable for the
1192
+ * model. The model's output then goes through a parsing stage before becoming an
1193
+ * API response. As a result, the token counts in `usage` will not match one-to-one
1194
+ * with the exact visible content of an API request or response.
1195
+ *
1196
+ * For example, `output_tokens` will be non-zero, even for an empty string response
1197
+ * from Claude.
1198
+ *
1199
+ * Total input tokens in a request is the summation of `input_tokens`,
1200
+ * `cache_creation_input_tokens`, and `cache_read_input_tokens`.
1201
+ */
1202
+ usage: MessageDeltaUsage;
1203
+ }
1204
+
1205
+ export namespace RawMessageDeltaEvent {
1206
+ export interface Delta {
1207
+ /**
1208
+ * Information about the container used in the request (for the code execution
1209
+ * tool)
1210
+ */
1211
+ container: MessagesAPI.Container | null;
1212
+
1213
+ /**
1214
+ * Structured information about a refusal.
1215
+ */
1216
+ stop_details: MessagesAPI.RefusalStopDetails | null;
1217
+
1218
+ stop_reason: MessagesAPI.StopReason | null;
1219
+
1220
+ stop_sequence: string | null;
1221
+ }
1222
+ }
1223
+
1224
+ export interface RawMessageStartEvent {
1225
+ message: Message;
1226
+
1227
+ type: 'message_start';
1228
+ }
1229
+
1230
+ export interface RawMessageStopEvent {
1231
+ type: 'message_stop';
1232
+ }
1233
+
1234
+ export type RawMessageStreamEvent =
1235
+ | RawMessageStartEvent
1236
+ | RawMessageDeltaEvent
1237
+ | RawMessageStopEvent
1238
+ | RawContentBlockStartEvent
1239
+ | RawContentBlockDeltaEvent
1240
+ | RawContentBlockStopEvent;
1241
+
1242
+ export interface RedactedThinkingBlock {
1243
+ data: string;
1244
+
1245
+ type: 'redacted_thinking';
1246
+ }
1247
+
1248
+ export interface RedactedThinkingBlockParam {
1249
+ data: string;
1250
+
1251
+ type: 'redacted_thinking';
1252
+ }
1253
+
1254
+ /**
1255
+ * Structured information about a refusal.
1256
+ */
1257
+ export interface RefusalStopDetails {
1258
+ /**
1259
+ * The policy category that triggered the refusal.
1260
+ *
1261
+ * `null` when the refusal doesn't map to a named category.
1262
+ */
1263
+ category: 'cyber' | 'bio' | null;
1264
+
1265
+ /**
1266
+ * Human-readable explanation of the refusal.
1267
+ *
1268
+ * This text is not guaranteed to be stable. `null` when no explanation is
1269
+ * available for the category.
1270
+ */
1271
+ explanation: string | null;
1272
+
1273
+ type: 'refusal';
1274
+ }
1275
+
1276
+ export interface SearchResultBlockParam {
1277
+ content: Array<TextBlockParam>;
1278
+
1279
+ source: string;
1280
+
1281
+ title: string;
1282
+
1283
+ type: 'search_result';
1284
+
1285
+ /**
1286
+ * Create a cache control breakpoint at this content block.
1287
+ */
1288
+ cache_control?: CacheControlEphemeral | null;
1289
+
1290
+ citations?: CitationsConfigParam;
1291
+ }
1292
+
1293
+ /**
1294
+ * Tool invocation generated by a server-side tool.
1295
+ */
1296
+ export interface ServerToolCaller {
1297
+ tool_id: string;
1298
+
1299
+ type: 'code_execution_20250825';
1300
+ }
1301
+
1302
+ export interface ServerToolCaller20260120 {
1303
+ tool_id: string;
1304
+
1305
+ type: 'code_execution_20260120';
1306
+ }
1307
+
1308
+ export interface ServerToolUsage {
1309
+ /**
1310
+ * The number of web fetch tool requests.
1311
+ */
1312
+ web_fetch_requests: number;
1313
+
1314
+ /**
1315
+ * The number of web search tool requests.
1316
+ */
1317
+ web_search_requests: number;
1318
+ }
1319
+
1320
+ export interface ServerToolUseBlock {
1321
+ id: string;
1322
+
1323
+ /**
1324
+ * Tool invocation directly from the model.
1325
+ */
1326
+ caller: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
1327
+
1328
+ input: unknown;
1329
+
1330
+ name:
1331
+ | 'web_search'
1332
+ | 'web_fetch'
1333
+ | 'code_execution'
1334
+ | 'bash_code_execution'
1335
+ | 'text_editor_code_execution'
1336
+ | 'tool_search_tool_regex'
1337
+ | 'tool_search_tool_bm25';
1338
+
1339
+ type: 'server_tool_use';
1340
+ }
1341
+
1342
+ export interface ServerToolUseBlockParam {
1343
+ id: string;
1344
+
1345
+ input: unknown;
1346
+
1347
+ name:
1348
+ | 'web_search'
1349
+ | 'web_fetch'
1350
+ | 'code_execution'
1351
+ | 'bash_code_execution'
1352
+ | 'text_editor_code_execution'
1353
+ | 'tool_search_tool_regex'
1354
+ | 'tool_search_tool_bm25';
1355
+
1356
+ type: 'server_tool_use';
1357
+
1358
+ /**
1359
+ * Create a cache control breakpoint at this content block.
1360
+ */
1361
+ cache_control?: CacheControlEphemeral | null;
1362
+
1363
+ /**
1364
+ * Tool invocation directly from the model.
1365
+ */
1366
+ caller?: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
1367
+ }
1368
+
1369
+ export interface SignatureDelta {
1370
+ signature: string;
1371
+
1372
+ type: 'signature_delta';
1373
+ }
1374
+
1375
+ export type StopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal';
1376
+
1377
+ export interface TextBlock {
1378
+ /**
1379
+ * Citations supporting the text block.
1380
+ *
1381
+ * The type of citation returned will depend on the type of document being cited.
1382
+ * Citing a PDF results in `page_location`, plain text results in `char_location`,
1383
+ * and content document results in `content_block_location`.
1384
+ */
1385
+ citations: Array<TextCitation> | null;
1386
+
1387
+ text: string;
1388
+
1389
+ type: 'text';
1390
+ }
1391
+
1392
+ export interface TextBlockParam {
1393
+ text: string;
1394
+
1395
+ type: 'text';
1396
+
1397
+ /**
1398
+ * Create a cache control breakpoint at this content block.
1399
+ */
1400
+ cache_control?: CacheControlEphemeral | null;
1401
+
1402
+ citations?: Array<TextCitationParam> | null;
1403
+ }
1404
+
1405
+ export type TextCitation =
1406
+ | CitationCharLocation
1407
+ | CitationPageLocation
1408
+ | CitationContentBlockLocation
1409
+ | CitationsWebSearchResultLocation
1410
+ | CitationsSearchResultLocation;
1411
+
1412
+ export type TextCitationParam =
1413
+ | CitationCharLocationParam
1414
+ | CitationPageLocationParam
1415
+ | CitationContentBlockLocationParam
1416
+ | CitationWebSearchResultLocationParam
1417
+ | CitationSearchResultLocationParam;
1418
+
1419
+ export interface TextDelta {
1420
+ text: string;
1421
+
1422
+ type: 'text_delta';
1423
+ }
1424
+
1425
+ export interface TextEditorCodeExecutionCreateResultBlock {
1426
+ is_file_update: boolean;
1427
+
1428
+ type: 'text_editor_code_execution_create_result';
1429
+ }
1430
+
1431
+ export interface TextEditorCodeExecutionCreateResultBlockParam {
1432
+ is_file_update: boolean;
1433
+
1434
+ type: 'text_editor_code_execution_create_result';
1435
+ }
1436
+
1437
+ export interface TextEditorCodeExecutionStrReplaceResultBlock {
1438
+ lines: Array<string> | null;
1439
+
1440
+ new_lines: number | null;
1441
+
1442
+ new_start: number | null;
1443
+
1444
+ old_lines: number | null;
1445
+
1446
+ old_start: number | null;
1447
+
1448
+ type: 'text_editor_code_execution_str_replace_result';
1449
+ }
1450
+
1451
+ export interface TextEditorCodeExecutionStrReplaceResultBlockParam {
1452
+ type: 'text_editor_code_execution_str_replace_result';
1453
+
1454
+ lines?: Array<string> | null;
1455
+
1456
+ new_lines?: number | null;
1457
+
1458
+ new_start?: number | null;
1459
+
1460
+ old_lines?: number | null;
1461
+
1462
+ old_start?: number | null;
1463
+ }
1464
+
1465
+ export interface TextEditorCodeExecutionToolResultBlock {
1466
+ content:
1467
+ | TextEditorCodeExecutionToolResultError
1468
+ | TextEditorCodeExecutionViewResultBlock
1469
+ | TextEditorCodeExecutionCreateResultBlock
1470
+ | TextEditorCodeExecutionStrReplaceResultBlock;
1471
+
1472
+ tool_use_id: string;
1473
+
1474
+ type: 'text_editor_code_execution_tool_result';
1475
+ }
1476
+
1477
+ export interface TextEditorCodeExecutionToolResultBlockParam {
1478
+ content:
1479
+ | TextEditorCodeExecutionToolResultErrorParam
1480
+ | TextEditorCodeExecutionViewResultBlockParam
1481
+ | TextEditorCodeExecutionCreateResultBlockParam
1482
+ | TextEditorCodeExecutionStrReplaceResultBlockParam;
1483
+
1484
+ tool_use_id: string;
1485
+
1486
+ type: 'text_editor_code_execution_tool_result';
1487
+
1488
+ /**
1489
+ * Create a cache control breakpoint at this content block.
1490
+ */
1491
+ cache_control?: CacheControlEphemeral | null;
1492
+ }
1493
+
1494
+ export interface TextEditorCodeExecutionToolResultError {
1495
+ error_code: TextEditorCodeExecutionToolResultErrorCode;
1496
+
1497
+ error_message: string | null;
1498
+
1499
+ type: 'text_editor_code_execution_tool_result_error';
1500
+ }
1501
+
1502
+ export type TextEditorCodeExecutionToolResultErrorCode =
1503
+ | 'invalid_tool_input'
1504
+ | 'unavailable'
1505
+ | 'too_many_requests'
1506
+ | 'execution_time_exceeded'
1507
+ | 'file_not_found';
1508
+
1509
+ export interface TextEditorCodeExecutionToolResultErrorParam {
1510
+ error_code: TextEditorCodeExecutionToolResultErrorCode;
1511
+
1512
+ type: 'text_editor_code_execution_tool_result_error';
1513
+
1514
+ error_message?: string | null;
1515
+ }
1516
+
1517
+ export interface TextEditorCodeExecutionViewResultBlock {
1518
+ content: string;
1519
+
1520
+ file_type: 'text' | 'image' | 'pdf';
1521
+
1522
+ num_lines: number | null;
1523
+
1524
+ start_line: number | null;
1525
+
1526
+ total_lines: number | null;
1527
+
1528
+ type: 'text_editor_code_execution_view_result';
1529
+ }
1530
+
1531
+ export interface TextEditorCodeExecutionViewResultBlockParam {
1532
+ content: string;
1533
+
1534
+ file_type: 'text' | 'image' | 'pdf';
1535
+
1536
+ type: 'text_editor_code_execution_view_result';
1537
+
1538
+ num_lines?: number | null;
1539
+
1540
+ start_line?: number | null;
1541
+
1542
+ total_lines?: number | null;
1543
+ }
1544
+
1545
+ export interface ThinkingBlock {
1546
+ signature: string;
1547
+
1548
+ thinking: string;
1549
+
1550
+ type: 'thinking';
1551
+ }
1552
+
1553
+ export interface ThinkingBlockParam {
1554
+ signature: string;
1555
+
1556
+ thinking: string;
1557
+
1558
+ type: 'thinking';
1559
+ }
1560
+
1561
+ export interface ThinkingConfigAdaptive {
1562
+ type: 'adaptive';
1563
+
1564
+ /**
1565
+ * Controls how thinking content appears in the response. When set to `summarized`,
1566
+ * thinking is returned normally. When set to `omitted`, thinking content is
1567
+ * redacted but a signature is returned for multi-turn continuity. Defaults to
1568
+ * `summarized`.
1569
+ */
1570
+ display?: 'summarized' | 'omitted' | null;
1571
+ }
1572
+
1573
+ export interface ThinkingConfigDisabled {
1574
+ type: 'disabled';
1575
+ }
1576
+
1577
+ export interface ThinkingConfigEnabled {
1578
+ /**
1579
+ * Determines how many tokens Claude can use for its internal reasoning process.
1580
+ * Larger budgets can enable more thorough analysis for complex problems, improving
1581
+ * response quality.
1582
+ *
1583
+ * Must be ≥1024 and less than `max_tokens`.
1584
+ *
1585
+ * See
1586
+ * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
1587
+ * for details.
1588
+ */
1589
+ budget_tokens: number;
1590
+
1591
+ type: 'enabled';
1592
+
1593
+ /**
1594
+ * Controls how thinking content appears in the response. When set to `summarized`,
1595
+ * thinking is returned normally. When set to `omitted`, thinking content is
1596
+ * redacted but a signature is returned for multi-turn continuity. Defaults to
1597
+ * `summarized`.
1598
+ */
1599
+ display?: 'summarized' | 'omitted' | null;
1600
+ }
1601
+
1602
+ /**
1603
+ * Configuration for enabling Claude's extended thinking.
1604
+ *
1605
+ * When enabled, responses include `thinking` content blocks showing Claude's
1606
+ * thinking process before the final answer. Requires a minimum budget of 1,024
1607
+ * tokens and counts towards your `max_tokens` limit.
1608
+ *
1609
+ * See
1610
+ * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
1611
+ * for details.
1612
+ */
1613
+ export type ThinkingConfigParam = ThinkingConfigEnabled | ThinkingConfigDisabled | ThinkingConfigAdaptive;
1614
+
1615
+ export interface ThinkingDelta {
1616
+ thinking: string;
1617
+
1618
+ type: 'thinking_delta';
1619
+ }
1620
+
1621
+ export interface Tool {
1622
+ /**
1623
+ * [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
1624
+ *
1625
+ * This defines the shape of the `input` that your tool accepts and that the model
1626
+ * will produce.
1627
+ */
1628
+ input_schema: Tool.InputSchema;
1629
+
1630
+ /**
1631
+ * Name of the tool.
1632
+ *
1633
+ * This is how the tool will be called by the model and in `tool_use` blocks.
1634
+ */
1635
+ name: string;
1636
+
1637
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1638
+
1639
+ /**
1640
+ * Create a cache control breakpoint at this content block.
1641
+ */
1642
+ cache_control?: CacheControlEphemeral | null;
1643
+
1644
+ /**
1645
+ * If true, tool will not be included in initial system prompt. Only loaded when
1646
+ * returned via tool_reference from tool search.
1647
+ */
1648
+ defer_loading?: boolean;
1649
+
1650
+ /**
1651
+ * Description of what this tool does.
1652
+ *
1653
+ * Tool descriptions should be as detailed as possible. The more information that
1654
+ * the model has about what the tool is and how to use it, the better it will
1655
+ * perform. You can use natural language descriptions to reinforce important
1656
+ * aspects of the tool input JSON schema.
1657
+ */
1658
+ description?: string;
1659
+
1660
+ /**
1661
+ * Enable eager input streaming for this tool. When true, tool input parameters
1662
+ * will be streamed incrementally as they are generated, and types will be inferred
1663
+ * on-the-fly rather than buffering the full JSON output. When false, streaming is
1664
+ * disabled for this tool even if the fine-grained-tool-streaming beta is active.
1665
+ * When null (default), uses the default behavior based on beta headers.
1666
+ */
1667
+ eager_input_streaming?: boolean | null;
1668
+
1669
+ input_examples?: Array<{ [key: string]: unknown }>;
1670
+
1671
+ /**
1672
+ * When true, guarantees schema validation on tool names and inputs
1673
+ */
1674
+ strict?: boolean;
1675
+
1676
+ type?: 'custom' | null;
1677
+ }
1678
+
1679
+ export namespace Tool {
1680
+ /**
1681
+ * [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
1682
+ *
1683
+ * This defines the shape of the `input` that your tool accepts and that the model
1684
+ * will produce.
1685
+ */
1686
+ export interface InputSchema {
1687
+ type: 'object';
1688
+
1689
+ properties?: unknown | null;
1690
+
1691
+ required?: Array<string> | null;
1692
+
1693
+ [k: string]: unknown;
1694
+ }
1695
+ }
1696
+
1697
+ export interface ToolBash20250124 {
1698
+ /**
1699
+ * Name of the tool.
1700
+ *
1701
+ * This is how the tool will be called by the model and in `tool_use` blocks.
1702
+ */
1703
+ name: 'bash';
1704
+
1705
+ type: 'bash_20250124';
1706
+
1707
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1708
+
1709
+ /**
1710
+ * Create a cache control breakpoint at this content block.
1711
+ */
1712
+ cache_control?: CacheControlEphemeral | null;
1713
+
1714
+ /**
1715
+ * If true, tool will not be included in initial system prompt. Only loaded when
1716
+ * returned via tool_reference from tool search.
1717
+ */
1718
+ defer_loading?: boolean;
1719
+
1720
+ input_examples?: Array<{ [key: string]: unknown }>;
1721
+
1722
+ /**
1723
+ * When true, guarantees schema validation on tool names and inputs
1724
+ */
1725
+ strict?: boolean;
1726
+ }
1727
+
1728
+ /**
1729
+ * How the model should use the provided tools. The model can use a specific tool,
1730
+ * any available tool, decide by itself, or not use tools at all.
1731
+ */
1732
+ export type ToolChoice = ToolChoiceAuto | ToolChoiceAny | ToolChoiceTool | ToolChoiceNone;
1733
+
1734
+ /**
1735
+ * The model will use any available tools.
1736
+ */
1737
+ export interface ToolChoiceAny {
1738
+ type: 'any';
1739
+
1740
+ /**
1741
+ * Whether to disable parallel tool use.
1742
+ *
1743
+ * Defaults to `false`. If set to `true`, the model will output exactly one tool
1744
+ * use.
1745
+ */
1746
+ disable_parallel_tool_use?: boolean;
1747
+ }
1748
+
1749
+ /**
1750
+ * The model will automatically decide whether to use tools.
1751
+ */
1752
+ export interface ToolChoiceAuto {
1753
+ type: 'auto';
1754
+
1755
+ /**
1756
+ * Whether to disable parallel tool use.
1757
+ *
1758
+ * Defaults to `false`. If set to `true`, the model will output at most one tool
1759
+ * use.
1760
+ */
1761
+ disable_parallel_tool_use?: boolean;
1762
+ }
1763
+
1764
+ /**
1765
+ * The model will not be allowed to use tools.
1766
+ */
1767
+ export interface ToolChoiceNone {
1768
+ type: 'none';
1769
+ }
1770
+
1771
+ /**
1772
+ * The model will use the specified tool with `tool_choice.name`.
1773
+ */
1774
+ export interface ToolChoiceTool {
1775
+ /**
1776
+ * The name of the tool to use.
1777
+ */
1778
+ name: string;
1779
+
1780
+ type: 'tool';
1781
+
1782
+ /**
1783
+ * Whether to disable parallel tool use.
1784
+ *
1785
+ * Defaults to `false`. If set to `true`, the model will output exactly one tool
1786
+ * use.
1787
+ */
1788
+ disable_parallel_tool_use?: boolean;
1789
+ }
1790
+
1791
+ export interface ToolReferenceBlock {
1792
+ tool_name: string;
1793
+
1794
+ type: 'tool_reference';
1795
+ }
1796
+
1797
+ /**
1798
+ * Tool reference block that can be included in tool_result content.
1799
+ */
1800
+ export interface ToolReferenceBlockParam {
1801
+ tool_name: string;
1802
+
1803
+ type: 'tool_reference';
1804
+
1805
+ /**
1806
+ * Create a cache control breakpoint at this content block.
1807
+ */
1808
+ cache_control?: CacheControlEphemeral | null;
1809
+ }
1810
+
1811
+ export interface ToolResultBlockParam {
1812
+ tool_use_id: string;
1813
+
1814
+ type: 'tool_result';
1815
+
1816
+ /**
1817
+ * Create a cache control breakpoint at this content block.
1818
+ */
1819
+ cache_control?: CacheControlEphemeral | null;
1820
+
1821
+ content?:
1822
+ | string
1823
+ | Array<
1824
+ | TextBlockParam
1825
+ | ImageBlockParam
1826
+ | SearchResultBlockParam
1827
+ | DocumentBlockParam
1828
+ | ToolReferenceBlockParam
1829
+ >;
1830
+
1831
+ is_error?: boolean;
1832
+ }
1833
+
1834
+ export interface ToolSearchToolBm25_20251119 {
1835
+ /**
1836
+ * Name of the tool.
1837
+ *
1838
+ * This is how the tool will be called by the model and in `tool_use` blocks.
1839
+ */
1840
+ name: 'tool_search_tool_bm25';
1841
+
1842
+ type: 'tool_search_tool_bm25_20251119' | 'tool_search_tool_bm25';
1843
+
1844
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1845
+
1846
+ /**
1847
+ * Create a cache control breakpoint at this content block.
1848
+ */
1849
+ cache_control?: CacheControlEphemeral | null;
1850
+
1851
+ /**
1852
+ * If true, tool will not be included in initial system prompt. Only loaded when
1853
+ * returned via tool_reference from tool search.
1854
+ */
1855
+ defer_loading?: boolean;
1856
+
1857
+ /**
1858
+ * When true, guarantees schema validation on tool names and inputs
1859
+ */
1860
+ strict?: boolean;
1861
+ }
1862
+
1863
+ export interface ToolSearchToolRegex20251119 {
1864
+ /**
1865
+ * Name of the tool.
1866
+ *
1867
+ * This is how the tool will be called by the model and in `tool_use` blocks.
1868
+ */
1869
+ name: 'tool_search_tool_regex';
1870
+
1871
+ type: 'tool_search_tool_regex_20251119' | 'tool_search_tool_regex';
1872
+
1873
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1874
+
1875
+ /**
1876
+ * Create a cache control breakpoint at this content block.
1877
+ */
1878
+ cache_control?: CacheControlEphemeral | null;
1879
+
1880
+ /**
1881
+ * If true, tool will not be included in initial system prompt. Only loaded when
1882
+ * returned via tool_reference from tool search.
1883
+ */
1884
+ defer_loading?: boolean;
1885
+
1886
+ /**
1887
+ * When true, guarantees schema validation on tool names and inputs
1888
+ */
1889
+ strict?: boolean;
1890
+ }
1891
+
1892
+ export interface ToolSearchToolResultBlock {
1893
+ content: ToolSearchToolResultError | ToolSearchToolSearchResultBlock;
1894
+
1895
+ tool_use_id: string;
1896
+
1897
+ type: 'tool_search_tool_result';
1898
+ }
1899
+
1900
+ export interface ToolSearchToolResultBlockParam {
1901
+ content: ToolSearchToolResultErrorParam | ToolSearchToolSearchResultBlockParam;
1902
+
1903
+ tool_use_id: string;
1904
+
1905
+ type: 'tool_search_tool_result';
1906
+
1907
+ /**
1908
+ * Create a cache control breakpoint at this content block.
1909
+ */
1910
+ cache_control?: CacheControlEphemeral | null;
1911
+ }
1912
+
1913
+ export interface ToolSearchToolResultError {
1914
+ error_code: ToolSearchToolResultErrorCode;
1915
+
1916
+ error_message: string | null;
1917
+
1918
+ type: 'tool_search_tool_result_error';
1919
+ }
1920
+
1921
+ export type ToolSearchToolResultErrorCode =
1922
+ | 'invalid_tool_input'
1923
+ | 'unavailable'
1924
+ | 'too_many_requests'
1925
+ | 'execution_time_exceeded';
1926
+
1927
+ export interface ToolSearchToolResultErrorParam {
1928
+ error_code: ToolSearchToolResultErrorCode;
1929
+
1930
+ type: 'tool_search_tool_result_error';
1931
+ }
1932
+
1933
+ export interface ToolSearchToolSearchResultBlock {
1934
+ tool_references: Array<ToolReferenceBlock>;
1935
+
1936
+ type: 'tool_search_tool_search_result';
1937
+ }
1938
+
1939
+ export interface ToolSearchToolSearchResultBlockParam {
1940
+ tool_references: Array<ToolReferenceBlockParam>;
1941
+
1942
+ type: 'tool_search_tool_search_result';
1943
+ }
1944
+
1945
+ export interface ToolTextEditor20250124 {
1946
+ /**
1947
+ * Name of the tool.
1948
+ *
1949
+ * This is how the tool will be called by the model and in `tool_use` blocks.
1950
+ */
1951
+ name: 'str_replace_editor';
1952
+
1953
+ type: 'text_editor_20250124';
1954
+
1955
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1956
+
1957
+ /**
1958
+ * Create a cache control breakpoint at this content block.
1959
+ */
1960
+ cache_control?: CacheControlEphemeral | null;
1961
+
1962
+ /**
1963
+ * If true, tool will not be included in initial system prompt. Only loaded when
1964
+ * returned via tool_reference from tool search.
1965
+ */
1966
+ defer_loading?: boolean;
1967
+
1968
+ input_examples?: Array<{ [key: string]: unknown }>;
1969
+
1970
+ /**
1971
+ * When true, guarantees schema validation on tool names and inputs
1972
+ */
1973
+ strict?: boolean;
1974
+ }
1975
+
1976
+ export interface ToolTextEditor20250429 {
1977
+ /**
1978
+ * Name of the tool.
1979
+ *
1980
+ * This is how the tool will be called by the model and in `tool_use` blocks.
1981
+ */
1982
+ name: 'str_replace_based_edit_tool';
1983
+
1984
+ type: 'text_editor_20250429';
1985
+
1986
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1987
+
1988
+ /**
1989
+ * Create a cache control breakpoint at this content block.
1990
+ */
1991
+ cache_control?: CacheControlEphemeral | null;
1992
+
1993
+ /**
1994
+ * If true, tool will not be included in initial system prompt. Only loaded when
1995
+ * returned via tool_reference from tool search.
1996
+ */
1997
+ defer_loading?: boolean;
1998
+
1999
+ input_examples?: Array<{ [key: string]: unknown }>;
2000
+
2001
+ /**
2002
+ * When true, guarantees schema validation on tool names and inputs
2003
+ */
2004
+ strict?: boolean;
2005
+ }
2006
+
2007
+ export interface ToolTextEditor20250728 {
2008
+ /**
2009
+ * Name of the tool.
2010
+ *
2011
+ * This is how the tool will be called by the model and in `tool_use` blocks.
2012
+ */
2013
+ name: 'str_replace_based_edit_tool';
2014
+
2015
+ type: 'text_editor_20250728';
2016
+
2017
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2018
+
2019
+ /**
2020
+ * Create a cache control breakpoint at this content block.
2021
+ */
2022
+ cache_control?: CacheControlEphemeral | null;
2023
+
2024
+ /**
2025
+ * If true, tool will not be included in initial system prompt. Only loaded when
2026
+ * returned via tool_reference from tool search.
2027
+ */
2028
+ defer_loading?: boolean;
2029
+
2030
+ input_examples?: Array<{ [key: string]: unknown }>;
2031
+
2032
+ /**
2033
+ * Maximum number of characters to display when viewing a file. If not specified,
2034
+ * defaults to displaying the full file.
2035
+ */
2036
+ max_characters?: number | null;
2037
+
2038
+ /**
2039
+ * When true, guarantees schema validation on tool names and inputs
2040
+ */
2041
+ strict?: boolean;
2042
+ }
2043
+
2044
+ /**
2045
+ * Code execution tool with REPL state persistence (daemon mode + gVisor
2046
+ * checkpoint).
2047
+ */
2048
+ export type ToolUnion =
2049
+ | Tool
2050
+ | ToolBash20250124
2051
+ | CodeExecutionTool20250522
2052
+ | CodeExecutionTool20250825
2053
+ | CodeExecutionTool20260120
2054
+ | MemoryTool20250818
2055
+ | ToolTextEditor20250124
2056
+ | ToolTextEditor20250429
2057
+ | ToolTextEditor20250728
2058
+ | WebSearchTool20250305
2059
+ | WebFetchTool20250910
2060
+ | WebSearchTool20260209
2061
+ | WebFetchTool20260209
2062
+ | WebFetchTool20260309
2063
+ | ToolSearchToolBm25_20251119
2064
+ | ToolSearchToolRegex20251119;
2065
+
2066
+ export interface ToolUseBlock {
2067
+ id: string;
2068
+
2069
+ /**
2070
+ * Tool invocation directly from the model.
2071
+ */
2072
+ caller: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
2073
+
2074
+ input: unknown;
2075
+
2076
+ name: string;
2077
+
2078
+ type: 'tool_use';
2079
+ }
2080
+
2081
+ export interface ToolUseBlockParam {
2082
+ id: string;
2083
+
2084
+ input: unknown;
2085
+
2086
+ name: string;
2087
+
2088
+ type: 'tool_use';
2089
+
2090
+ /**
2091
+ * Create a cache control breakpoint at this content block.
2092
+ */
2093
+ cache_control?: CacheControlEphemeral | null;
2094
+
2095
+ /**
2096
+ * Tool invocation directly from the model.
2097
+ */
2098
+ caller?: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
2099
+ }
2100
+
2101
+ export interface URLImageSource {
2102
+ type: 'url';
2103
+
2104
+ url: string;
2105
+ }
2106
+
2107
+ export interface URLPDFSource {
2108
+ type: 'url';
2109
+
2110
+ url: string;
2111
+ }
2112
+
2113
+ export interface Usage {
2114
+ /**
2115
+ * Breakdown of cached tokens by TTL
2116
+ */
2117
+ cache_creation: CacheCreation | null;
2118
+
2119
+ /**
2120
+ * The number of input tokens used to create the cache entry.
2121
+ */
2122
+ cache_creation_input_tokens: number | null;
2123
+
2124
+ /**
2125
+ * The number of input tokens read from the cache.
2126
+ */
2127
+ cache_read_input_tokens: number | null;
2128
+
2129
+ /**
2130
+ * The geographic region where inference was performed for this request.
2131
+ */
2132
+ inference_geo: string | null;
2133
+
2134
+ /**
2135
+ * The number of input tokens which were used.
2136
+ */
2137
+ input_tokens: number;
2138
+
2139
+ /**
2140
+ * The number of output tokens which were used.
2141
+ */
2142
+ output_tokens: number;
2143
+
2144
+ /**
2145
+ * The number of server tool requests.
2146
+ */
2147
+ server_tool_use: ServerToolUsage | null;
2148
+
2149
+ /**
2150
+ * If the request used the priority, standard, or batch tier.
2151
+ */
2152
+ service_tier: 'standard' | 'priority' | 'batch' | null;
2153
+ }
2154
+
2155
+ export interface UserLocation {
2156
+ type: 'approximate';
2157
+
2158
+ /**
2159
+ * The city of the user.
2160
+ */
2161
+ city?: string | null;
2162
+
2163
+ /**
2164
+ * The two letter
2165
+ * [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
2166
+ * user.
2167
+ */
2168
+ country?: string | null;
2169
+
2170
+ /**
2171
+ * The region of the user.
2172
+ */
2173
+ region?: string | null;
2174
+
2175
+ /**
2176
+ * The [IANA timezone](https://nodatime.org/TimeZones) of the user.
2177
+ */
2178
+ timezone?: string | null;
2179
+ }
2180
+
2181
+ export interface WebFetchBlock {
2182
+ content: DocumentBlock;
2183
+
2184
+ /**
2185
+ * ISO 8601 timestamp when the content was retrieved
2186
+ */
2187
+ retrieved_at: string | null;
2188
+
2189
+ type: 'web_fetch_result';
2190
+
2191
+ /**
2192
+ * Fetched content URL
2193
+ */
2194
+ url: string;
2195
+ }
2196
+
2197
+ export interface WebFetchBlockParam {
2198
+ content: DocumentBlockParam;
2199
+
2200
+ type: 'web_fetch_result';
2201
+
2202
+ /**
2203
+ * Fetched content URL
2204
+ */
2205
+ url: string;
2206
+
2207
+ /**
2208
+ * ISO 8601 timestamp when the content was retrieved
2209
+ */
2210
+ retrieved_at?: string | null;
2211
+ }
2212
+
2213
+ export interface WebFetchTool20250910 {
2214
+ /**
2215
+ * Name of the tool.
2216
+ *
2217
+ * This is how the tool will be called by the model and in `tool_use` blocks.
2218
+ */
2219
+ name: 'web_fetch';
2220
+
2221
+ type: 'web_fetch_20250910';
2222
+
2223
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2224
+
2225
+ /**
2226
+ * List of domains to allow fetching from
2227
+ */
2228
+ allowed_domains?: Array<string> | null;
2229
+
2230
+ /**
2231
+ * List of domains to block fetching from
2232
+ */
2233
+ blocked_domains?: Array<string> | null;
2234
+
2235
+ /**
2236
+ * Create a cache control breakpoint at this content block.
2237
+ */
2238
+ cache_control?: CacheControlEphemeral | null;
2239
+
2240
+ /**
2241
+ * Citations configuration for fetched documents. Citations are disabled by
2242
+ * default.
2243
+ */
2244
+ citations?: CitationsConfigParam | null;
2245
+
2246
+ /**
2247
+ * If true, tool will not be included in initial system prompt. Only loaded when
2248
+ * returned via tool_reference from tool search.
2249
+ */
2250
+ defer_loading?: boolean;
2251
+
2252
+ /**
2253
+ * Maximum number of tokens used by including web page text content in the context.
2254
+ * The limit is approximate and does not apply to binary content such as PDFs.
2255
+ */
2256
+ max_content_tokens?: number | null;
2257
+
2258
+ /**
2259
+ * Maximum number of times the tool can be used in the API request.
2260
+ */
2261
+ max_uses?: number | null;
2262
+
2263
+ /**
2264
+ * When true, guarantees schema validation on tool names and inputs
2265
+ */
2266
+ strict?: boolean;
2267
+ }
2268
+
2269
+ export interface WebFetchTool20260209 {
2270
+ /**
2271
+ * Name of the tool.
2272
+ *
2273
+ * This is how the tool will be called by the model and in `tool_use` blocks.
2274
+ */
2275
+ name: 'web_fetch';
2276
+
2277
+ type: 'web_fetch_20260209';
2278
+
2279
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2280
+
2281
+ /**
2282
+ * List of domains to allow fetching from
2283
+ */
2284
+ allowed_domains?: Array<string> | null;
2285
+
2286
+ /**
2287
+ * List of domains to block fetching from
2288
+ */
2289
+ blocked_domains?: Array<string> | null;
2290
+
2291
+ /**
2292
+ * Create a cache control breakpoint at this content block.
2293
+ */
2294
+ cache_control?: CacheControlEphemeral | null;
2295
+
2296
+ /**
2297
+ * Citations configuration for fetched documents. Citations are disabled by
2298
+ * default.
2299
+ */
2300
+ citations?: CitationsConfigParam | null;
2301
+
2302
+ /**
2303
+ * If true, tool will not be included in initial system prompt. Only loaded when
2304
+ * returned via tool_reference from tool search.
2305
+ */
2306
+ defer_loading?: boolean;
2307
+
2308
+ /**
2309
+ * Maximum number of tokens used by including web page text content in the context.
2310
+ * The limit is approximate and does not apply to binary content such as PDFs.
2311
+ */
2312
+ max_content_tokens?: number | null;
2313
+
2314
+ /**
2315
+ * Maximum number of times the tool can be used in the API request.
2316
+ */
2317
+ max_uses?: number | null;
2318
+
2319
+ /**
2320
+ * When true, guarantees schema validation on tool names and inputs
2321
+ */
2322
+ strict?: boolean;
2323
+ }
2324
+
2325
+ /**
2326
+ * Web fetch tool with use_cache parameter for bypassing cached content.
2327
+ */
2328
+ export interface WebFetchTool20260309 {
2329
+ /**
2330
+ * Name of the tool.
2331
+ *
2332
+ * This is how the tool will be called by the model and in `tool_use` blocks.
2333
+ */
2334
+ name: 'web_fetch';
2335
+
2336
+ type: 'web_fetch_20260309';
2337
+
2338
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2339
+
2340
+ /**
2341
+ * List of domains to allow fetching from
2342
+ */
2343
+ allowed_domains?: Array<string> | null;
2344
+
2345
+ /**
2346
+ * List of domains to block fetching from
2347
+ */
2348
+ blocked_domains?: Array<string> | null;
2349
+
2350
+ /**
2351
+ * Create a cache control breakpoint at this content block.
2352
+ */
2353
+ cache_control?: CacheControlEphemeral | null;
2354
+
2355
+ /**
2356
+ * Citations configuration for fetched documents. Citations are disabled by
2357
+ * default.
2358
+ */
2359
+ citations?: CitationsConfigParam | null;
2360
+
2361
+ /**
2362
+ * If true, tool will not be included in initial system prompt. Only loaded when
2363
+ * returned via tool_reference from tool search.
2364
+ */
2365
+ defer_loading?: boolean;
2366
+
2367
+ /**
2368
+ * Maximum number of tokens used by including web page text content in the context.
2369
+ * The limit is approximate and does not apply to binary content such as PDFs.
2370
+ */
2371
+ max_content_tokens?: number | null;
2372
+
2373
+ /**
2374
+ * Maximum number of times the tool can be used in the API request.
2375
+ */
2376
+ max_uses?: number | null;
2377
+
2378
+ /**
2379
+ * When true, guarantees schema validation on tool names and inputs
2380
+ */
2381
+ strict?: boolean;
2382
+
2383
+ /**
2384
+ * Whether to use cached content. Set to false to bypass the cache and fetch fresh
2385
+ * content. Only set to false when the user explicitly requests fresh content or
2386
+ * when fetching rapidly-changing sources.
2387
+ */
2388
+ use_cache?: boolean;
2389
+ }
2390
+
2391
+ export interface WebFetchToolResultBlock {
2392
+ /**
2393
+ * Tool invocation directly from the model.
2394
+ */
2395
+ caller: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
2396
+
2397
+ content: WebFetchToolResultErrorBlock | WebFetchBlock;
2398
+
2399
+ tool_use_id: string;
2400
+
2401
+ type: 'web_fetch_tool_result';
2402
+ }
2403
+
2404
+ export interface WebFetchToolResultBlockParam {
2405
+ content: WebFetchToolResultErrorBlockParam | WebFetchBlockParam;
2406
+
2407
+ tool_use_id: string;
2408
+
2409
+ type: 'web_fetch_tool_result';
2410
+
2411
+ /**
2412
+ * Create a cache control breakpoint at this content block.
2413
+ */
2414
+ cache_control?: CacheControlEphemeral | null;
2415
+
2416
+ /**
2417
+ * Tool invocation directly from the model.
2418
+ */
2419
+ caller?: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
2420
+ }
2421
+
2422
+ export interface WebFetchToolResultErrorBlock {
2423
+ error_code: WebFetchToolResultErrorCode;
2424
+
2425
+ type: 'web_fetch_tool_result_error';
2426
+ }
2427
+
2428
+ export interface WebFetchToolResultErrorBlockParam {
2429
+ error_code: WebFetchToolResultErrorCode;
2430
+
2431
+ type: 'web_fetch_tool_result_error';
2432
+ }
2433
+
2434
+ export type WebFetchToolResultErrorCode =
2435
+ | 'invalid_tool_input'
2436
+ | 'url_too_long'
2437
+ | 'url_not_allowed'
2438
+ | 'url_not_accessible'
2439
+ | 'unsupported_content_type'
2440
+ | 'too_many_requests'
2441
+ | 'max_uses_exceeded'
2442
+ | 'unavailable';
2443
+
2444
+ export interface WebSearchResultBlock {
2445
+ encrypted_content: string;
2446
+
2447
+ page_age: string | null;
2448
+
2449
+ title: string;
2450
+
2451
+ type: 'web_search_result';
2452
+
2453
+ url: string;
2454
+ }
2455
+
2456
+ export interface WebSearchResultBlockParam {
2457
+ encrypted_content: string;
2458
+
2459
+ title: string;
2460
+
2461
+ type: 'web_search_result';
2462
+
2463
+ url: string;
2464
+
2465
+ page_age?: string | null;
2466
+ }
2467
+
2468
+ export interface WebSearchTool20250305 {
2469
+ /**
2470
+ * Name of the tool.
2471
+ *
2472
+ * This is how the tool will be called by the model and in `tool_use` blocks.
2473
+ */
2474
+ name: 'web_search';
2475
+
2476
+ type: 'web_search_20250305';
2477
+
2478
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2479
+
2480
+ /**
2481
+ * If provided, only these domains will be included in results. Cannot be used
2482
+ * alongside `blocked_domains`.
2483
+ */
2484
+ allowed_domains?: Array<string> | null;
2485
+
2486
+ /**
2487
+ * If provided, these domains will never appear in results. Cannot be used
2488
+ * alongside `allowed_domains`.
2489
+ */
2490
+ blocked_domains?: Array<string> | null;
2491
+
2492
+ /**
2493
+ * Create a cache control breakpoint at this content block.
2494
+ */
2495
+ cache_control?: CacheControlEphemeral | null;
2496
+
2497
+ /**
2498
+ * If true, tool will not be included in initial system prompt. Only loaded when
2499
+ * returned via tool_reference from tool search.
2500
+ */
2501
+ defer_loading?: boolean;
2502
+
2503
+ /**
2504
+ * Maximum number of times the tool can be used in the API request.
2505
+ */
2506
+ max_uses?: number | null;
2507
+
2508
+ /**
2509
+ * When true, guarantees schema validation on tool names and inputs
2510
+ */
2511
+ strict?: boolean;
2512
+
2513
+ /**
2514
+ * Parameters for the user's location. Used to provide more relevant search
2515
+ * results.
2516
+ */
2517
+ user_location?: UserLocation | null;
2518
+ }
2519
+
2520
+ // backward compat
2521
+ export namespace WebSearchTool20250305 {
2522
+ /**
2523
+ * @deprecated Import `UserLocation` from `anthropic` directly instead of using
2524
+ * `WebSearchTool20250305.UserLocation`.
2525
+ */
2526
+ export type UserLocation = Messages.UserLocation;
2527
+ }
2528
+
2529
+ export interface WebSearchTool20260209 {
2530
+ /**
2531
+ * Name of the tool.
2532
+ *
2533
+ * This is how the tool will be called by the model and in `tool_use` blocks.
2534
+ */
2535
+ name: 'web_search';
2536
+
2537
+ type: 'web_search_20260209';
2538
+
2539
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
2540
+
2541
+ /**
2542
+ * If provided, only these domains will be included in results. Cannot be used
2543
+ * alongside `blocked_domains`.
2544
+ */
2545
+ allowed_domains?: Array<string> | null;
2546
+
2547
+ /**
2548
+ * If provided, these domains will never appear in results. Cannot be used
2549
+ * alongside `allowed_domains`.
2550
+ */
2551
+ blocked_domains?: Array<string> | null;
2552
+
2553
+ /**
2554
+ * Create a cache control breakpoint at this content block.
2555
+ */
2556
+ cache_control?: CacheControlEphemeral | null;
2557
+
2558
+ /**
2559
+ * If true, tool will not be included in initial system prompt. Only loaded when
2560
+ * returned via tool_reference from tool search.
2561
+ */
2562
+ defer_loading?: boolean;
2563
+
2564
+ /**
2565
+ * Maximum number of times the tool can be used in the API request.
2566
+ */
2567
+ max_uses?: number | null;
2568
+
2569
+ /**
2570
+ * When true, guarantees schema validation on tool names and inputs
2571
+ */
2572
+ strict?: boolean;
2573
+
2574
+ /**
2575
+ * Parameters for the user's location. Used to provide more relevant search
2576
+ * results.
2577
+ */
2578
+ user_location?: UserLocation | null;
2579
+ }
2580
+
2581
+ // backward compat
2582
+ export namespace WebSearchTool20260209 {
2583
+ /**
2584
+ * @deprecated Import `UserLocation` from `anthropic` directly instead of using
2585
+ * `WebSearchTool20260209.UserLocation`.
2586
+ */
2587
+ export type UserLocation = Messages.UserLocation;
2588
+ }
2589
+
2590
+ export interface WebSearchToolRequestError {
2591
+ error_code: WebSearchToolResultErrorCode;
2592
+
2593
+ type: 'web_search_tool_result_error';
2594
+ }
2595
+
2596
+ export interface WebSearchToolResultBlock {
2597
+ /**
2598
+ * Tool invocation directly from the model.
2599
+ */
2600
+ caller: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
2601
+
2602
+ content: WebSearchToolResultBlockContent;
2603
+
2604
+ tool_use_id: string;
2605
+
2606
+ type: 'web_search_tool_result';
2607
+ }
2608
+
2609
+ export type WebSearchToolResultBlockContent = WebSearchToolResultError | Array<WebSearchResultBlock>;
2610
+
2611
+ export interface WebSearchToolResultBlockParam {
2612
+ content: WebSearchToolResultBlockParamContent;
2613
+
2614
+ tool_use_id: string;
2615
+
2616
+ type: 'web_search_tool_result';
2617
+
2618
+ /**
2619
+ * Create a cache control breakpoint at this content block.
2620
+ */
2621
+ cache_control?: CacheControlEphemeral | null;
2622
+
2623
+ /**
2624
+ * Tool invocation directly from the model.
2625
+ */
2626
+ caller?: DirectCaller | ServerToolCaller | ServerToolCaller20260120;
2627
+ }
2628
+
2629
+ export type WebSearchToolResultBlockParamContent =
2630
+ | Array<WebSearchResultBlockParam>
2631
+ | WebSearchToolRequestError;
2632
+
2633
+ export interface WebSearchToolResultError {
2634
+ error_code: WebSearchToolResultErrorCode;
2635
+
2636
+ type: 'web_search_tool_result_error';
2637
+ }
2638
+
2639
+ export type WebSearchToolResultErrorCode =
2640
+ | 'invalid_tool_input'
2641
+ | 'unavailable'
2642
+ | 'max_uses_exceeded'
2643
+ | 'too_many_requests'
2644
+ | 'query_too_long'
2645
+ | 'request_too_large';
2646
+
2647
+ export type MessageStreamEvent = RawMessageStreamEvent;
2648
+
2649
+ export type MessageStartEvent = RawMessageStartEvent;
2650
+
2651
+ export type MessageDeltaEvent = RawMessageDeltaEvent;
2652
+
2653
+ export type MessageStopEvent = RawMessageStopEvent;
2654
+
2655
+ export type ContentBlockStartEvent = RawContentBlockStartEvent;
2656
+
2657
+ export type ContentBlockDeltaEvent = RawContentBlockDeltaEvent;
2658
+
2659
+ export type ContentBlockStopEvent = RawContentBlockStopEvent;
2660
+
2661
+ export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
2662
+
2663
+ export interface MessageCreateParamsBase {
2664
+ /**
2665
+ * The maximum number of tokens to generate before stopping.
2666
+ *
2667
+ * Note that our models may stop _before_ reaching this maximum. This parameter
2668
+ * only specifies the absolute maximum number of tokens to generate.
2669
+ *
2670
+ * Different models have different maximum values for this parameter. See
2671
+ * [models](https://docs.claude.com/en/docs/models-overview) for details.
2672
+ */
2673
+ max_tokens: number;
2674
+
2675
+ /**
2676
+ * Input messages.
2677
+ *
2678
+ * Our models are trained to operate on alternating `user` and `assistant`
2679
+ * conversational turns. When creating a new `Message`, you specify the prior
2680
+ * conversational turns with the `messages` parameter, and the model then generates
2681
+ * the next `Message` in the conversation. Consecutive `user` or `assistant` turns
2682
+ * in your request will be combined into a single turn.
2683
+ *
2684
+ * Each input message must be an object with a `role` and `content`. You can
2685
+ * specify a single `user`-role message, or you can include multiple `user` and
2686
+ * `assistant` messages.
2687
+ *
2688
+ * If the final message uses the `assistant` role, the response content will
2689
+ * continue immediately from the content in that message. This can be used to
2690
+ * constrain part of the model's response.
2691
+ *
2692
+ * Example with a single `user` message:
2693
+ *
2694
+ * ```json
2695
+ * [{ "role": "user", "content": "Hello, Claude" }]
2696
+ * ```
2697
+ *
2698
+ * Example with multiple conversational turns:
2699
+ *
2700
+ * ```json
2701
+ * [
2702
+ * { "role": "user", "content": "Hello there." },
2703
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
2704
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
2705
+ * ]
2706
+ * ```
2707
+ *
2708
+ * Example with a partially-filled response from Claude:
2709
+ *
2710
+ * ```json
2711
+ * [
2712
+ * {
2713
+ * "role": "user",
2714
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
2715
+ * },
2716
+ * { "role": "assistant", "content": "The best answer is (" }
2717
+ * ]
2718
+ * ```
2719
+ *
2720
+ * Each input message `content` may be either a single `string` or an array of
2721
+ * content blocks, where each block has a specific `type`. Using a `string` for
2722
+ * `content` is shorthand for an array of one content block of type `"text"`. The
2723
+ * following input messages are equivalent:
2724
+ *
2725
+ * ```json
2726
+ * { "role": "user", "content": "Hello, Claude" }
2727
+ * ```
2728
+ *
2729
+ * ```json
2730
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
2731
+ * ```
2732
+ *
2733
+ * See [input examples](https://docs.claude.com/en/api/messages-examples).
2734
+ *
2735
+ * Note that if you want to include a
2736
+ * [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the
2737
+ * top-level `system` parameter — there is no `"system"` role for input messages in
2738
+ * the Messages API.
2739
+ *
2740
+ * There is a limit of 100,000 messages in a single request.
2741
+ */
2742
+ messages: Array<MessageParam>;
2743
+
2744
+ /**
2745
+ * The model that will complete your prompt.\n\nSee
2746
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
2747
+ * details and options.
2748
+ */
2749
+ model: Model;
2750
+
2751
+ /**
2752
+ * Top-level cache control automatically applies a cache_control marker to the last
2753
+ * cacheable block in the request.
2754
+ */
2755
+ cache_control?: CacheControlEphemeral | null;
2756
+
2757
+ /**
2758
+ * Container identifier for reuse across requests.
2759
+ */
2760
+ container?: string | null;
2761
+
2762
+ /**
2763
+ * Specifies the geographic region for inference processing. If not specified, the
2764
+ * workspace's `default_inference_geo` is used.
2765
+ */
2766
+ inference_geo?: string | null;
2767
+
2768
+ /**
2769
+ * An object describing metadata about the request.
2770
+ */
2771
+ metadata?: Metadata;
2772
+
2773
+ /**
2774
+ * Configuration options for the model's output, such as the output format.
2775
+ */
2776
+ output_config?: OutputConfig;
2777
+
2778
+ /**
2779
+ * Determines whether to use priority capacity (if available) or standard capacity
2780
+ * for this request.
2781
+ *
2782
+ * Anthropic offers different levels of service for your API requests. See
2783
+ * [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
2784
+ */
2785
+ service_tier?: 'auto' | 'standard_only';
2786
+
2787
+ /**
2788
+ * Custom text sequences that will cause the model to stop generating.
2789
+ *
2790
+ * Our models will normally stop when they have naturally completed their turn,
2791
+ * which will result in a response `stop_reason` of `"end_turn"`.
2792
+ *
2793
+ * If you want the model to stop generating when it encounters custom strings of
2794
+ * text, you can use the `stop_sequences` parameter. If the model encounters one of
2795
+ * the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
2796
+ * and the response `stop_sequence` value will contain the matched stop sequence.
2797
+ */
2798
+ stop_sequences?: Array<string>;
2799
+
2800
+ /**
2801
+ * Whether to incrementally stream the response using server-sent events.
2802
+ *
2803
+ * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
2804
+ */
2805
+ stream?: boolean;
2806
+
2807
+ /**
2808
+ * System prompt.
2809
+ *
2810
+ * A system prompt is a way of providing context and instructions to Claude, such
2811
+ * as specifying a particular goal or role. See our
2812
+ * [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).
2813
+ */
2814
+ system?: string | Array<TextBlockParam>;
2815
+
2816
+ /**
2817
+ * Amount of randomness injected into the response.
2818
+ *
2819
+ * Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
2820
+ * for analytical / multiple choice, and closer to `1.0` for creative and
2821
+ * generative tasks.
2822
+ *
2823
+ * Note that even with `temperature` of `0.0`, the results will not be fully
2824
+ * deterministic.
2825
+ */
2826
+ temperature?: number;
2827
+
2828
+ /**
2829
+ * Configuration for enabling Claude's extended thinking.
2830
+ *
2831
+ * When enabled, responses include `thinking` content blocks showing Claude's
2832
+ * thinking process before the final answer. Requires a minimum budget of 1,024
2833
+ * tokens and counts towards your `max_tokens` limit.
2834
+ *
2835
+ * See
2836
+ * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
2837
+ * for details.
2838
+ */
2839
+ thinking?: ThinkingConfigParam;
2840
+
2841
+ /**
2842
+ * How the model should use the provided tools. The model can use a specific tool,
2843
+ * any available tool, decide by itself, or not use tools at all.
2844
+ */
2845
+ tool_choice?: ToolChoice;
2846
+
2847
+ /**
2848
+ * Definitions of tools that the model may use.
2849
+ *
2850
+ * If you include `tools` in your API request, the model may return `tool_use`
2851
+ * content blocks that represent the model's use of those tools. You can then run
2852
+ * those tools using the tool input generated by the model and then optionally
2853
+ * return results back to the model using `tool_result` content blocks.
2854
+ *
2855
+ * There are two types of tools: **client tools** and **server tools**. The
2856
+ * behavior described below applies to client tools. For
2857
+ * [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
2858
+ * see their individual documentation as each has its own behavior (e.g., the
2859
+ * [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
2860
+ *
2861
+ * Each tool definition includes:
2862
+ *
2863
+ * - `name`: Name of the tool.
2864
+ * - `description`: Optional, but strongly-recommended description of the tool.
2865
+ * - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
2866
+ * tool `input` shape that the model will produce in `tool_use` output content
2867
+ * blocks.
2868
+ *
2869
+ * For example, if you defined `tools` as:
2870
+ *
2871
+ * ```json
2872
+ * [
2873
+ * {
2874
+ * "name": "get_stock_price",
2875
+ * "description": "Get the current stock price for a given ticker symbol.",
2876
+ * "input_schema": {
2877
+ * "type": "object",
2878
+ * "properties": {
2879
+ * "ticker": {
2880
+ * "type": "string",
2881
+ * "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
2882
+ * }
2883
+ * },
2884
+ * "required": ["ticker"]
2885
+ * }
2886
+ * }
2887
+ * ]
2888
+ * ```
2889
+ *
2890
+ * And then asked the model "What's the S&P 500 at today?", the model might produce
2891
+ * `tool_use` content blocks in the response like this:
2892
+ *
2893
+ * ```json
2894
+ * [
2895
+ * {
2896
+ * "type": "tool_use",
2897
+ * "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
2898
+ * "name": "get_stock_price",
2899
+ * "input": { "ticker": "^GSPC" }
2900
+ * }
2901
+ * ]
2902
+ * ```
2903
+ *
2904
+ * You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
2905
+ * input, and return the following back to the model in a subsequent `user`
2906
+ * message:
2907
+ *
2908
+ * ```json
2909
+ * [
2910
+ * {
2911
+ * "type": "tool_result",
2912
+ * "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
2913
+ * "content": "259.75 USD"
2914
+ * }
2915
+ * ]
2916
+ * ```
2917
+ *
2918
+ * Tools can be used for workflows that include running client-side tools and
2919
+ * functions, or more generally whenever you want the model to produce a particular
2920
+ * JSON structure of output.
2921
+ *
2922
+ * See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.
2923
+ */
2924
+ tools?: Array<ToolUnion>;
2925
+
2926
+ /**
2927
+ * Only sample from the top K options for each subsequent token.
2928
+ *
2929
+ * Used to remove "long tail" low probability responses.
2930
+ * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
2931
+ *
2932
+ * Recommended for advanced use cases only. You usually only need to use
2933
+ * `temperature`.
2934
+ */
2935
+ top_k?: number;
2936
+
2937
+ /**
2938
+ * Use nucleus sampling.
2939
+ *
2940
+ * In nucleus sampling, we compute the cumulative distribution over all the options
2941
+ * for each subsequent token in decreasing probability order and cut it off once it
2942
+ * reaches a particular probability specified by `top_p`. You should either alter
2943
+ * `temperature` or `top_p`, but not both.
2944
+ *
2945
+ * Recommended for advanced use cases only. You usually only need to use
2946
+ * `temperature`.
2947
+ */
2948
+ top_p?: number;
2949
+ }
2950
+
2951
+ export namespace MessageCreateParams {
2952
+ export type MessageCreateParamsNonStreaming = MessagesAPI.MessageCreateParamsNonStreaming;
2953
+ export type MessageCreateParamsStreaming = MessagesAPI.MessageCreateParamsStreaming;
2954
+ }
2955
+
2956
+ export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase {
2957
+ /**
2958
+ * Whether to incrementally stream the response using server-sent events.
2959
+ *
2960
+ * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
2961
+ */
2962
+ stream?: false;
2963
+ }
2964
+
2965
+ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
2966
+ /**
2967
+ * Whether to incrementally stream the response using server-sent events.
2968
+ *
2969
+ * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
2970
+ */
2971
+ stream: true;
2972
+ }
2973
+
2974
+ export type MessageStreamParams = ParseableMessageCreateParams;
2975
+
2976
+ export interface MessageCountTokensParams {
2977
+ /**
2978
+ * Input messages.
2979
+ *
2980
+ * Our models are trained to operate on alternating `user` and `assistant`
2981
+ * conversational turns. When creating a new `Message`, you specify the prior
2982
+ * conversational turns with the `messages` parameter, and the model then generates
2983
+ * the next `Message` in the conversation. Consecutive `user` or `assistant` turns
2984
+ * in your request will be combined into a single turn.
2985
+ *
2986
+ * Each input message must be an object with a `role` and `content`. You can
2987
+ * specify a single `user`-role message, or you can include multiple `user` and
2988
+ * `assistant` messages.
2989
+ *
2990
+ * If the final message uses the `assistant` role, the response content will
2991
+ * continue immediately from the content in that message. This can be used to
2992
+ * constrain part of the model's response.
2993
+ *
2994
+ * Example with a single `user` message:
2995
+ *
2996
+ * ```json
2997
+ * [{ "role": "user", "content": "Hello, Claude" }]
2998
+ * ```
2999
+ *
3000
+ * Example with multiple conversational turns:
3001
+ *
3002
+ * ```json
3003
+ * [
3004
+ * { "role": "user", "content": "Hello there." },
3005
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
3006
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
3007
+ * ]
3008
+ * ```
3009
+ *
3010
+ * Example with a partially-filled response from Claude:
3011
+ *
3012
+ * ```json
3013
+ * [
3014
+ * {
3015
+ * "role": "user",
3016
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
3017
+ * },
3018
+ * { "role": "assistant", "content": "The best answer is (" }
3019
+ * ]
3020
+ * ```
3021
+ *
3022
+ * Each input message `content` may be either a single `string` or an array of
3023
+ * content blocks, where each block has a specific `type`. Using a `string` for
3024
+ * `content` is shorthand for an array of one content block of type `"text"`. The
3025
+ * following input messages are equivalent:
3026
+ *
3027
+ * ```json
3028
+ * { "role": "user", "content": "Hello, Claude" }
3029
+ * ```
3030
+ *
3031
+ * ```json
3032
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
3033
+ * ```
3034
+ *
3035
+ * See [input examples](https://docs.claude.com/en/api/messages-examples).
3036
+ *
3037
+ * Note that if you want to include a
3038
+ * [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the
3039
+ * top-level `system` parameter — there is no `"system"` role for input messages in
3040
+ * the Messages API.
3041
+ *
3042
+ * There is a limit of 100,000 messages in a single request.
3043
+ */
3044
+ messages: Array<MessageParam>;
3045
+
3046
+ /**
3047
+ * The model that will complete your prompt.\n\nSee
3048
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
3049
+ * details and options.
3050
+ */
3051
+ model: Model;
3052
+
3053
+ /**
3054
+ * Top-level cache control automatically applies a cache_control marker to the last
3055
+ * cacheable block in the request.
3056
+ */
3057
+ cache_control?: CacheControlEphemeral | null;
3058
+
3059
+ /**
3060
+ * Configuration options for the model's output, such as the output format.
3061
+ */
3062
+ output_config?: OutputConfig;
3063
+
3064
+ /**
3065
+ * System prompt.
3066
+ *
3067
+ * A system prompt is a way of providing context and instructions to Claude, such
3068
+ * as specifying a particular goal or role. See our
3069
+ * [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).
3070
+ */
3071
+ system?: string | Array<TextBlockParam>;
3072
+
3073
+ /**
3074
+ * Configuration for enabling Claude's extended thinking.
3075
+ *
3076
+ * When enabled, responses include `thinking` content blocks showing Claude's
3077
+ * thinking process before the final answer. Requires a minimum budget of 1,024
3078
+ * tokens and counts towards your `max_tokens` limit.
3079
+ *
3080
+ * See
3081
+ * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
3082
+ * for details.
3083
+ */
3084
+ thinking?: ThinkingConfigParam;
3085
+
3086
+ /**
3087
+ * How the model should use the provided tools. The model can use a specific tool,
3088
+ * any available tool, decide by itself, or not use tools at all.
3089
+ */
3090
+ tool_choice?: ToolChoice;
3091
+
3092
+ /**
3093
+ * Definitions of tools that the model may use.
3094
+ *
3095
+ * If you include `tools` in your API request, the model may return `tool_use`
3096
+ * content blocks that represent the model's use of those tools. You can then run
3097
+ * those tools using the tool input generated by the model and then optionally
3098
+ * return results back to the model using `tool_result` content blocks.
3099
+ *
3100
+ * There are two types of tools: **client tools** and **server tools**. The
3101
+ * behavior described below applies to client tools. For
3102
+ * [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
3103
+ * see their individual documentation as each has its own behavior (e.g., the
3104
+ * [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
3105
+ *
3106
+ * Each tool definition includes:
3107
+ *
3108
+ * - `name`: Name of the tool.
3109
+ * - `description`: Optional, but strongly-recommended description of the tool.
3110
+ * - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
3111
+ * tool `input` shape that the model will produce in `tool_use` output content
3112
+ * blocks.
3113
+ *
3114
+ * For example, if you defined `tools` as:
3115
+ *
3116
+ * ```json
3117
+ * [
3118
+ * {
3119
+ * "name": "get_stock_price",
3120
+ * "description": "Get the current stock price for a given ticker symbol.",
3121
+ * "input_schema": {
3122
+ * "type": "object",
3123
+ * "properties": {
3124
+ * "ticker": {
3125
+ * "type": "string",
3126
+ * "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
3127
+ * }
3128
+ * },
3129
+ * "required": ["ticker"]
3130
+ * }
3131
+ * }
3132
+ * ]
3133
+ * ```
3134
+ *
3135
+ * And then asked the model "What's the S&P 500 at today?", the model might produce
3136
+ * `tool_use` content blocks in the response like this:
3137
+ *
3138
+ * ```json
3139
+ * [
3140
+ * {
3141
+ * "type": "tool_use",
3142
+ * "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
3143
+ * "name": "get_stock_price",
3144
+ * "input": { "ticker": "^GSPC" }
3145
+ * }
3146
+ * ]
3147
+ * ```
3148
+ *
3149
+ * You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
3150
+ * input, and return the following back to the model in a subsequent `user`
3151
+ * message:
3152
+ *
3153
+ * ```json
3154
+ * [
3155
+ * {
3156
+ * "type": "tool_result",
3157
+ * "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
3158
+ * "content": "259.75 USD"
3159
+ * }
3160
+ * ]
3161
+ * ```
3162
+ *
3163
+ * Tools can be used for workflows that include running client-side tools and
3164
+ * functions, or more generally whenever you want the model to produce a particular
3165
+ * JSON structure of output.
3166
+ *
3167
+ * See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.
3168
+ */
3169
+ tools?: Array<MessageCountTokensTool>;
3170
+ }
3171
+
3172
+ Messages.Batches = Batches;
3173
+
3174
+ export declare namespace Messages {
3175
+ export {
3176
+ type Base64ImageSource as Base64ImageSource,
3177
+ type Base64PDFSource as Base64PDFSource,
3178
+ type BashCodeExecutionOutputBlock as BashCodeExecutionOutputBlock,
3179
+ type BashCodeExecutionOutputBlockParam as BashCodeExecutionOutputBlockParam,
3180
+ type BashCodeExecutionResultBlock as BashCodeExecutionResultBlock,
3181
+ type BashCodeExecutionResultBlockParam as BashCodeExecutionResultBlockParam,
3182
+ type BashCodeExecutionToolResultBlock as BashCodeExecutionToolResultBlock,
3183
+ type BashCodeExecutionToolResultBlockParam as BashCodeExecutionToolResultBlockParam,
3184
+ type BashCodeExecutionToolResultError as BashCodeExecutionToolResultError,
3185
+ type BashCodeExecutionToolResultErrorCode as BashCodeExecutionToolResultErrorCode,
3186
+ type BashCodeExecutionToolResultErrorParam as BashCodeExecutionToolResultErrorParam,
3187
+ type CacheControlEphemeral as CacheControlEphemeral,
3188
+ type CacheCreation as CacheCreation,
3189
+ type CitationCharLocation as CitationCharLocation,
3190
+ type CitationCharLocationParam as CitationCharLocationParam,
3191
+ type CitationContentBlockLocation as CitationContentBlockLocation,
3192
+ type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
3193
+ type CitationPageLocation as CitationPageLocation,
3194
+ type CitationPageLocationParam as CitationPageLocationParam,
3195
+ type CitationSearchResultLocationParam as CitationSearchResultLocationParam,
3196
+ type CitationWebSearchResultLocationParam as CitationWebSearchResultLocationParam,
3197
+ type CitationsConfig as CitationsConfig,
3198
+ type CitationsConfigParam as CitationsConfigParam,
3199
+ type CitationsDelta as CitationsDelta,
3200
+ type CitationsSearchResultLocation as CitationsSearchResultLocation,
3201
+ type CitationsWebSearchResultLocation as CitationsWebSearchResultLocation,
3202
+ type CodeExecutionOutputBlock as CodeExecutionOutputBlock,
3203
+ type CodeExecutionOutputBlockParam as CodeExecutionOutputBlockParam,
3204
+ type CodeExecutionResultBlock as CodeExecutionResultBlock,
3205
+ type CodeExecutionResultBlockParam as CodeExecutionResultBlockParam,
3206
+ type CodeExecutionTool20250522 as CodeExecutionTool20250522,
3207
+ type CodeExecutionTool20250825 as CodeExecutionTool20250825,
3208
+ type CodeExecutionTool20260120 as CodeExecutionTool20260120,
3209
+ type CodeExecutionToolResultBlock as CodeExecutionToolResultBlock,
3210
+ type CodeExecutionToolResultBlockContent as CodeExecutionToolResultBlockContent,
3211
+ type CodeExecutionToolResultBlockParam as CodeExecutionToolResultBlockParam,
3212
+ type CodeExecutionToolResultBlockParamContent as CodeExecutionToolResultBlockParamContent,
3213
+ type CodeExecutionToolResultError as CodeExecutionToolResultError,
3214
+ type CodeExecutionToolResultErrorCode as CodeExecutionToolResultErrorCode,
3215
+ type CodeExecutionToolResultErrorParam as CodeExecutionToolResultErrorParam,
3216
+ type Container as Container,
3217
+ type ContainerUploadBlock as ContainerUploadBlock,
3218
+ type ContainerUploadBlockParam as ContainerUploadBlockParam,
3219
+ type ContentBlock as ContentBlock,
3220
+ type ContentBlockParam as ContentBlockParam,
3221
+ type ContentBlockStartEvent as ContentBlockStartEvent,
3222
+ type ContentBlockStopEvent as ContentBlockStopEvent,
3223
+ type ContentBlockSource as ContentBlockSource,
3224
+ type ContentBlockSourceContent as ContentBlockSourceContent,
3225
+ type DirectCaller as DirectCaller,
3226
+ type DocumentBlock as DocumentBlock,
3227
+ type DocumentBlockParam as DocumentBlockParam,
3228
+ type EncryptedCodeExecutionResultBlock as EncryptedCodeExecutionResultBlock,
3229
+ type EncryptedCodeExecutionResultBlockParam as EncryptedCodeExecutionResultBlockParam,
3230
+ type ImageBlockParam as ImageBlockParam,
3231
+ type InputJSONDelta as InputJSONDelta,
3232
+ type JSONOutputFormat as JSONOutputFormat,
3233
+ type MemoryTool20250818 as MemoryTool20250818,
3234
+ type Message as Message,
3235
+ type MessageCountTokensTool as MessageCountTokensTool,
3236
+ type MessageDeltaEvent as MessageDeltaEvent,
3237
+ type MessageDeltaUsage as MessageDeltaUsage,
3238
+ type MessageParam as MessageParam,
3239
+ type MessageTokensCount as MessageTokensCount,
3240
+ type Metadata as Metadata,
3241
+ type Model as Model,
3242
+ type OutputConfig as OutputConfig,
3243
+ type PlainTextSource as PlainTextSource,
3244
+ type RawContentBlockDelta as RawContentBlockDelta,
3245
+ type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
3246
+ type RawContentBlockStartEvent as RawContentBlockStartEvent,
3247
+ type RawContentBlockStopEvent as RawContentBlockStopEvent,
3248
+ type RawMessageDeltaEvent as RawMessageDeltaEvent,
3249
+ type RawMessageStartEvent as RawMessageStartEvent,
3250
+ type RawMessageStopEvent as RawMessageStopEvent,
3251
+ type RawMessageStreamEvent as RawMessageStreamEvent,
3252
+ type RedactedThinkingBlock as RedactedThinkingBlock,
3253
+ type RedactedThinkingBlockParam as RedactedThinkingBlockParam,
3254
+ type RefusalStopDetails as RefusalStopDetails,
3255
+ type SearchResultBlockParam as SearchResultBlockParam,
3256
+ type ServerToolCaller as ServerToolCaller,
3257
+ type ServerToolCaller20260120 as ServerToolCaller20260120,
3258
+ type ServerToolUsage as ServerToolUsage,
3259
+ type ServerToolUseBlock as ServerToolUseBlock,
3260
+ type ServerToolUseBlockParam as ServerToolUseBlockParam,
3261
+ type SignatureDelta as SignatureDelta,
3262
+ type StopReason as StopReason,
3263
+ type TextBlock as TextBlock,
3264
+ type TextBlockParam as TextBlockParam,
3265
+ type TextCitation as TextCitation,
3266
+ type TextCitationParam as TextCitationParam,
3267
+ type TextDelta as TextDelta,
3268
+ type TextEditorCodeExecutionCreateResultBlock as TextEditorCodeExecutionCreateResultBlock,
3269
+ type TextEditorCodeExecutionCreateResultBlockParam as TextEditorCodeExecutionCreateResultBlockParam,
3270
+ type TextEditorCodeExecutionStrReplaceResultBlock as TextEditorCodeExecutionStrReplaceResultBlock,
3271
+ type TextEditorCodeExecutionStrReplaceResultBlockParam as TextEditorCodeExecutionStrReplaceResultBlockParam,
3272
+ type TextEditorCodeExecutionToolResultBlock as TextEditorCodeExecutionToolResultBlock,
3273
+ type TextEditorCodeExecutionToolResultBlockParam as TextEditorCodeExecutionToolResultBlockParam,
3274
+ type TextEditorCodeExecutionToolResultError as TextEditorCodeExecutionToolResultError,
3275
+ type TextEditorCodeExecutionToolResultErrorCode as TextEditorCodeExecutionToolResultErrorCode,
3276
+ type TextEditorCodeExecutionToolResultErrorParam as TextEditorCodeExecutionToolResultErrorParam,
3277
+ type TextEditorCodeExecutionViewResultBlock as TextEditorCodeExecutionViewResultBlock,
3278
+ type TextEditorCodeExecutionViewResultBlockParam as TextEditorCodeExecutionViewResultBlockParam,
3279
+ type ThinkingBlock as ThinkingBlock,
3280
+ type ThinkingBlockParam as ThinkingBlockParam,
3281
+ type ThinkingConfigAdaptive as ThinkingConfigAdaptive,
3282
+ type ThinkingConfigDisabled as ThinkingConfigDisabled,
3283
+ type ThinkingConfigEnabled as ThinkingConfigEnabled,
3284
+ type ThinkingConfigParam as ThinkingConfigParam,
3285
+ type ThinkingDelta as ThinkingDelta,
3286
+ type Tool as Tool,
3287
+ type ToolBash20250124 as ToolBash20250124,
3288
+ type ToolChoice as ToolChoice,
3289
+ type ToolChoiceAny as ToolChoiceAny,
3290
+ type ToolChoiceAuto as ToolChoiceAuto,
3291
+ type ToolChoiceNone as ToolChoiceNone,
3292
+ type ToolChoiceTool as ToolChoiceTool,
3293
+ type ToolReferenceBlock as ToolReferenceBlock,
3294
+ type ToolReferenceBlockParam as ToolReferenceBlockParam,
3295
+ type ToolResultBlockParam as ToolResultBlockParam,
3296
+ type ToolSearchToolBm25_20251119 as ToolSearchToolBm25_20251119,
3297
+ type ToolSearchToolRegex20251119 as ToolSearchToolRegex20251119,
3298
+ type ToolSearchToolResultBlock as ToolSearchToolResultBlock,
3299
+ type ToolSearchToolResultBlockParam as ToolSearchToolResultBlockParam,
3300
+ type ToolSearchToolResultError as ToolSearchToolResultError,
3301
+ type ToolSearchToolResultErrorCode as ToolSearchToolResultErrorCode,
3302
+ type ToolSearchToolResultErrorParam as ToolSearchToolResultErrorParam,
3303
+ type ToolSearchToolSearchResultBlock as ToolSearchToolSearchResultBlock,
3304
+ type ToolSearchToolSearchResultBlockParam as ToolSearchToolSearchResultBlockParam,
3305
+ type ToolTextEditor20250124 as ToolTextEditor20250124,
3306
+ type ToolTextEditor20250429 as ToolTextEditor20250429,
3307
+ type ToolTextEditor20250728 as ToolTextEditor20250728,
3308
+ type ToolUnion as ToolUnion,
3309
+ type ToolUseBlock as ToolUseBlock,
3310
+ type ToolUseBlockParam as ToolUseBlockParam,
3311
+ type URLImageSource as URLImageSource,
3312
+ type URLPDFSource as URLPDFSource,
3313
+ type Usage as Usage,
3314
+ type UserLocation as UserLocation,
3315
+ type WebFetchBlock as WebFetchBlock,
3316
+ type WebFetchBlockParam as WebFetchBlockParam,
3317
+ type WebFetchTool20250910 as WebFetchTool20250910,
3318
+ type WebFetchTool20260209 as WebFetchTool20260209,
3319
+ type WebFetchTool20260309 as WebFetchTool20260309,
3320
+ type WebFetchToolResultBlock as WebFetchToolResultBlock,
3321
+ type WebFetchToolResultBlockParam as WebFetchToolResultBlockParam,
3322
+ type WebFetchToolResultErrorBlock as WebFetchToolResultErrorBlock,
3323
+ type WebFetchToolResultErrorBlockParam as WebFetchToolResultErrorBlockParam,
3324
+ type WebFetchToolResultErrorCode as WebFetchToolResultErrorCode,
3325
+ type WebSearchResultBlock as WebSearchResultBlock,
3326
+ type WebSearchResultBlockParam as WebSearchResultBlockParam,
3327
+ type WebSearchTool20250305 as WebSearchTool20250305,
3328
+ type WebSearchTool20260209 as WebSearchTool20260209,
3329
+ type WebSearchToolRequestError as WebSearchToolRequestError,
3330
+ type WebSearchToolResultBlock as WebSearchToolResultBlock,
3331
+ type WebSearchToolResultBlockContent as WebSearchToolResultBlockContent,
3332
+ type WebSearchToolResultBlockParam as WebSearchToolResultBlockParam,
3333
+ type WebSearchToolResultBlockParamContent as WebSearchToolResultBlockParamContent,
3334
+ type WebSearchToolResultError as WebSearchToolResultError,
3335
+ type MessageStreamEvent as MessageStreamEvent,
3336
+ type MessageStartEvent as MessageStartEvent,
3337
+ type MessageStopEvent as MessageStopEvent,
3338
+ type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
3339
+ type MessageCreateParams as MessageCreateParams,
3340
+ type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
3341
+ type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
3342
+ type MessageStreamParams as MessageStreamParams,
3343
+ type MessageCountTokensParams as MessageCountTokensParams,
3344
+ };
3345
+
3346
+ export {
3347
+ Batches as Batches,
3348
+ type DeletedMessageBatch as DeletedMessageBatch,
3349
+ type MessageBatch as MessageBatch,
3350
+ type MessageBatchCanceledResult as MessageBatchCanceledResult,
3351
+ type MessageBatchErroredResult as MessageBatchErroredResult,
3352
+ type MessageBatchExpiredResult as MessageBatchExpiredResult,
3353
+ type MessageBatchIndividualResponse as MessageBatchIndividualResponse,
3354
+ type MessageBatchRequestCounts as MessageBatchRequestCounts,
3355
+ type MessageBatchResult as MessageBatchResult,
3356
+ type MessageBatchSucceededResult as MessageBatchSucceededResult,
3357
+ type MessageBatchesPage as MessageBatchesPage,
3358
+ type BatchCreateParams as BatchCreateParams,
3359
+ type BatchListParams as BatchListParams,
3360
+ };
3361
+ }