@anthropic-ai/sdk 0.41.0 → 0.50.2

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 (614) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +118 -53
  3. package/_vendor/partial-json-parser/parser.d.mts +3 -0
  4. package/_vendor/partial-json-parser/parser.d.mts.map +1 -0
  5. package/_vendor/partial-json-parser/parser.d.ts.map +1 -1
  6. package/_vendor/partial-json-parser/parser.js.map +1 -1
  7. package/_vendor/partial-json-parser/parser.mjs.map +1 -1
  8. package/api-promise.d.mts +2 -0
  9. package/api-promise.d.mts.map +1 -0
  10. package/api-promise.d.ts +2 -0
  11. package/api-promise.d.ts.map +1 -0
  12. package/api-promise.js +6 -0
  13. package/api-promise.js.map +1 -0
  14. package/api-promise.mjs +2 -0
  15. package/api-promise.mjs.map +1 -0
  16. package/bin/cli +53 -0
  17. package/bin/migration-config.json +7 -0
  18. package/client.d.mts +224 -0
  19. package/client.d.mts.map +1 -0
  20. package/client.d.ts +224 -0
  21. package/client.d.ts.map +1 -0
  22. package/client.js +527 -0
  23. package/client.js.map +1 -0
  24. package/client.mjs +522 -0
  25. package/client.mjs.map +1 -0
  26. package/core/api-promise.d.mts +49 -0
  27. package/core/api-promise.d.mts.map +1 -0
  28. package/core/api-promise.d.ts +49 -0
  29. package/core/api-promise.d.ts.map +1 -0
  30. package/core/api-promise.js +76 -0
  31. package/core/api-promise.js.map +1 -0
  32. package/core/api-promise.mjs +72 -0
  33. package/core/api-promise.mjs.map +1 -0
  34. package/core/error.d.mts +47 -0
  35. package/core/error.d.mts.map +1 -0
  36. package/core/error.d.ts +47 -0
  37. package/core/error.d.ts.map +1 -0
  38. package/core/error.js +114 -0
  39. package/core/error.js.map +1 -0
  40. package/core/error.mjs +98 -0
  41. package/core/error.mjs.map +1 -0
  42. package/core/pagination.d.mts +63 -0
  43. package/core/pagination.d.mts.map +1 -0
  44. package/core/pagination.d.ts +63 -0
  45. package/core/pagination.d.ts.map +1 -0
  46. package/core/pagination.js +123 -0
  47. package/core/pagination.js.map +1 -0
  48. package/core/pagination.mjs +117 -0
  49. package/core/pagination.mjs.map +1 -0
  50. package/core/resource.d.mts +6 -0
  51. package/core/resource.d.mts.map +1 -0
  52. package/core/resource.d.ts +6 -0
  53. package/core/resource.d.ts.map +1 -0
  54. package/core/resource.js +11 -0
  55. package/core/resource.js.map +1 -0
  56. package/core/resource.mjs +7 -0
  57. package/core/resource.mjs.map +1 -0
  58. package/core/streaming.d.mts +31 -0
  59. package/core/streaming.d.mts.map +1 -0
  60. package/core/streaming.d.ts +31 -0
  61. package/core/streaming.d.ts.map +1 -0
  62. package/core/streaming.js +282 -0
  63. package/core/streaming.js.map +1 -0
  64. package/core/streaming.mjs +277 -0
  65. package/core/streaming.mjs.map +1 -0
  66. package/core/uploads.d.mts +3 -0
  67. package/core/uploads.d.mts.map +1 -0
  68. package/core/uploads.d.ts +3 -0
  69. package/core/uploads.d.ts.map +1 -0
  70. package/core/uploads.js +6 -0
  71. package/core/uploads.js.map +1 -0
  72. package/core/uploads.mjs +2 -0
  73. package/core/uploads.mjs.map +1 -0
  74. package/error.d.mts +2 -0
  75. package/error.d.mts.map +1 -0
  76. package/error.d.ts +1 -47
  77. package/error.d.ts.map +1 -1
  78. package/error.js +3 -111
  79. package/error.js.map +1 -1
  80. package/error.mjs +1 -97
  81. package/error.mjs.map +1 -1
  82. package/index.d.mts +7 -152
  83. package/index.d.mts.map +1 -0
  84. package/index.d.ts +6 -151
  85. package/index.d.ts.map +1 -1
  86. package/index.js +17 -156
  87. package/index.js.map +1 -1
  88. package/index.mjs +6 -129
  89. package/index.mjs.map +1 -1
  90. package/internal/builtin-types.d.mts +73 -0
  91. package/internal/builtin-types.d.mts.map +1 -0
  92. package/internal/builtin-types.d.ts +73 -0
  93. package/internal/builtin-types.d.ts.map +1 -0
  94. package/internal/builtin-types.js +4 -0
  95. package/internal/builtin-types.js.map +1 -0
  96. package/internal/builtin-types.mjs +3 -0
  97. package/internal/builtin-types.mjs.map +1 -0
  98. package/internal/decoders/jsonl.d.mts +10 -0
  99. package/internal/decoders/jsonl.d.mts.map +1 -0
  100. package/internal/decoders/jsonl.d.ts +0 -2
  101. package/internal/decoders/jsonl.d.ts.map +1 -1
  102. package/internal/decoders/jsonl.js +7 -3
  103. package/internal/decoders/jsonl.js.map +1 -1
  104. package/internal/decoders/jsonl.mjs +6 -2
  105. package/internal/decoders/jsonl.mjs.map +1 -1
  106. package/internal/decoders/line.d.mts +17 -0
  107. package/internal/decoders/line.d.mts.map +1 -0
  108. package/internal/decoders/line.d.ts +1 -5
  109. package/internal/decoders/line.d.ts.map +1 -1
  110. package/internal/decoders/line.js +24 -61
  111. package/internal/decoders/line.js.map +1 -1
  112. package/internal/decoders/line.mjs +14 -51
  113. package/internal/decoders/line.mjs.map +1 -1
  114. package/internal/detect-platform.d.mts +15 -0
  115. package/internal/detect-platform.d.mts.map +1 -0
  116. package/internal/detect-platform.d.ts +15 -0
  117. package/internal/detect-platform.d.ts.map +1 -0
  118. package/internal/detect-platform.js +162 -0
  119. package/internal/detect-platform.js.map +1 -0
  120. package/internal/detect-platform.mjs +157 -0
  121. package/internal/detect-platform.mjs.map +1 -0
  122. package/internal/errors.d.mts +3 -0
  123. package/internal/errors.d.mts.map +1 -0
  124. package/internal/errors.d.ts +3 -0
  125. package/internal/errors.d.ts.map +1 -0
  126. package/internal/errors.js +41 -0
  127. package/internal/errors.js.map +1 -0
  128. package/internal/errors.mjs +36 -0
  129. package/internal/errors.mjs.map +1 -0
  130. package/internal/headers.d.mts +22 -0
  131. package/internal/headers.d.mts.map +1 -0
  132. package/internal/headers.d.ts +22 -0
  133. package/internal/headers.d.ts.map +1 -0
  134. package/internal/headers.js +79 -0
  135. package/internal/headers.js.map +1 -0
  136. package/internal/headers.mjs +74 -0
  137. package/internal/headers.mjs.map +1 -0
  138. package/internal/parse.d.mts +17 -0
  139. package/internal/parse.d.mts.map +1 -0
  140. package/internal/parse.d.ts +17 -0
  141. package/internal/parse.d.ts.map +1 -0
  142. package/internal/parse.js +55 -0
  143. package/internal/parse.js.map +1 -0
  144. package/internal/parse.mjs +51 -0
  145. package/internal/parse.mjs.map +1 -0
  146. package/internal/request-options.d.mts +34 -0
  147. package/internal/request-options.d.mts.map +1 -0
  148. package/internal/request-options.d.ts +34 -0
  149. package/internal/request-options.d.ts.map +1 -0
  150. package/internal/request-options.js +14 -0
  151. package/internal/request-options.js.map +1 -0
  152. package/internal/request-options.mjs +10 -0
  153. package/internal/request-options.mjs.map +1 -0
  154. package/internal/shim-types.d.mts +28 -0
  155. package/internal/shim-types.d.ts +28 -0
  156. package/internal/shims.d.mts +20 -0
  157. package/internal/shims.d.mts.map +1 -0
  158. package/internal/shims.d.ts +20 -0
  159. package/internal/shims.d.ts.map +1 -0
  160. package/internal/shims.js +92 -0
  161. package/internal/shims.js.map +1 -0
  162. package/internal/shims.mjs +85 -0
  163. package/internal/shims.mjs.map +1 -0
  164. package/internal/stream-utils.d.mts +8 -0
  165. package/internal/stream-utils.d.mts.map +1 -0
  166. package/internal/stream-utils.js +1 -2
  167. package/internal/stream-utils.js.map +1 -1
  168. package/internal/stream-utils.mjs.map +1 -1
  169. package/internal/to-file.d.mts +45 -0
  170. package/internal/to-file.d.mts.map +1 -0
  171. package/internal/to-file.d.ts +45 -0
  172. package/internal/to-file.d.ts.map +1 -0
  173. package/internal/to-file.js +91 -0
  174. package/internal/to-file.js.map +1 -0
  175. package/internal/to-file.mjs +88 -0
  176. package/internal/to-file.mjs.map +1 -0
  177. package/internal/tslib.js +81 -0
  178. package/internal/tslib.mjs +17 -0
  179. package/internal/types.d.mts +67 -0
  180. package/internal/types.d.mts.map +1 -0
  181. package/internal/types.d.ts +67 -0
  182. package/internal/types.d.ts.map +1 -0
  183. package/internal/types.js +4 -0
  184. package/internal/types.js.map +1 -0
  185. package/internal/types.mjs +3 -0
  186. package/internal/types.mjs.map +1 -0
  187. package/internal/uploads.d.mts +42 -0
  188. package/internal/uploads.d.mts.map +1 -0
  189. package/internal/uploads.d.ts +42 -0
  190. package/internal/uploads.d.ts.map +1 -0
  191. package/internal/uploads.js +141 -0
  192. package/internal/uploads.js.map +1 -0
  193. package/internal/uploads.mjs +131 -0
  194. package/internal/uploads.mjs.map +1 -0
  195. package/internal/utils/base64.d.mts +3 -0
  196. package/internal/utils/base64.d.mts.map +1 -0
  197. package/internal/utils/base64.d.ts +3 -0
  198. package/internal/utils/base64.d.ts.map +1 -0
  199. package/internal/utils/base64.js +38 -0
  200. package/internal/utils/base64.js.map +1 -0
  201. package/internal/utils/base64.mjs +33 -0
  202. package/internal/utils/base64.mjs.map +1 -0
  203. package/internal/utils/bytes.d.mts +4 -0
  204. package/internal/utils/bytes.d.mts.map +1 -0
  205. package/internal/utils/bytes.d.ts +4 -0
  206. package/internal/utils/bytes.d.ts.map +1 -0
  207. package/internal/utils/bytes.js +31 -0
  208. package/internal/utils/bytes.js.map +1 -0
  209. package/internal/utils/bytes.mjs +26 -0
  210. package/internal/utils/bytes.mjs.map +1 -0
  211. package/internal/utils/env.d.mts +9 -0
  212. package/internal/utils/env.d.mts.map +1 -0
  213. package/internal/utils/env.d.ts +9 -0
  214. package/internal/utils/env.d.ts.map +1 -0
  215. package/internal/utils/env.js +22 -0
  216. package/internal/utils/env.js.map +1 -0
  217. package/internal/utils/env.mjs +18 -0
  218. package/internal/utils/env.mjs.map +1 -0
  219. package/internal/utils/log.d.mts +37 -0
  220. package/internal/utils/log.d.mts.map +1 -0
  221. package/internal/utils/log.d.ts +37 -0
  222. package/internal/utils/log.d.ts.map +1 -0
  223. package/internal/utils/log.js +86 -0
  224. package/internal/utils/log.js.map +1 -0
  225. package/internal/utils/log.mjs +80 -0
  226. package/internal/utils/log.mjs.map +1 -0
  227. package/internal/utils/path.d.mts +15 -0
  228. package/internal/utils/path.d.mts.map +1 -0
  229. package/internal/utils/path.d.ts +15 -0
  230. package/internal/utils/path.d.ts.map +1 -0
  231. package/internal/utils/path.js +58 -0
  232. package/internal/utils/path.js.map +1 -0
  233. package/internal/utils/path.mjs +53 -0
  234. package/internal/utils/path.mjs.map +1 -0
  235. package/internal/utils/sleep.d.mts +2 -0
  236. package/internal/utils/sleep.d.mts.map +1 -0
  237. package/internal/utils/sleep.d.ts +2 -0
  238. package/internal/utils/sleep.d.ts.map +1 -0
  239. package/internal/utils/sleep.js +7 -0
  240. package/internal/utils/sleep.js.map +1 -0
  241. package/internal/utils/sleep.mjs +3 -0
  242. package/internal/utils/sleep.mjs.map +1 -0
  243. package/internal/utils/uuid.d.mts +5 -0
  244. package/internal/utils/uuid.d.mts.map +1 -0
  245. package/internal/utils/uuid.d.ts +5 -0
  246. package/internal/utils/uuid.d.ts.map +1 -0
  247. package/internal/utils/uuid.js +19 -0
  248. package/internal/utils/uuid.js.map +1 -0
  249. package/internal/utils/uuid.mjs +15 -0
  250. package/internal/utils/uuid.mjs.map +1 -0
  251. package/internal/utils/values.d.mts +16 -0
  252. package/internal/utils/values.d.mts.map +1 -0
  253. package/internal/utils/values.d.ts +16 -0
  254. package/internal/utils/values.d.ts.map +1 -0
  255. package/internal/utils/values.js +109 -0
  256. package/internal/utils/values.js.map +1 -0
  257. package/internal/utils/values.mjs +92 -0
  258. package/internal/utils/values.mjs.map +1 -0
  259. package/internal/utils.d.mts +7 -0
  260. package/internal/utils.d.mts.map +1 -0
  261. package/internal/utils.d.ts +7 -0
  262. package/internal/utils.d.ts.map +1 -0
  263. package/internal/utils.js +11 -0
  264. package/internal/utils.js.map +1 -0
  265. package/internal/utils.mjs +8 -0
  266. package/internal/utils.mjs.map +1 -0
  267. package/lib/BetaMessageStream.d.mts +114 -0
  268. package/lib/BetaMessageStream.d.mts.map +1 -0
  269. package/lib/BetaMessageStream.d.ts +7 -8
  270. package/lib/BetaMessageStream.d.ts.map +1 -1
  271. package/lib/BetaMessageStream.js +58 -67
  272. package/lib/BetaMessageStream.js.map +1 -1
  273. package/lib/BetaMessageStream.mjs +5 -14
  274. package/lib/BetaMessageStream.mjs.map +1 -1
  275. package/lib/MessageStream.d.mts +114 -0
  276. package/lib/MessageStream.d.mts.map +1 -0
  277. package/lib/MessageStream.d.ts +7 -8
  278. package/lib/MessageStream.d.ts.map +1 -1
  279. package/lib/MessageStream.js +58 -67
  280. package/lib/MessageStream.js.map +1 -1
  281. package/lib/MessageStream.mjs +5 -14
  282. package/lib/MessageStream.mjs.map +1 -1
  283. package/package.json +149 -64
  284. package/pagination.d.mts +2 -0
  285. package/pagination.d.mts.map +1 -0
  286. package/pagination.d.ts +1 -26
  287. package/pagination.d.ts.map +1 -1
  288. package/pagination.js +3 -57
  289. package/pagination.js.map +1 -1
  290. package/pagination.mjs +1 -55
  291. package/pagination.mjs.map +1 -1
  292. package/resource.d.mts +2 -0
  293. package/resource.d.mts.map +1 -0
  294. package/resource.d.ts +1 -5
  295. package/resource.d.ts.map +1 -1
  296. package/resource.js +3 -8
  297. package/resource.js.map +1 -1
  298. package/resource.mjs +1 -6
  299. package/resource.mjs.map +1 -1
  300. package/resources/beta/beta.d.mts +57 -0
  301. package/resources/beta/beta.d.mts.map +1 -0
  302. package/resources/beta/beta.d.ts +2 -2
  303. package/resources/beta/beta.d.ts.map +1 -1
  304. package/resources/beta/beta.js +4 -27
  305. package/resources/beta/beta.js.map +1 -1
  306. package/resources/beta/beta.mjs +2 -3
  307. package/resources/beta/beta.mjs.map +1 -1
  308. package/resources/beta/index.d.mts +4 -0
  309. package/resources/beta/index.d.mts.map +1 -0
  310. package/resources/beta/index.d.ts +1 -1
  311. package/resources/beta/index.d.ts.map +1 -1
  312. package/resources/beta/index.js +3 -4
  313. package/resources/beta/index.js.map +1 -1
  314. package/resources/beta/index.mjs +1 -1
  315. package/resources/beta/index.mjs.map +1 -1
  316. package/resources/beta/messages/batches.d.mts +343 -0
  317. package/resources/beta/messages/batches.d.mts.map +1 -0
  318. package/resources/beta/messages/batches.d.ts +12 -17
  319. package/resources/beta/messages/batches.d.ts.map +1 -1
  320. package/resources/beta/messages/batches.js +134 -62
  321. package/resources/beta/messages/batches.js.map +1 -1
  322. package/resources/beta/messages/batches.mjs +133 -60
  323. package/resources/beta/messages/batches.mjs.map +1 -1
  324. package/resources/beta/messages/index.d.mts +3 -0
  325. package/resources/beta/messages/index.d.mts.map +1 -0
  326. package/resources/beta/messages/index.d.ts +1 -1
  327. package/resources/beta/messages/index.d.ts.map +1 -1
  328. package/resources/beta/messages/index.js +1 -2
  329. package/resources/beta/messages/index.js.map +1 -1
  330. package/resources/beta/messages/index.mjs +1 -1
  331. package/resources/beta/messages/index.mjs.map +1 -1
  332. package/resources/beta/messages/messages.d.mts +1324 -0
  333. package/resources/beta/messages/messages.d.mts.map +1 -0
  334. package/resources/beta/messages/messages.d.ts +10 -10
  335. package/resources/beta/messages/messages.d.ts.map +1 -1
  336. package/resources/beta/messages/messages.js +12 -34
  337. package/resources/beta/messages/messages.js.map +1 -1
  338. package/resources/beta/messages/messages.mjs +11 -11
  339. package/resources/beta/messages/messages.mjs.map +1 -1
  340. package/resources/beta/messages.d.mts +2 -0
  341. package/resources/beta/messages.d.mts.map +1 -0
  342. package/resources/beta/messages.d.ts.map +1 -1
  343. package/resources/beta/messages.js +2 -15
  344. package/resources/beta/messages.js.map +1 -1
  345. package/resources/beta/models.d.mts +74 -0
  346. package/resources/beta/models.d.mts.map +1 -0
  347. package/resources/beta/models.d.ts +8 -10
  348. package/resources/beta/models.d.ts.map +1 -1
  349. package/resources/beta/models.js +45 -27
  350. package/resources/beta/models.js.map +1 -1
  351. package/resources/beta/models.mjs +44 -25
  352. package/resources/beta/models.mjs.map +1 -1
  353. package/resources/beta.d.mts +2 -0
  354. package/resources/beta.d.mts.map +1 -0
  355. package/resources/beta.d.ts.map +1 -1
  356. package/resources/beta.js +2 -15
  357. package/resources/beta.js.map +1 -1
  358. package/resources/completions.d.mts +183 -0
  359. package/resources/completions.d.mts.map +1 -0
  360. package/resources/completions.d.ts +7 -7
  361. package/resources/completions.d.ts.map +1 -1
  362. package/resources/completions.js +6 -5
  363. package/resources/completions.js.map +1 -1
  364. package/resources/completions.mjs +6 -5
  365. package/resources/completions.mjs.map +1 -1
  366. package/resources/index.d.mts +6 -0
  367. package/resources/index.d.mts.map +1 -0
  368. package/resources/index.d.ts +2 -2
  369. package/resources/index.d.ts.map +1 -1
  370. package/resources/index.js +3 -17
  371. package/resources/index.js.map +1 -1
  372. package/resources/index.mjs +1 -1
  373. package/resources/index.mjs.map +1 -1
  374. package/resources/messages/batches.d.mts +304 -0
  375. package/resources/messages/batches.d.mts.map +1 -0
  376. package/resources/messages/batches.d.ts +12 -13
  377. package/resources/messages/batches.d.ts.map +1 -1
  378. package/resources/messages/batches.js +31 -24
  379. package/resources/messages/batches.js.map +1 -1
  380. package/resources/messages/batches.mjs +30 -22
  381. package/resources/messages/batches.mjs.map +1 -1
  382. package/resources/messages/index.d.mts +3 -0
  383. package/resources/messages/index.d.mts.map +1 -0
  384. package/resources/messages/index.d.ts +2 -2
  385. package/resources/messages/index.d.ts.map +1 -1
  386. package/resources/messages/index.js +1 -2
  387. package/resources/messages/index.js.map +1 -1
  388. package/resources/messages/index.mjs +1 -1
  389. package/resources/messages/index.mjs.map +1 -1
  390. package/resources/messages/messages.d.mts +1250 -0
  391. package/resources/messages/messages.d.mts.map +1 -0
  392. package/resources/messages/messages.d.ts +11 -28
  393. package/resources/messages/messages.d.ts.map +1 -1
  394. package/resources/messages/messages.js +3 -26
  395. package/resources/messages/messages.js.map +1 -1
  396. package/resources/messages/messages.mjs +2 -3
  397. package/resources/messages/messages.mjs.map +1 -1
  398. package/resources/messages.d.mts +2 -0
  399. package/resources/messages.d.mts.map +1 -0
  400. package/resources/messages.d.ts.map +1 -1
  401. package/resources/messages.js +2 -15
  402. package/resources/messages.js.map +1 -1
  403. package/resources/models.d.mts +59 -0
  404. package/resources/models.d.mts.map +1 -0
  405. package/resources/models.d.ts +8 -10
  406. package/resources/models.d.ts.map +1 -1
  407. package/resources/models.js +30 -27
  408. package/resources/models.js.map +1 -1
  409. package/resources/models.mjs +29 -25
  410. package/resources/models.mjs.map +1 -1
  411. package/resources/shared.d.mts +42 -0
  412. package/resources/shared.d.mts.map +1 -0
  413. package/resources/top-level.d.mts +2 -0
  414. package/resources/top-level.d.mts.map +1 -0
  415. package/resources.d.mts +2 -0
  416. package/resources.d.mts.map +1 -0
  417. package/resources.d.ts.map +1 -1
  418. package/resources.js +2 -15
  419. package/resources.js.map +1 -1
  420. package/src/api-promise.ts +2 -0
  421. package/src/client.ts +1056 -0
  422. package/src/core/README.md +3 -0
  423. package/src/core/api-promise.ts +101 -0
  424. package/src/core/error.ts +133 -0
  425. package/src/core/pagination.ts +201 -0
  426. package/src/core/resource.ts +11 -0
  427. package/src/core/streaming.ts +331 -0
  428. package/src/core/uploads.ts +2 -0
  429. package/src/error.ts +2 -133
  430. package/src/index.ts +6 -492
  431. package/src/internal/README.md +3 -0
  432. package/src/internal/builtin-types.ts +93 -0
  433. package/src/internal/decoders/jsonl.ts +11 -4
  434. package/src/internal/decoders/line.ts +12 -53
  435. package/src/internal/detect-platform.ts +196 -0
  436. package/src/internal/errors.ts +33 -0
  437. package/src/internal/headers.ts +99 -0
  438. package/src/internal/parse.ts +84 -0
  439. package/src/internal/request-options.ts +39 -0
  440. package/src/internal/shim-types.d.ts +28 -0
  441. package/src/internal/shims.ts +107 -0
  442. package/src/internal/to-file.ts +154 -0
  443. package/src/internal/types.ts +92 -0
  444. package/src/internal/uploads.ts +187 -0
  445. package/src/internal/utils/base64.ts +40 -0
  446. package/src/internal/utils/bytes.ts +32 -0
  447. package/src/internal/utils/env.ts +18 -0
  448. package/src/internal/utils/log.ts +127 -0
  449. package/src/internal/utils/path.ts +65 -0
  450. package/src/internal/utils/sleep.ts +3 -0
  451. package/src/internal/utils/uuid.ts +17 -0
  452. package/src/internal/utils/values.ts +102 -0
  453. package/src/internal/utils.ts +8 -0
  454. package/src/lib/BetaMessageStream.ts +11 -10
  455. package/src/lib/MessageStream.ts +11 -10
  456. package/src/pagination.ts +2 -92
  457. package/src/resource.ts +2 -11
  458. package/src/resources/beta/beta.ts +6 -7
  459. package/src/resources/beta/index.ts +9 -9
  460. package/src/resources/beta/messages/batches.ts +68 -115
  461. package/src/resources/beta/messages/index.ts +3 -3
  462. package/src/resources/beta/messages/messages.ts +28 -28
  463. package/src/resources/beta/messages.ts +1 -1
  464. package/src/resources/beta/models.ts +28 -45
  465. package/src/resources/beta.ts +1 -1
  466. package/src/resources/completions.ts +16 -18
  467. package/src/resources/index.ts +9 -14
  468. package/src/resources/messages/batches.ts +28 -39
  469. package/src/resources/messages/index.ts +6 -6
  470. package/src/resources/messages/messages.ts +19 -46
  471. package/src/resources/messages.ts +1 -1
  472. package/src/resources/models.ts +28 -42
  473. package/src/resources.ts +1 -1
  474. package/src/streaming.ts +2 -326
  475. package/src/tsconfig.json +2 -2
  476. package/src/uploads.ts +2 -255
  477. package/src/version.ts +1 -1
  478. package/streaming.d.mts +2 -0
  479. package/streaming.d.mts.map +1 -0
  480. package/streaming.d.ts +1 -31
  481. package/streaming.d.ts.map +1 -1
  482. package/streaming.js +3 -274
  483. package/streaming.js.map +1 -1
  484. package/streaming.mjs +1 -271
  485. package/streaming.mjs.map +1 -1
  486. package/uploads.d.mts +2 -0
  487. package/uploads.d.mts.map +1 -0
  488. package/uploads.d.ts +1 -74
  489. package/uploads.d.ts.map +1 -1
  490. package/uploads.js +3 -168
  491. package/uploads.js.map +1 -1
  492. package/uploads.mjs +1 -157
  493. package/uploads.mjs.map +1 -1
  494. package/version.d.mts +2 -0
  495. package/version.d.mts.map +1 -0
  496. package/version.d.ts +1 -1
  497. package/version.js +1 -1
  498. package/version.mjs +1 -1
  499. package/_shims/MultipartBody.d.ts +0 -9
  500. package/_shims/MultipartBody.d.ts.map +0 -1
  501. package/_shims/MultipartBody.js +0 -16
  502. package/_shims/MultipartBody.js.map +0 -1
  503. package/_shims/MultipartBody.mjs +0 -12
  504. package/_shims/MultipartBody.mjs.map +0 -1
  505. package/_shims/README.md +0 -46
  506. package/_shims/auto/runtime-bun.d.ts +0 -5
  507. package/_shims/auto/runtime-bun.d.ts.map +0 -1
  508. package/_shims/auto/runtime-bun.js +0 -21
  509. package/_shims/auto/runtime-bun.js.map +0 -1
  510. package/_shims/auto/runtime-bun.mjs +0 -2
  511. package/_shims/auto/runtime-bun.mjs.map +0 -1
  512. package/_shims/auto/runtime-node.d.ts +0 -5
  513. package/_shims/auto/runtime-node.d.ts.map +0 -1
  514. package/_shims/auto/runtime-node.js +0 -21
  515. package/_shims/auto/runtime-node.js.map +0 -1
  516. package/_shims/auto/runtime-node.mjs +0 -2
  517. package/_shims/auto/runtime-node.mjs.map +0 -1
  518. package/_shims/auto/runtime.d.ts +0 -5
  519. package/_shims/auto/runtime.d.ts.map +0 -1
  520. package/_shims/auto/runtime.js +0 -21
  521. package/_shims/auto/runtime.js.map +0 -1
  522. package/_shims/auto/runtime.mjs +0 -2
  523. package/_shims/auto/runtime.mjs.map +0 -1
  524. package/_shims/auto/types-node.d.ts +0 -5
  525. package/_shims/auto/types-node.d.ts.map +0 -1
  526. package/_shims/auto/types-node.js +0 -21
  527. package/_shims/auto/types-node.js.map +0 -1
  528. package/_shims/auto/types-node.mjs +0 -2
  529. package/_shims/auto/types-node.mjs.map +0 -1
  530. package/_shims/auto/types.d.ts +0 -101
  531. package/_shims/auto/types.js +0 -3
  532. package/_shims/auto/types.mjs +0 -3
  533. package/_shims/bun-runtime.d.ts +0 -6
  534. package/_shims/bun-runtime.d.ts.map +0 -1
  535. package/_shims/bun-runtime.js +0 -14
  536. package/_shims/bun-runtime.js.map +0 -1
  537. package/_shims/bun-runtime.mjs +0 -10
  538. package/_shims/bun-runtime.mjs.map +0 -1
  539. package/_shims/index.d.ts +0 -83
  540. package/_shims/index.js +0 -17
  541. package/_shims/index.mjs +0 -11
  542. package/_shims/manual-types.d.ts +0 -12
  543. package/_shims/manual-types.js +0 -3
  544. package/_shims/manual-types.mjs +0 -3
  545. package/_shims/node-runtime.d.ts +0 -3
  546. package/_shims/node-runtime.d.ts.map +0 -1
  547. package/_shims/node-runtime.js +0 -89
  548. package/_shims/node-runtime.js.map +0 -1
  549. package/_shims/node-runtime.mjs +0 -56
  550. package/_shims/node-runtime.mjs.map +0 -1
  551. package/_shims/node-types.d.ts +0 -42
  552. package/_shims/node-types.js +0 -3
  553. package/_shims/node-types.mjs +0 -3
  554. package/_shims/registry.d.ts +0 -37
  555. package/_shims/registry.d.ts.map +0 -1
  556. package/_shims/registry.js +0 -41
  557. package/_shims/registry.js.map +0 -1
  558. package/_shims/registry.mjs +0 -37
  559. package/_shims/registry.mjs.map +0 -1
  560. package/_shims/web-runtime.d.ts +0 -5
  561. package/_shims/web-runtime.d.ts.map +0 -1
  562. package/_shims/web-runtime.js +0 -78
  563. package/_shims/web-runtime.js.map +0 -1
  564. package/_shims/web-runtime.mjs +0 -71
  565. package/_shims/web-runtime.mjs.map +0 -1
  566. package/_shims/web-types.d.ts +0 -83
  567. package/_shims/web-types.js +0 -3
  568. package/_shims/web-types.mjs +0 -3
  569. package/core.d.ts +0 -260
  570. package/core.d.ts.map +0 -1
  571. package/core.js +0 -959
  572. package/core.js.map +0 -1
  573. package/core.mjs +0 -927
  574. package/core.mjs.map +0 -1
  575. package/shims/node.d.ts +0 -30
  576. package/shims/node.d.ts.map +0 -1
  577. package/shims/node.js +0 -31
  578. package/shims/node.js.map +0 -1
  579. package/shims/node.mjs +0 -5
  580. package/shims/node.mjs.map +0 -1
  581. package/shims/web.d.ts +0 -26
  582. package/shims/web.d.ts.map +0 -1
  583. package/shims/web.js +0 -31
  584. package/shims/web.js.map +0 -1
  585. package/shims/web.mjs +0 -5
  586. package/shims/web.mjs.map +0 -1
  587. package/src/_shims/MultipartBody.ts +0 -9
  588. package/src/_shims/README.md +0 -46
  589. package/src/_shims/auto/runtime-bun.ts +0 -4
  590. package/src/_shims/auto/runtime-node.ts +0 -4
  591. package/src/_shims/auto/runtime.ts +0 -4
  592. package/src/_shims/auto/types-node.ts +0 -4
  593. package/src/_shims/auto/types.d.ts +0 -101
  594. package/src/_shims/auto/types.js +0 -3
  595. package/src/_shims/auto/types.mjs +0 -3
  596. package/src/_shims/bun-runtime.ts +0 -14
  597. package/src/_shims/index.d.ts +0 -83
  598. package/src/_shims/index.js +0 -17
  599. package/src/_shims/index.mjs +0 -11
  600. package/src/_shims/manual-types.d.ts +0 -12
  601. package/src/_shims/manual-types.js +0 -3
  602. package/src/_shims/manual-types.mjs +0 -3
  603. package/src/_shims/node-runtime.ts +0 -81
  604. package/src/_shims/node-types.d.ts +0 -42
  605. package/src/_shims/node-types.js +0 -3
  606. package/src/_shims/node-types.mjs +0 -3
  607. package/src/_shims/registry.ts +0 -67
  608. package/src/_shims/web-runtime.ts +0 -103
  609. package/src/_shims/web-types.d.ts +0 -83
  610. package/src/_shims/web-types.js +0 -3
  611. package/src/_shims/web-types.mjs +0 -3
  612. package/src/core.ts +0 -1294
  613. package/src/shims/node.ts +0 -50
  614. package/src/shims/web.ts +0 -50
@@ -0,0 +1,1324 @@
1
+ import { APIResource } from "../../../core/resource.mjs";
2
+ import * as MessagesMessagesAPI from "./messages.mjs";
3
+ import * as BetaAPI from "../beta.mjs";
4
+ import * as MessagesAPI from "../../messages/messages.mjs";
5
+ import * as BatchesAPI from "./batches.mjs";
6
+ import { BatchCancelParams, BatchCreateParams, BatchDeleteParams, BatchListParams, BatchResultsParams, BatchRetrieveParams, Batches, BetaDeletedMessageBatch, BetaMessageBatch, BetaMessageBatchCanceledResult, BetaMessageBatchErroredResult, BetaMessageBatchExpiredResult, BetaMessageBatchIndividualResponse, BetaMessageBatchRequestCounts, BetaMessageBatchResult, BetaMessageBatchSucceededResult, BetaMessageBatchesPage } from "./batches.mjs";
7
+ import { APIPromise } from "../../../core/api-promise.mjs";
8
+ import { Stream } from "../../../core/streaming.mjs";
9
+ import { RequestOptions } from "../../../internal/request-options.mjs";
10
+ import { BetaMessageStream } from "../../../lib/BetaMessageStream.mjs";
11
+ export declare class Messages extends APIResource {
12
+ batches: BatchesAPI.Batches;
13
+ /**
14
+ * Send a structured list of input messages with text and/or image content, and the
15
+ * model will generate the next message in the conversation.
16
+ *
17
+ * The Messages API can be used for either single queries or stateless multi-turn
18
+ * conversations.
19
+ *
20
+ * Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const betaMessage = await client.beta.messages.create({
25
+ * max_tokens: 1024,
26
+ * messages: [{ content: 'Hello, world', role: 'user' }],
27
+ * model: 'claude-3-7-sonnet-20250219',
28
+ * });
29
+ * ```
30
+ */
31
+ create(params: MessageCreateParamsNonStreaming, options?: RequestOptions): APIPromise<BetaMessage>;
32
+ create(params: MessageCreateParamsStreaming, options?: RequestOptions): APIPromise<Stream<BetaRawMessageStreamEvent>>;
33
+ create(params: MessageCreateParamsBase, options?: RequestOptions): APIPromise<Stream<BetaRawMessageStreamEvent> | BetaMessage>;
34
+ /**
35
+ * Create a Message stream
36
+ */
37
+ stream(body: BetaMessageStreamParams, options?: RequestOptions): BetaMessageStream;
38
+ /**
39
+ * Count the number of tokens in a Message.
40
+ *
41
+ * The Token Count API can be used to count the number of tokens in a Message,
42
+ * including tools, images, and documents, without creating it.
43
+ *
44
+ * Learn more about token counting in our
45
+ * [user guide](/en/docs/build-with-claude/token-counting)
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const betaMessageTokensCount =
50
+ * await client.beta.messages.countTokens({
51
+ * messages: [{ content: 'string', role: 'user' }],
52
+ * model: 'claude-3-7-sonnet-latest',
53
+ * });
54
+ * ```
55
+ */
56
+ countTokens(params: MessageCountTokensParams, options?: RequestOptions): APIPromise<BetaMessageTokensCount>;
57
+ }
58
+ export type BetaMessageStreamParams = MessageCreateParamsBase;
59
+ export interface BetaBase64ImageSource {
60
+ data: string;
61
+ media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
62
+ type: 'base64';
63
+ }
64
+ export interface BetaBase64PDFBlock {
65
+ source: BetaBase64PDFSource | BetaPlainTextSource | BetaContentBlockSource | BetaURLPDFSource;
66
+ type: 'document';
67
+ /**
68
+ * Create a cache control breakpoint at this content block.
69
+ */
70
+ cache_control?: BetaCacheControlEphemeral | null;
71
+ citations?: BetaCitationsConfigParam;
72
+ context?: string | null;
73
+ title?: string | null;
74
+ }
75
+ export interface BetaBase64PDFSource {
76
+ data: string;
77
+ media_type: 'application/pdf';
78
+ type: 'base64';
79
+ }
80
+ export interface BetaCacheControlEphemeral {
81
+ type: 'ephemeral';
82
+ }
83
+ export interface BetaCitationCharLocation {
84
+ cited_text: string;
85
+ document_index: number;
86
+ document_title: string | null;
87
+ end_char_index: number;
88
+ start_char_index: number;
89
+ type: 'char_location';
90
+ }
91
+ export interface BetaCitationCharLocationParam {
92
+ cited_text: string;
93
+ document_index: number;
94
+ document_title: string | null;
95
+ end_char_index: number;
96
+ start_char_index: number;
97
+ type: 'char_location';
98
+ }
99
+ export interface BetaCitationContentBlockLocation {
100
+ cited_text: string;
101
+ document_index: number;
102
+ document_title: string | null;
103
+ end_block_index: number;
104
+ start_block_index: number;
105
+ type: 'content_block_location';
106
+ }
107
+ export interface BetaCitationContentBlockLocationParam {
108
+ cited_text: string;
109
+ document_index: number;
110
+ document_title: string | null;
111
+ end_block_index: number;
112
+ start_block_index: number;
113
+ type: 'content_block_location';
114
+ }
115
+ export interface BetaCitationPageLocation {
116
+ cited_text: string;
117
+ document_index: number;
118
+ document_title: string | null;
119
+ end_page_number: number;
120
+ start_page_number: number;
121
+ type: 'page_location';
122
+ }
123
+ export interface BetaCitationPageLocationParam {
124
+ cited_text: string;
125
+ document_index: number;
126
+ document_title: string | null;
127
+ end_page_number: number;
128
+ start_page_number: number;
129
+ type: 'page_location';
130
+ }
131
+ export interface BetaCitationWebSearchResultLocationParam {
132
+ cited_text: string;
133
+ encrypted_index: string;
134
+ title: string | null;
135
+ type: 'web_search_result_location';
136
+ url: string;
137
+ }
138
+ export interface BetaCitationsConfigParam {
139
+ enabled?: boolean;
140
+ }
141
+ export interface BetaCitationsDelta {
142
+ citation: BetaCitationCharLocation | BetaCitationPageLocation | BetaCitationContentBlockLocation | BetaCitationsWebSearchResultLocation;
143
+ type: 'citations_delta';
144
+ }
145
+ export interface BetaCitationsWebSearchResultLocation {
146
+ cited_text: string;
147
+ encrypted_index: string;
148
+ title: string | null;
149
+ type: 'web_search_result_location';
150
+ url: string;
151
+ }
152
+ export type BetaContentBlock = BetaTextBlock | BetaToolUseBlock | BetaServerToolUseBlock | BetaWebSearchToolResultBlock | BetaThinkingBlock | BetaRedactedThinkingBlock;
153
+ export type BetaContentBlockParam = BetaTextBlockParam | BetaImageBlockParam | BetaToolUseBlockParam | BetaServerToolUseBlockParam | BetaWebSearchToolResultBlockParam | BetaToolResultBlockParam | BetaBase64PDFBlock | BetaThinkingBlockParam | BetaRedactedThinkingBlockParam;
154
+ export interface BetaContentBlockSource {
155
+ content: string | Array<BetaContentBlockSourceContent>;
156
+ type: 'content';
157
+ }
158
+ export type BetaContentBlockSourceContent = BetaTextBlockParam | BetaImageBlockParam;
159
+ export interface BetaImageBlockParam {
160
+ source: BetaBase64ImageSource | BetaURLImageSource;
161
+ type: 'image';
162
+ /**
163
+ * Create a cache control breakpoint at this content block.
164
+ */
165
+ cache_control?: BetaCacheControlEphemeral | null;
166
+ }
167
+ export interface BetaInputJSONDelta {
168
+ partial_json: string;
169
+ type: 'input_json_delta';
170
+ }
171
+ export interface BetaMessage {
172
+ /**
173
+ * Unique object identifier.
174
+ *
175
+ * The format and length of IDs may change over time.
176
+ */
177
+ id: string;
178
+ /**
179
+ * Content generated by the model.
180
+ *
181
+ * This is an array of content blocks, each of which has a `type` that determines
182
+ * its shape.
183
+ *
184
+ * Example:
185
+ *
186
+ * ```json
187
+ * [{ "type": "text", "text": "Hi, I'm Claude." }]
188
+ * ```
189
+ *
190
+ * If the request input `messages` ended with an `assistant` turn, then the
191
+ * response `content` will continue directly from that last turn. You can use this
192
+ * to constrain the model's output.
193
+ *
194
+ * For example, if the input `messages` were:
195
+ *
196
+ * ```json
197
+ * [
198
+ * {
199
+ * "role": "user",
200
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
201
+ * },
202
+ * { "role": "assistant", "content": "The best answer is (" }
203
+ * ]
204
+ * ```
205
+ *
206
+ * Then the response `content` might be:
207
+ *
208
+ * ```json
209
+ * [{ "type": "text", "text": "B)" }]
210
+ * ```
211
+ */
212
+ content: Array<BetaContentBlock>;
213
+ /**
214
+ * The model that will complete your prompt.\n\nSee
215
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
216
+ * details and options.
217
+ */
218
+ model: MessagesAPI.Model;
219
+ /**
220
+ * Conversational role of the generated message.
221
+ *
222
+ * This will always be `"assistant"`.
223
+ */
224
+ role: 'assistant';
225
+ /**
226
+ * The reason that we stopped.
227
+ *
228
+ * This may be one the following values:
229
+ *
230
+ * - `"end_turn"`: the model reached a natural stopping point
231
+ * - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
232
+ * - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
233
+ * - `"tool_use"`: the model invoked one or more tools
234
+ *
235
+ * In non-streaming mode this value is always non-null. In streaming mode, it is
236
+ * null in the `message_start` event and non-null otherwise.
237
+ */
238
+ stop_reason: BetaStopReason | null;
239
+ /**
240
+ * Which custom stop sequence was generated, if any.
241
+ *
242
+ * This value will be a non-null string if one of your custom stop sequences was
243
+ * generated.
244
+ */
245
+ stop_sequence: string | null;
246
+ /**
247
+ * Object type.
248
+ *
249
+ * For Messages, this is always `"message"`.
250
+ */
251
+ type: 'message';
252
+ /**
253
+ * Billing and rate-limit usage.
254
+ *
255
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
256
+ * underlying cost to our systems.
257
+ *
258
+ * Under the hood, the API transforms requests into a format suitable for the
259
+ * model. The model's output then goes through a parsing stage before becoming an
260
+ * API response. As a result, the token counts in `usage` will not match one-to-one
261
+ * with the exact visible content of an API request or response.
262
+ *
263
+ * For example, `output_tokens` will be non-zero, even for an empty string response
264
+ * from Claude.
265
+ *
266
+ * Total input tokens in a request is the summation of `input_tokens`,
267
+ * `cache_creation_input_tokens`, and `cache_read_input_tokens`.
268
+ */
269
+ usage: BetaUsage;
270
+ }
271
+ export interface BetaMessageDeltaUsage {
272
+ /**
273
+ * The cumulative number of input tokens used to create the cache entry.
274
+ */
275
+ cache_creation_input_tokens: number | null;
276
+ /**
277
+ * The cumulative number of input tokens read from the cache.
278
+ */
279
+ cache_read_input_tokens: number | null;
280
+ /**
281
+ * The cumulative number of input tokens which were used.
282
+ */
283
+ input_tokens: number | null;
284
+ /**
285
+ * The cumulative number of output tokens which were used.
286
+ */
287
+ output_tokens: number;
288
+ /**
289
+ * The number of server tool requests.
290
+ */
291
+ server_tool_use: BetaServerToolUsage | null;
292
+ }
293
+ export interface BetaMessageParam {
294
+ content: string | Array<BetaContentBlockParam>;
295
+ role: 'user' | 'assistant';
296
+ }
297
+ export interface BetaMessageTokensCount {
298
+ /**
299
+ * The total number of tokens across the provided list of messages, system prompt,
300
+ * and tools.
301
+ */
302
+ input_tokens: number;
303
+ }
304
+ export interface BetaMetadata {
305
+ /**
306
+ * An external identifier for the user who is associated with the request.
307
+ *
308
+ * This should be a uuid, hash value, or other opaque identifier. Anthropic may use
309
+ * this id to help detect abuse. Do not include any identifying information such as
310
+ * name, email address, or phone number.
311
+ */
312
+ user_id?: string | null;
313
+ }
314
+ export interface BetaPlainTextSource {
315
+ data: string;
316
+ media_type: 'text/plain';
317
+ type: 'text';
318
+ }
319
+ export type BetaRawContentBlockDelta = BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta | BetaThinkingDelta | BetaSignatureDelta;
320
+ export interface BetaRawContentBlockDeltaEvent {
321
+ delta: BetaRawContentBlockDelta;
322
+ index: number;
323
+ type: 'content_block_delta';
324
+ }
325
+ export interface BetaRawContentBlockStartEvent {
326
+ content_block: BetaTextBlock | BetaToolUseBlock | BetaServerToolUseBlock | BetaWebSearchToolResultBlock | BetaThinkingBlock | BetaRedactedThinkingBlock;
327
+ index: number;
328
+ type: 'content_block_start';
329
+ }
330
+ export interface BetaRawContentBlockStopEvent {
331
+ index: number;
332
+ type: 'content_block_stop';
333
+ }
334
+ export interface BetaRawMessageDeltaEvent {
335
+ delta: BetaRawMessageDeltaEvent.Delta;
336
+ type: 'message_delta';
337
+ /**
338
+ * Billing and rate-limit usage.
339
+ *
340
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
341
+ * underlying cost to our systems.
342
+ *
343
+ * Under the hood, the API transforms requests into a format suitable for the
344
+ * model. The model's output then goes through a parsing stage before becoming an
345
+ * API response. As a result, the token counts in `usage` will not match one-to-one
346
+ * with the exact visible content of an API request or response.
347
+ *
348
+ * For example, `output_tokens` will be non-zero, even for an empty string response
349
+ * from Claude.
350
+ *
351
+ * Total input tokens in a request is the summation of `input_tokens`,
352
+ * `cache_creation_input_tokens`, and `cache_read_input_tokens`.
353
+ */
354
+ usage: BetaMessageDeltaUsage;
355
+ }
356
+ export declare namespace BetaRawMessageDeltaEvent {
357
+ interface Delta {
358
+ stop_reason: MessagesMessagesAPI.BetaStopReason | null;
359
+ stop_sequence: string | null;
360
+ }
361
+ }
362
+ export interface BetaRawMessageStartEvent {
363
+ message: BetaMessage;
364
+ type: 'message_start';
365
+ }
366
+ export interface BetaRawMessageStopEvent {
367
+ type: 'message_stop';
368
+ }
369
+ export type BetaRawMessageStreamEvent = BetaRawMessageStartEvent | BetaRawMessageDeltaEvent | BetaRawMessageStopEvent | BetaRawContentBlockStartEvent | BetaRawContentBlockDeltaEvent | BetaRawContentBlockStopEvent;
370
+ export interface BetaRedactedThinkingBlock {
371
+ data: string;
372
+ type: 'redacted_thinking';
373
+ }
374
+ export interface BetaRedactedThinkingBlockParam {
375
+ data: string;
376
+ type: 'redacted_thinking';
377
+ }
378
+ export interface BetaServerToolUsage {
379
+ /**
380
+ * The number of web search tool requests.
381
+ */
382
+ web_search_requests: number;
383
+ }
384
+ export interface BetaServerToolUseBlock {
385
+ id: string;
386
+ input: unknown;
387
+ name: 'web_search';
388
+ type: 'server_tool_use';
389
+ }
390
+ export interface BetaServerToolUseBlockParam {
391
+ id: string;
392
+ input: unknown;
393
+ name: 'web_search';
394
+ type: 'server_tool_use';
395
+ /**
396
+ * Create a cache control breakpoint at this content block.
397
+ */
398
+ cache_control?: BetaCacheControlEphemeral | null;
399
+ }
400
+ export interface BetaSignatureDelta {
401
+ signature: string;
402
+ type: 'signature_delta';
403
+ }
404
+ export type BetaStopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal';
405
+ export interface BetaTextBlock {
406
+ /**
407
+ * Citations supporting the text block.
408
+ *
409
+ * The type of citation returned will depend on the type of document being cited.
410
+ * Citing a PDF results in `page_location`, plain text results in `char_location`,
411
+ * and content document results in `content_block_location`.
412
+ */
413
+ citations: Array<BetaTextCitation> | null;
414
+ text: string;
415
+ type: 'text';
416
+ }
417
+ export interface BetaTextBlockParam {
418
+ text: string;
419
+ type: 'text';
420
+ /**
421
+ * Create a cache control breakpoint at this content block.
422
+ */
423
+ cache_control?: BetaCacheControlEphemeral | null;
424
+ citations?: Array<BetaTextCitationParam> | null;
425
+ }
426
+ export type BetaTextCitation = BetaCitationCharLocation | BetaCitationPageLocation | BetaCitationContentBlockLocation | BetaCitationsWebSearchResultLocation;
427
+ export type BetaTextCitationParam = BetaCitationCharLocationParam | BetaCitationPageLocationParam | BetaCitationContentBlockLocationParam | BetaCitationWebSearchResultLocationParam;
428
+ export interface BetaTextDelta {
429
+ text: string;
430
+ type: 'text_delta';
431
+ }
432
+ export interface BetaThinkingBlock {
433
+ signature: string;
434
+ thinking: string;
435
+ type: 'thinking';
436
+ }
437
+ export interface BetaThinkingBlockParam {
438
+ signature: string;
439
+ thinking: string;
440
+ type: 'thinking';
441
+ }
442
+ export interface BetaThinkingConfigDisabled {
443
+ type: 'disabled';
444
+ }
445
+ export interface BetaThinkingConfigEnabled {
446
+ /**
447
+ * Determines how many tokens Claude can use for its internal reasoning process.
448
+ * Larger budgets can enable more thorough analysis for complex problems, improving
449
+ * response quality.
450
+ *
451
+ * Must be ≥1024 and less than `max_tokens`.
452
+ *
453
+ * See
454
+ * [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
455
+ * for details.
456
+ */
457
+ budget_tokens: number;
458
+ type: 'enabled';
459
+ }
460
+ /**
461
+ * Configuration for enabling Claude's extended thinking.
462
+ *
463
+ * When enabled, responses include `thinking` content blocks showing Claude's
464
+ * thinking process before the final answer. Requires a minimum budget of 1,024
465
+ * tokens and counts towards your `max_tokens` limit.
466
+ *
467
+ * See
468
+ * [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
469
+ * for details.
470
+ */
471
+ export type BetaThinkingConfigParam = BetaThinkingConfigEnabled | BetaThinkingConfigDisabled;
472
+ export interface BetaThinkingDelta {
473
+ thinking: string;
474
+ type: 'thinking_delta';
475
+ }
476
+ export interface BetaTool {
477
+ /**
478
+ * [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
479
+ *
480
+ * This defines the shape of the `input` that your tool accepts and that the model
481
+ * will produce.
482
+ */
483
+ input_schema: BetaTool.InputSchema;
484
+ /**
485
+ * Name of the tool.
486
+ *
487
+ * This is how the tool will be called by the model and in `tool_use` blocks.
488
+ */
489
+ name: string;
490
+ /**
491
+ * Create a cache control breakpoint at this content block.
492
+ */
493
+ cache_control?: BetaCacheControlEphemeral | null;
494
+ /**
495
+ * Description of what this tool does.
496
+ *
497
+ * Tool descriptions should be as detailed as possible. The more information that
498
+ * the model has about what the tool is and how to use it, the better it will
499
+ * perform. You can use natural language descriptions to reinforce important
500
+ * aspects of the tool input JSON schema.
501
+ */
502
+ description?: string;
503
+ type?: 'custom' | null;
504
+ }
505
+ export declare namespace BetaTool {
506
+ /**
507
+ * [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
508
+ *
509
+ * This defines the shape of the `input` that your tool accepts and that the model
510
+ * will produce.
511
+ */
512
+ interface InputSchema {
513
+ type: 'object';
514
+ properties?: unknown | null;
515
+ [k: string]: unknown;
516
+ }
517
+ }
518
+ export interface BetaToolBash20241022 {
519
+ /**
520
+ * Name of the tool.
521
+ *
522
+ * This is how the tool will be called by the model and in `tool_use` blocks.
523
+ */
524
+ name: 'bash';
525
+ type: 'bash_20241022';
526
+ /**
527
+ * Create a cache control breakpoint at this content block.
528
+ */
529
+ cache_control?: BetaCacheControlEphemeral | null;
530
+ }
531
+ export interface BetaToolBash20250124 {
532
+ /**
533
+ * Name of the tool.
534
+ *
535
+ * This is how the tool will be called by the model and in `tool_use` blocks.
536
+ */
537
+ name: 'bash';
538
+ type: 'bash_20250124';
539
+ /**
540
+ * Create a cache control breakpoint at this content block.
541
+ */
542
+ cache_control?: BetaCacheControlEphemeral | null;
543
+ }
544
+ /**
545
+ * How the model should use the provided tools. The model can use a specific tool,
546
+ * any available tool, decide by itself, or not use tools at all.
547
+ */
548
+ export type BetaToolChoice = BetaToolChoiceAuto | BetaToolChoiceAny | BetaToolChoiceTool | BetaToolChoiceNone;
549
+ /**
550
+ * The model will use any available tools.
551
+ */
552
+ export interface BetaToolChoiceAny {
553
+ type: 'any';
554
+ /**
555
+ * Whether to disable parallel tool use.
556
+ *
557
+ * Defaults to `false`. If set to `true`, the model will output exactly one tool
558
+ * use.
559
+ */
560
+ disable_parallel_tool_use?: boolean;
561
+ }
562
+ /**
563
+ * The model will automatically decide whether to use tools.
564
+ */
565
+ export interface BetaToolChoiceAuto {
566
+ type: 'auto';
567
+ /**
568
+ * Whether to disable parallel tool use.
569
+ *
570
+ * Defaults to `false`. If set to `true`, the model will output at most one tool
571
+ * use.
572
+ */
573
+ disable_parallel_tool_use?: boolean;
574
+ }
575
+ /**
576
+ * The model will not be allowed to use tools.
577
+ */
578
+ export interface BetaToolChoiceNone {
579
+ type: 'none';
580
+ }
581
+ /**
582
+ * The model will use the specified tool with `tool_choice.name`.
583
+ */
584
+ export interface BetaToolChoiceTool {
585
+ /**
586
+ * The name of the tool to use.
587
+ */
588
+ name: string;
589
+ type: 'tool';
590
+ /**
591
+ * Whether to disable parallel tool use.
592
+ *
593
+ * Defaults to `false`. If set to `true`, the model will output exactly one tool
594
+ * use.
595
+ */
596
+ disable_parallel_tool_use?: boolean;
597
+ }
598
+ export interface BetaToolComputerUse20241022 {
599
+ /**
600
+ * The height of the display in pixels.
601
+ */
602
+ display_height_px: number;
603
+ /**
604
+ * The width of the display in pixels.
605
+ */
606
+ display_width_px: number;
607
+ /**
608
+ * Name of the tool.
609
+ *
610
+ * This is how the tool will be called by the model and in `tool_use` blocks.
611
+ */
612
+ name: 'computer';
613
+ type: 'computer_20241022';
614
+ /**
615
+ * Create a cache control breakpoint at this content block.
616
+ */
617
+ cache_control?: BetaCacheControlEphemeral | null;
618
+ /**
619
+ * The X11 display number (e.g. 0, 1) for the display.
620
+ */
621
+ display_number?: number | null;
622
+ }
623
+ export interface BetaToolComputerUse20250124 {
624
+ /**
625
+ * The height of the display in pixels.
626
+ */
627
+ display_height_px: number;
628
+ /**
629
+ * The width of the display in pixels.
630
+ */
631
+ display_width_px: number;
632
+ /**
633
+ * Name of the tool.
634
+ *
635
+ * This is how the tool will be called by the model and in `tool_use` blocks.
636
+ */
637
+ name: 'computer';
638
+ type: 'computer_20250124';
639
+ /**
640
+ * Create a cache control breakpoint at this content block.
641
+ */
642
+ cache_control?: BetaCacheControlEphemeral | null;
643
+ /**
644
+ * The X11 display number (e.g. 0, 1) for the display.
645
+ */
646
+ display_number?: number | null;
647
+ }
648
+ export interface BetaToolResultBlockParam {
649
+ tool_use_id: string;
650
+ type: 'tool_result';
651
+ /**
652
+ * Create a cache control breakpoint at this content block.
653
+ */
654
+ cache_control?: BetaCacheControlEphemeral | null;
655
+ content?: string | Array<BetaTextBlockParam | BetaImageBlockParam>;
656
+ is_error?: boolean;
657
+ }
658
+ export interface BetaToolTextEditor20241022 {
659
+ /**
660
+ * Name of the tool.
661
+ *
662
+ * This is how the tool will be called by the model and in `tool_use` blocks.
663
+ */
664
+ name: 'str_replace_editor';
665
+ type: 'text_editor_20241022';
666
+ /**
667
+ * Create a cache control breakpoint at this content block.
668
+ */
669
+ cache_control?: BetaCacheControlEphemeral | null;
670
+ }
671
+ export interface BetaToolTextEditor20250124 {
672
+ /**
673
+ * Name of the tool.
674
+ *
675
+ * This is how the tool will be called by the model and in `tool_use` blocks.
676
+ */
677
+ name: 'str_replace_editor';
678
+ type: 'text_editor_20250124';
679
+ /**
680
+ * Create a cache control breakpoint at this content block.
681
+ */
682
+ cache_control?: BetaCacheControlEphemeral | null;
683
+ }
684
+ export type BetaToolUnion = BetaTool | BetaToolComputerUse20241022 | BetaToolBash20241022 | BetaToolTextEditor20241022 | BetaToolComputerUse20250124 | BetaToolBash20250124 | BetaToolTextEditor20250124 | BetaWebSearchTool20250305;
685
+ export interface BetaToolUseBlock {
686
+ id: string;
687
+ input: unknown;
688
+ name: string;
689
+ type: 'tool_use';
690
+ }
691
+ export interface BetaToolUseBlockParam {
692
+ id: string;
693
+ input: unknown;
694
+ name: string;
695
+ type: 'tool_use';
696
+ /**
697
+ * Create a cache control breakpoint at this content block.
698
+ */
699
+ cache_control?: BetaCacheControlEphemeral | null;
700
+ }
701
+ export interface BetaURLImageSource {
702
+ type: 'url';
703
+ url: string;
704
+ }
705
+ export interface BetaURLPDFSource {
706
+ type: 'url';
707
+ url: string;
708
+ }
709
+ export interface BetaUsage {
710
+ /**
711
+ * The number of input tokens used to create the cache entry.
712
+ */
713
+ cache_creation_input_tokens: number | null;
714
+ /**
715
+ * The number of input tokens read from the cache.
716
+ */
717
+ cache_read_input_tokens: number | null;
718
+ /**
719
+ * The number of input tokens which were used.
720
+ */
721
+ input_tokens: number;
722
+ /**
723
+ * The number of output tokens which were used.
724
+ */
725
+ output_tokens: number;
726
+ /**
727
+ * The number of server tool requests.
728
+ */
729
+ server_tool_use: BetaServerToolUsage | null;
730
+ }
731
+ export interface BetaWebSearchResultBlock {
732
+ encrypted_content: string;
733
+ page_age: string | null;
734
+ title: string;
735
+ type: 'web_search_result';
736
+ url: string;
737
+ }
738
+ export interface BetaWebSearchResultBlockParam {
739
+ encrypted_content: string;
740
+ title: string;
741
+ type: 'web_search_result';
742
+ url: string;
743
+ page_age?: string | null;
744
+ }
745
+ export interface BetaWebSearchTool20250305 {
746
+ /**
747
+ * Name of the tool.
748
+ *
749
+ * This is how the tool will be called by the model and in `tool_use` blocks.
750
+ */
751
+ name: 'web_search';
752
+ type: 'web_search_20250305';
753
+ /**
754
+ * If provided, only these domains will be included in results. Cannot be used
755
+ * alongside `blocked_domains`.
756
+ */
757
+ allowed_domains?: Array<string> | null;
758
+ /**
759
+ * If provided, these domains will never appear in results. Cannot be used
760
+ * alongside `allowed_domains`.
761
+ */
762
+ blocked_domains?: Array<string> | null;
763
+ /**
764
+ * Create a cache control breakpoint at this content block.
765
+ */
766
+ cache_control?: BetaCacheControlEphemeral | null;
767
+ /**
768
+ * Maximum number of times the tool can be used in the API request.
769
+ */
770
+ max_uses?: number | null;
771
+ /**
772
+ * Parameters for the user's location. Used to provide more relevant search
773
+ * results.
774
+ */
775
+ user_location?: BetaWebSearchTool20250305.UserLocation | null;
776
+ }
777
+ export declare namespace BetaWebSearchTool20250305 {
778
+ /**
779
+ * Parameters for the user's location. Used to provide more relevant search
780
+ * results.
781
+ */
782
+ interface UserLocation {
783
+ type: 'approximate';
784
+ /**
785
+ * The city of the user.
786
+ */
787
+ city?: string | null;
788
+ /**
789
+ * The two letter
790
+ * [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
791
+ * user.
792
+ */
793
+ country?: string | null;
794
+ /**
795
+ * The region of the user.
796
+ */
797
+ region?: string | null;
798
+ /**
799
+ * The [IANA timezone](https://nodatime.org/TimeZones) of the user.
800
+ */
801
+ timezone?: string | null;
802
+ }
803
+ }
804
+ export interface BetaWebSearchToolRequestError {
805
+ error_code: 'invalid_tool_input' | 'unavailable' | 'max_uses_exceeded' | 'too_many_requests' | 'query_too_long';
806
+ type: 'web_search_tool_result_error';
807
+ }
808
+ export interface BetaWebSearchToolResultBlock {
809
+ content: BetaWebSearchToolResultBlockContent;
810
+ tool_use_id: string;
811
+ type: 'web_search_tool_result';
812
+ }
813
+ export type BetaWebSearchToolResultBlockContent = BetaWebSearchToolResultError | Array<BetaWebSearchResultBlock>;
814
+ export interface BetaWebSearchToolResultBlockParam {
815
+ content: BetaWebSearchToolResultBlockParamContent;
816
+ tool_use_id: string;
817
+ type: 'web_search_tool_result';
818
+ /**
819
+ * Create a cache control breakpoint at this content block.
820
+ */
821
+ cache_control?: BetaCacheControlEphemeral | null;
822
+ }
823
+ export type BetaWebSearchToolResultBlockParamContent = Array<BetaWebSearchResultBlockParam> | BetaWebSearchToolRequestError;
824
+ export interface BetaWebSearchToolResultError {
825
+ error_code: 'invalid_tool_input' | 'unavailable' | 'max_uses_exceeded' | 'too_many_requests' | 'query_too_long';
826
+ type: 'web_search_tool_result_error';
827
+ }
828
+ export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
829
+ export interface MessageCreateParamsBase {
830
+ /**
831
+ * Body param: The maximum number of tokens to generate before stopping.
832
+ *
833
+ * Note that our models may stop _before_ reaching this maximum. This parameter
834
+ * only specifies the absolute maximum number of tokens to generate.
835
+ *
836
+ * Different models have different maximum values for this parameter. See
837
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for details.
838
+ */
839
+ max_tokens: number;
840
+ /**
841
+ * Body param: Input messages.
842
+ *
843
+ * Our models are trained to operate on alternating `user` and `assistant`
844
+ * conversational turns. When creating a new `Message`, you specify the prior
845
+ * conversational turns with the `messages` parameter, and the model then generates
846
+ * the next `Message` in the conversation. Consecutive `user` or `assistant` turns
847
+ * in your request will be combined into a single turn.
848
+ *
849
+ * Each input message must be an object with a `role` and `content`. You can
850
+ * specify a single `user`-role message, or you can include multiple `user` and
851
+ * `assistant` messages.
852
+ *
853
+ * If the final message uses the `assistant` role, the response content will
854
+ * continue immediately from the content in that message. This can be used to
855
+ * constrain part of the model's response.
856
+ *
857
+ * Example with a single `user` message:
858
+ *
859
+ * ```json
860
+ * [{ "role": "user", "content": "Hello, Claude" }]
861
+ * ```
862
+ *
863
+ * Example with multiple conversational turns:
864
+ *
865
+ * ```json
866
+ * [
867
+ * { "role": "user", "content": "Hello there." },
868
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
869
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
870
+ * ]
871
+ * ```
872
+ *
873
+ * Example with a partially-filled response from Claude:
874
+ *
875
+ * ```json
876
+ * [
877
+ * {
878
+ * "role": "user",
879
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
880
+ * },
881
+ * { "role": "assistant", "content": "The best answer is (" }
882
+ * ]
883
+ * ```
884
+ *
885
+ * Each input message `content` may be either a single `string` or an array of
886
+ * content blocks, where each block has a specific `type`. Using a `string` for
887
+ * `content` is shorthand for an array of one content block of type `"text"`. The
888
+ * following input messages are equivalent:
889
+ *
890
+ * ```json
891
+ * { "role": "user", "content": "Hello, Claude" }
892
+ * ```
893
+ *
894
+ * ```json
895
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
896
+ * ```
897
+ *
898
+ * Starting with Claude 3 models, you can also send image content blocks:
899
+ *
900
+ * ```json
901
+ * {
902
+ * "role": "user",
903
+ * "content": [
904
+ * {
905
+ * "type": "image",
906
+ * "source": {
907
+ * "type": "base64",
908
+ * "media_type": "image/jpeg",
909
+ * "data": "/9j/4AAQSkZJRg..."
910
+ * }
911
+ * },
912
+ * { "type": "text", "text": "What is in this image?" }
913
+ * ]
914
+ * }
915
+ * ```
916
+ *
917
+ * We currently support the `base64` source type for images, and the `image/jpeg`,
918
+ * `image/png`, `image/gif`, and `image/webp` media types.
919
+ *
920
+ * See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
921
+ * more input examples.
922
+ *
923
+ * Note that if you want to include a
924
+ * [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
925
+ * the top-level `system` parameter — there is no `"system"` role for input
926
+ * messages in the Messages API.
927
+ *
928
+ * There is a limit of 100000 messages in a single request.
929
+ */
930
+ messages: Array<BetaMessageParam>;
931
+ /**
932
+ * Body param: The model that will complete your prompt.\n\nSee
933
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
934
+ * details and options.
935
+ */
936
+ model: MessagesAPI.Model;
937
+ /**
938
+ * Body param: An object describing metadata about the request.
939
+ */
940
+ metadata?: BetaMetadata;
941
+ /**
942
+ * Body param: Custom text sequences that will cause the model to stop generating.
943
+ *
944
+ * Our models will normally stop when they have naturally completed their turn,
945
+ * which will result in a response `stop_reason` of `"end_turn"`.
946
+ *
947
+ * If you want the model to stop generating when it encounters custom strings of
948
+ * text, you can use the `stop_sequences` parameter. If the model encounters one of
949
+ * the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
950
+ * and the response `stop_sequence` value will contain the matched stop sequence.
951
+ */
952
+ stop_sequences?: Array<string>;
953
+ /**
954
+ * Body param: Whether to incrementally stream the response using server-sent
955
+ * events.
956
+ *
957
+ * See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
958
+ * details.
959
+ */
960
+ stream?: boolean;
961
+ /**
962
+ * Body param: System prompt.
963
+ *
964
+ * A system prompt is a way of providing context and instructions to Claude, such
965
+ * as specifying a particular goal or role. See our
966
+ * [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
967
+ */
968
+ system?: string | Array<BetaTextBlockParam>;
969
+ /**
970
+ * Body param: Amount of randomness injected into the response.
971
+ *
972
+ * Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
973
+ * for analytical / multiple choice, and closer to `1.0` for creative and
974
+ * generative tasks.
975
+ *
976
+ * Note that even with `temperature` of `0.0`, the results will not be fully
977
+ * deterministic.
978
+ */
979
+ temperature?: number;
980
+ /**
981
+ * Body param: Configuration for enabling Claude's extended thinking.
982
+ *
983
+ * When enabled, responses include `thinking` content blocks showing Claude's
984
+ * thinking process before the final answer. Requires a minimum budget of 1,024
985
+ * tokens and counts towards your `max_tokens` limit.
986
+ *
987
+ * See
988
+ * [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
989
+ * for details.
990
+ */
991
+ thinking?: BetaThinkingConfigParam;
992
+ /**
993
+ * Body param: How the model should use the provided tools. The model can use a
994
+ * specific tool, any available tool, decide by itself, or not use tools at all.
995
+ */
996
+ tool_choice?: BetaToolChoice;
997
+ /**
998
+ * Body param: Definitions of tools that the model may use.
999
+ *
1000
+ * If you include `tools` in your API request, the model may return `tool_use`
1001
+ * content blocks that represent the model's use of those tools. You can then run
1002
+ * those tools using the tool input generated by the model and then optionally
1003
+ * return results back to the model using `tool_result` content blocks.
1004
+ *
1005
+ * Each tool definition includes:
1006
+ *
1007
+ * - `name`: Name of the tool.
1008
+ * - `description`: Optional, but strongly-recommended description of the tool.
1009
+ * - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
1010
+ * tool `input` shape that the model will produce in `tool_use` output content
1011
+ * blocks.
1012
+ *
1013
+ * For example, if you defined `tools` as:
1014
+ *
1015
+ * ```json
1016
+ * [
1017
+ * {
1018
+ * "name": "get_stock_price",
1019
+ * "description": "Get the current stock price for a given ticker symbol.",
1020
+ * "input_schema": {
1021
+ * "type": "object",
1022
+ * "properties": {
1023
+ * "ticker": {
1024
+ * "type": "string",
1025
+ * "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
1026
+ * }
1027
+ * },
1028
+ * "required": ["ticker"]
1029
+ * }
1030
+ * }
1031
+ * ]
1032
+ * ```
1033
+ *
1034
+ * And then asked the model "What's the S&P 500 at today?", the model might produce
1035
+ * `tool_use` content blocks in the response like this:
1036
+ *
1037
+ * ```json
1038
+ * [
1039
+ * {
1040
+ * "type": "tool_use",
1041
+ * "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
1042
+ * "name": "get_stock_price",
1043
+ * "input": { "ticker": "^GSPC" }
1044
+ * }
1045
+ * ]
1046
+ * ```
1047
+ *
1048
+ * You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
1049
+ * input, and return the following back to the model in a subsequent `user`
1050
+ * message:
1051
+ *
1052
+ * ```json
1053
+ * [
1054
+ * {
1055
+ * "type": "tool_result",
1056
+ * "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
1057
+ * "content": "259.75 USD"
1058
+ * }
1059
+ * ]
1060
+ * ```
1061
+ *
1062
+ * Tools can be used for workflows that include running client-side tools and
1063
+ * functions, or more generally whenever you want the model to produce a particular
1064
+ * JSON structure of output.
1065
+ *
1066
+ * See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
1067
+ */
1068
+ tools?: Array<BetaToolUnion>;
1069
+ /**
1070
+ * Body param: Only sample from the top K options for each subsequent token.
1071
+ *
1072
+ * Used to remove "long tail" low probability responses.
1073
+ * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
1074
+ *
1075
+ * Recommended for advanced use cases only. You usually only need to use
1076
+ * `temperature`.
1077
+ */
1078
+ top_k?: number;
1079
+ /**
1080
+ * Body param: Use nucleus sampling.
1081
+ *
1082
+ * In nucleus sampling, we compute the cumulative distribution over all the options
1083
+ * for each subsequent token in decreasing probability order and cut it off once it
1084
+ * reaches a particular probability specified by `top_p`. You should either alter
1085
+ * `temperature` or `top_p`, but not both.
1086
+ *
1087
+ * Recommended for advanced use cases only. You usually only need to use
1088
+ * `temperature`.
1089
+ */
1090
+ top_p?: number;
1091
+ /**
1092
+ * Header param: Optional header to specify the beta version(s) you want to use.
1093
+ */
1094
+ betas?: Array<BetaAPI.AnthropicBeta>;
1095
+ }
1096
+ export declare namespace MessageCreateParams {
1097
+ type MessageCreateParamsNonStreaming = MessagesMessagesAPI.MessageCreateParamsNonStreaming;
1098
+ type MessageCreateParamsStreaming = MessagesMessagesAPI.MessageCreateParamsStreaming;
1099
+ }
1100
+ export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase {
1101
+ /**
1102
+ * Body param: Whether to incrementally stream the response using server-sent
1103
+ * events.
1104
+ *
1105
+ * See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
1106
+ * details.
1107
+ */
1108
+ stream?: false;
1109
+ }
1110
+ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
1111
+ /**
1112
+ * Body param: Whether to incrementally stream the response using server-sent
1113
+ * events.
1114
+ *
1115
+ * See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
1116
+ * details.
1117
+ */
1118
+ stream: true;
1119
+ }
1120
+ export interface MessageCountTokensParams {
1121
+ /**
1122
+ * Body param: Input messages.
1123
+ *
1124
+ * Our models are trained to operate on alternating `user` and `assistant`
1125
+ * conversational turns. When creating a new `Message`, you specify the prior
1126
+ * conversational turns with the `messages` parameter, and the model then generates
1127
+ * the next `Message` in the conversation. Consecutive `user` or `assistant` turns
1128
+ * in your request will be combined into a single turn.
1129
+ *
1130
+ * Each input message must be an object with a `role` and `content`. You can
1131
+ * specify a single `user`-role message, or you can include multiple `user` and
1132
+ * `assistant` messages.
1133
+ *
1134
+ * If the final message uses the `assistant` role, the response content will
1135
+ * continue immediately from the content in that message. This can be used to
1136
+ * constrain part of the model's response.
1137
+ *
1138
+ * Example with a single `user` message:
1139
+ *
1140
+ * ```json
1141
+ * [{ "role": "user", "content": "Hello, Claude" }]
1142
+ * ```
1143
+ *
1144
+ * Example with multiple conversational turns:
1145
+ *
1146
+ * ```json
1147
+ * [
1148
+ * { "role": "user", "content": "Hello there." },
1149
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
1150
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
1151
+ * ]
1152
+ * ```
1153
+ *
1154
+ * Example with a partially-filled response from Claude:
1155
+ *
1156
+ * ```json
1157
+ * [
1158
+ * {
1159
+ * "role": "user",
1160
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
1161
+ * },
1162
+ * { "role": "assistant", "content": "The best answer is (" }
1163
+ * ]
1164
+ * ```
1165
+ *
1166
+ * Each input message `content` may be either a single `string` or an array of
1167
+ * content blocks, where each block has a specific `type`. Using a `string` for
1168
+ * `content` is shorthand for an array of one content block of type `"text"`. The
1169
+ * following input messages are equivalent:
1170
+ *
1171
+ * ```json
1172
+ * { "role": "user", "content": "Hello, Claude" }
1173
+ * ```
1174
+ *
1175
+ * ```json
1176
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
1177
+ * ```
1178
+ *
1179
+ * Starting with Claude 3 models, you can also send image content blocks:
1180
+ *
1181
+ * ```json
1182
+ * {
1183
+ * "role": "user",
1184
+ * "content": [
1185
+ * {
1186
+ * "type": "image",
1187
+ * "source": {
1188
+ * "type": "base64",
1189
+ * "media_type": "image/jpeg",
1190
+ * "data": "/9j/4AAQSkZJRg..."
1191
+ * }
1192
+ * },
1193
+ * { "type": "text", "text": "What is in this image?" }
1194
+ * ]
1195
+ * }
1196
+ * ```
1197
+ *
1198
+ * We currently support the `base64` source type for images, and the `image/jpeg`,
1199
+ * `image/png`, `image/gif`, and `image/webp` media types.
1200
+ *
1201
+ * See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
1202
+ * more input examples.
1203
+ *
1204
+ * Note that if you want to include a
1205
+ * [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
1206
+ * the top-level `system` parameter — there is no `"system"` role for input
1207
+ * messages in the Messages API.
1208
+ *
1209
+ * There is a limit of 100000 messages in a single request.
1210
+ */
1211
+ messages: Array<BetaMessageParam>;
1212
+ /**
1213
+ * Body param: The model that will complete your prompt.\n\nSee
1214
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
1215
+ * details and options.
1216
+ */
1217
+ model: MessagesAPI.Model;
1218
+ /**
1219
+ * Body param: System prompt.
1220
+ *
1221
+ * A system prompt is a way of providing context and instructions to Claude, such
1222
+ * as specifying a particular goal or role. See our
1223
+ * [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
1224
+ */
1225
+ system?: string | Array<BetaTextBlockParam>;
1226
+ /**
1227
+ * Body param: Configuration for enabling Claude's extended thinking.
1228
+ *
1229
+ * When enabled, responses include `thinking` content blocks showing Claude's
1230
+ * thinking process before the final answer. Requires a minimum budget of 1,024
1231
+ * tokens and counts towards your `max_tokens` limit.
1232
+ *
1233
+ * See
1234
+ * [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
1235
+ * for details.
1236
+ */
1237
+ thinking?: BetaThinkingConfigParam;
1238
+ /**
1239
+ * Body param: How the model should use the provided tools. The model can use a
1240
+ * specific tool, any available tool, decide by itself, or not use tools at all.
1241
+ */
1242
+ tool_choice?: BetaToolChoice;
1243
+ /**
1244
+ * Body param: Definitions of tools that the model may use.
1245
+ *
1246
+ * If you include `tools` in your API request, the model may return `tool_use`
1247
+ * content blocks that represent the model's use of those tools. You can then run
1248
+ * those tools using the tool input generated by the model and then optionally
1249
+ * return results back to the model using `tool_result` content blocks.
1250
+ *
1251
+ * Each tool definition includes:
1252
+ *
1253
+ * - `name`: Name of the tool.
1254
+ * - `description`: Optional, but strongly-recommended description of the tool.
1255
+ * - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
1256
+ * tool `input` shape that the model will produce in `tool_use` output content
1257
+ * blocks.
1258
+ *
1259
+ * For example, if you defined `tools` as:
1260
+ *
1261
+ * ```json
1262
+ * [
1263
+ * {
1264
+ * "name": "get_stock_price",
1265
+ * "description": "Get the current stock price for a given ticker symbol.",
1266
+ * "input_schema": {
1267
+ * "type": "object",
1268
+ * "properties": {
1269
+ * "ticker": {
1270
+ * "type": "string",
1271
+ * "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
1272
+ * }
1273
+ * },
1274
+ * "required": ["ticker"]
1275
+ * }
1276
+ * }
1277
+ * ]
1278
+ * ```
1279
+ *
1280
+ * And then asked the model "What's the S&P 500 at today?", the model might produce
1281
+ * `tool_use` content blocks in the response like this:
1282
+ *
1283
+ * ```json
1284
+ * [
1285
+ * {
1286
+ * "type": "tool_use",
1287
+ * "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
1288
+ * "name": "get_stock_price",
1289
+ * "input": { "ticker": "^GSPC" }
1290
+ * }
1291
+ * ]
1292
+ * ```
1293
+ *
1294
+ * You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
1295
+ * input, and return the following back to the model in a subsequent `user`
1296
+ * message:
1297
+ *
1298
+ * ```json
1299
+ * [
1300
+ * {
1301
+ * "type": "tool_result",
1302
+ * "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
1303
+ * "content": "259.75 USD"
1304
+ * }
1305
+ * ]
1306
+ * ```
1307
+ *
1308
+ * Tools can be used for workflows that include running client-side tools and
1309
+ * functions, or more generally whenever you want the model to produce a particular
1310
+ * JSON structure of output.
1311
+ *
1312
+ * See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
1313
+ */
1314
+ tools?: Array<BetaTool | BetaToolComputerUse20241022 | BetaToolBash20241022 | BetaToolTextEditor20241022 | BetaToolComputerUse20250124 | BetaToolBash20250124 | BetaToolTextEditor20250124 | BetaWebSearchTool20250305>;
1315
+ /**
1316
+ * Header param: Optional header to specify the beta version(s) you want to use.
1317
+ */
1318
+ betas?: Array<BetaAPI.AnthropicBeta>;
1319
+ }
1320
+ export declare namespace Messages {
1321
+ export { type BetaBase64ImageSource as BetaBase64ImageSource, type BetaBase64PDFBlock as BetaBase64PDFBlock, type BetaBase64PDFSource as BetaBase64PDFSource, type BetaCacheControlEphemeral as BetaCacheControlEphemeral, type BetaCitationCharLocation as BetaCitationCharLocation, type BetaCitationCharLocationParam as BetaCitationCharLocationParam, type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation, type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam, type BetaCitationPageLocation as BetaCitationPageLocation, type BetaCitationPageLocationParam as BetaCitationPageLocationParam, type BetaCitationWebSearchResultLocationParam as BetaCitationWebSearchResultLocationParam, type BetaCitationsConfigParam as BetaCitationsConfigParam, type BetaCitationsDelta as BetaCitationsDelta, type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation, type BetaContentBlock as BetaContentBlock, type BetaContentBlockParam as BetaContentBlockParam, type BetaContentBlockSource as BetaContentBlockSource, type BetaContentBlockSourceContent as BetaContentBlockSourceContent, type BetaImageBlockParam as BetaImageBlockParam, type BetaInputJSONDelta as BetaInputJSONDelta, type BetaMessage as BetaMessage, type BetaMessageDeltaUsage as BetaMessageDeltaUsage, type BetaMessageParam as BetaMessageParam, type BetaMessageTokensCount as BetaMessageTokensCount, type BetaMetadata as BetaMetadata, type BetaPlainTextSource as BetaPlainTextSource, type BetaRawContentBlockDelta as BetaRawContentBlockDelta, type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent, type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent, type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent, type BetaRawMessageDeltaEvent as BetaRawMessageDeltaEvent, type BetaRawMessageStartEvent as BetaRawMessageStartEvent, type BetaRawMessageStopEvent as BetaRawMessageStopEvent, type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent, type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock, type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam, type BetaServerToolUsage as BetaServerToolUsage, type BetaServerToolUseBlock as BetaServerToolUseBlock, type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam, type BetaSignatureDelta as BetaSignatureDelta, type BetaStopReason as BetaStopReason, type BetaTextBlock as BetaTextBlock, type BetaTextBlockParam as BetaTextBlockParam, type BetaTextCitation as BetaTextCitation, type BetaTextCitationParam as BetaTextCitationParam, type BetaTextDelta as BetaTextDelta, type BetaThinkingBlock as BetaThinkingBlock, type BetaThinkingBlockParam as BetaThinkingBlockParam, type BetaThinkingConfigDisabled as BetaThinkingConfigDisabled, type BetaThinkingConfigEnabled as BetaThinkingConfigEnabled, type BetaThinkingConfigParam as BetaThinkingConfigParam, type BetaThinkingDelta as BetaThinkingDelta, type BetaTool as BetaTool, type BetaToolBash20241022 as BetaToolBash20241022, type BetaToolBash20250124 as BetaToolBash20250124, type BetaToolChoice as BetaToolChoice, type BetaToolChoiceAny as BetaToolChoiceAny, type BetaToolChoiceAuto as BetaToolChoiceAuto, type BetaToolChoiceNone as BetaToolChoiceNone, type BetaToolChoiceTool as BetaToolChoiceTool, type BetaToolComputerUse20241022 as BetaToolComputerUse20241022, type BetaToolComputerUse20250124 as BetaToolComputerUse20250124, type BetaToolResultBlockParam as BetaToolResultBlockParam, type BetaToolTextEditor20241022 as BetaToolTextEditor20241022, type BetaToolTextEditor20250124 as BetaToolTextEditor20250124, type BetaToolUnion as BetaToolUnion, type BetaToolUseBlock as BetaToolUseBlock, type BetaToolUseBlockParam as BetaToolUseBlockParam, type BetaURLImageSource as BetaURLImageSource, type BetaURLPDFSource as BetaURLPDFSource, type BetaUsage as BetaUsage, type BetaWebSearchResultBlock as BetaWebSearchResultBlock, type BetaWebSearchResultBlockParam as BetaWebSearchResultBlockParam, type BetaWebSearchTool20250305 as BetaWebSearchTool20250305, type BetaWebSearchToolRequestError as BetaWebSearchToolRequestError, type BetaWebSearchToolResultBlock as BetaWebSearchToolResultBlock, type BetaWebSearchToolResultBlockContent as BetaWebSearchToolResultBlockContent, type BetaWebSearchToolResultBlockParam as BetaWebSearchToolResultBlockParam, type BetaWebSearchToolResultBlockParamContent as BetaWebSearchToolResultBlockParamContent, type BetaWebSearchToolResultError as BetaWebSearchToolResultError, type MessageCreateParams as MessageCreateParams, type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming, type MessageCreateParamsStreaming as MessageCreateParamsStreaming, type MessageCountTokensParams as MessageCountTokensParams, };
1322
+ export { Batches as Batches, type BetaDeletedMessageBatch as BetaDeletedMessageBatch, type BetaMessageBatch as BetaMessageBatch, type BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult, type BetaMessageBatchErroredResult as BetaMessageBatchErroredResult, type BetaMessageBatchExpiredResult as BetaMessageBatchExpiredResult, type BetaMessageBatchIndividualResponse as BetaMessageBatchIndividualResponse, type BetaMessageBatchRequestCounts as BetaMessageBatchRequestCounts, type BetaMessageBatchResult as BetaMessageBatchResult, type BetaMessageBatchSucceededResult as BetaMessageBatchSucceededResult, type BetaMessageBatchesPage as BetaMessageBatchesPage, type BatchCreateParams as BatchCreateParams, type BatchRetrieveParams as BatchRetrieveParams, type BatchListParams as BatchListParams, type BatchDeleteParams as BatchDeleteParams, type BatchCancelParams as BatchCancelParams, type BatchResultsParams as BatchResultsParams, };
1323
+ }
1324
+ //# sourceMappingURL=messages.d.mts.map