@anthropic-ai/sdk 0.33.0 → 0.34.0-alpha.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 (481) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +15 -11
  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/api-promise.d.mts +48 -0
  6. package/api-promise.d.mts.map +1 -0
  7. package/api-promise.d.ts +48 -0
  8. package/api-promise.d.ts.map +1 -0
  9. package/api-promise.js +71 -0
  10. package/api-promise.js.map +1 -0
  11. package/api-promise.mjs +67 -0
  12. package/api-promise.mjs.map +1 -0
  13. package/client.d.mts +212 -0
  14. package/client.d.mts.map +1 -0
  15. package/client.d.ts +212 -0
  16. package/client.d.ts.map +1 -0
  17. package/client.js +505 -0
  18. package/client.js.map +1 -0
  19. package/client.mjs +477 -0
  20. package/client.mjs.map +1 -0
  21. package/error.d.mts +48 -0
  22. package/error.d.mts.map +1 -0
  23. package/error.d.ts +2 -2
  24. package/error.d.ts.map +1 -1
  25. package/error.js +3 -3
  26. package/error.js.map +1 -1
  27. package/error.mjs +2 -2
  28. package/error.mjs.map +1 -1
  29. package/index.d.mts +5 -150
  30. package/index.d.mts.map +1 -0
  31. package/index.d.ts +5 -150
  32. package/index.d.ts.map +1 -1
  33. package/index.js +18 -159
  34. package/index.js.map +1 -1
  35. package/index.mjs +5 -133
  36. package/index.mjs.map +1 -1
  37. package/internal/builtin-types.d.mts +65 -0
  38. package/internal/builtin-types.d.mts.map +1 -0
  39. package/internal/builtin-types.d.ts +65 -0
  40. package/internal/builtin-types.d.ts.map +1 -0
  41. package/internal/builtin-types.js +4 -0
  42. package/internal/builtin-types.js.map +1 -0
  43. package/internal/builtin-types.mjs +3 -0
  44. package/internal/builtin-types.mjs.map +1 -0
  45. package/internal/decoders/jsonl.d.mts +11 -0
  46. package/internal/decoders/jsonl.d.mts.map +1 -0
  47. package/internal/decoders/jsonl.d.ts +0 -1
  48. package/internal/decoders/jsonl.d.ts.map +1 -1
  49. package/internal/decoders/jsonl.js.map +1 -1
  50. package/internal/decoders/jsonl.mjs.map +1 -1
  51. package/internal/decoders/line.d.mts +21 -0
  52. package/internal/decoders/line.d.mts.map +1 -0
  53. package/internal/decoders/line.d.ts +1 -0
  54. package/internal/decoders/line.d.ts.map +1 -1
  55. package/internal/detect-platform.d.mts +15 -0
  56. package/internal/detect-platform.d.mts.map +1 -0
  57. package/internal/detect-platform.d.ts +15 -0
  58. package/internal/detect-platform.d.ts.map +1 -0
  59. package/internal/detect-platform.js +162 -0
  60. package/internal/detect-platform.js.map +1 -0
  61. package/internal/detect-platform.mjs +157 -0
  62. package/internal/detect-platform.mjs.map +1 -0
  63. package/internal/errors.d.mts +3 -0
  64. package/internal/errors.d.mts.map +1 -0
  65. package/internal/errors.d.ts +3 -0
  66. package/internal/errors.d.ts.map +1 -0
  67. package/internal/errors.js +22 -0
  68. package/internal/errors.js.map +1 -0
  69. package/internal/errors.mjs +17 -0
  70. package/internal/errors.mjs.map +1 -0
  71. package/internal/headers.d.mts +21 -0
  72. package/internal/headers.d.mts.map +1 -0
  73. package/internal/headers.d.ts +21 -0
  74. package/internal/headers.d.ts.map +1 -0
  75. package/internal/headers.js +77 -0
  76. package/internal/headers.js.map +1 -0
  77. package/internal/headers.mjs +72 -0
  78. package/internal/headers.mjs.map +1 -0
  79. package/internal/parse.d.mts +14 -0
  80. package/internal/parse.d.mts.map +1 -0
  81. package/internal/parse.d.ts +14 -0
  82. package/internal/parse.d.ts.map +1 -0
  83. package/internal/parse.js +48 -0
  84. package/internal/parse.js.map +1 -0
  85. package/internal/parse.mjs +43 -0
  86. package/internal/parse.mjs.map +1 -0
  87. package/internal/polyfill/crypto.node.d.ts +10 -0
  88. package/internal/polyfill/crypto.node.js +11 -0
  89. package/internal/polyfill/crypto.node.mjs +2 -0
  90. package/internal/polyfill/file.node.d.ts +9 -0
  91. package/internal/polyfill/file.node.js +17 -0
  92. package/internal/polyfill/file.node.mjs +9 -0
  93. package/internal/request-options.d.mts +37 -0
  94. package/internal/request-options.d.mts.map +1 -0
  95. package/internal/request-options.d.ts +37 -0
  96. package/internal/request-options.d.ts.map +1 -0
  97. package/internal/request-options.js +40 -0
  98. package/internal/request-options.js.map +1 -0
  99. package/internal/request-options.mjs +35 -0
  100. package/internal/request-options.mjs.map +1 -0
  101. package/internal/shim-types.d.mts +28 -0
  102. package/internal/shim-types.d.ts +28 -0
  103. package/internal/shims.d.mts +65 -0
  104. package/internal/shims.d.mts.map +1 -0
  105. package/internal/shims.d.ts +65 -0
  106. package/internal/shims.d.ts.map +1 -0
  107. package/internal/shims.js +66 -0
  108. package/internal/shims.js.map +1 -0
  109. package/internal/shims.mjs +58 -0
  110. package/internal/shims.mjs.map +1 -0
  111. package/internal/types.d.mts +6 -0
  112. package/internal/types.d.mts.map +1 -0
  113. package/internal/types.d.ts +6 -0
  114. package/internal/types.d.ts.map +1 -0
  115. package/internal/types.js +4 -0
  116. package/internal/types.js.map +1 -0
  117. package/internal/types.mjs +3 -0
  118. package/internal/types.mjs.map +1 -0
  119. package/internal/utils/base64.d.mts +3 -0
  120. package/internal/utils/base64.d.mts.map +1 -0
  121. package/internal/utils/base64.d.ts +3 -0
  122. package/internal/utils/base64.d.ts.map +1 -0
  123. package/internal/utils/base64.js +33 -0
  124. package/internal/utils/base64.js.map +1 -0
  125. package/internal/utils/base64.mjs +28 -0
  126. package/internal/utils/base64.mjs.map +1 -0
  127. package/internal/utils/env.d.mts +9 -0
  128. package/internal/utils/env.d.mts.map +1 -0
  129. package/internal/utils/env.d.ts +9 -0
  130. package/internal/utils/env.d.ts.map +1 -0
  131. package/internal/utils/env.js +22 -0
  132. package/internal/utils/env.js.map +1 -0
  133. package/internal/utils/env.mjs +18 -0
  134. package/internal/utils/env.mjs.map +1 -0
  135. package/internal/utils/log.d.mts +2 -0
  136. package/internal/utils/log.d.mts.map +1 -0
  137. package/internal/utils/log.d.ts +2 -0
  138. package/internal/utils/log.d.ts.map +1 -0
  139. package/internal/utils/log.js +12 -0
  140. package/internal/utils/log.js.map +1 -0
  141. package/internal/utils/log.mjs +8 -0
  142. package/internal/utils/log.mjs.map +1 -0
  143. package/internal/utils/sleep.d.mts +2 -0
  144. package/internal/utils/sleep.d.mts.map +1 -0
  145. package/internal/utils/sleep.d.ts +2 -0
  146. package/internal/utils/sleep.d.ts.map +1 -0
  147. package/internal/utils/sleep.js +7 -0
  148. package/internal/utils/sleep.js.map +1 -0
  149. package/internal/utils/sleep.mjs +3 -0
  150. package/internal/utils/sleep.mjs.map +1 -0
  151. package/internal/utils/uuid.d.mts +5 -0
  152. package/internal/utils/uuid.d.mts.map +1 -0
  153. package/internal/utils/uuid.d.ts +5 -0
  154. package/internal/utils/uuid.d.ts.map +1 -0
  155. package/internal/utils/uuid.js +15 -0
  156. package/internal/utils/uuid.js.map +1 -0
  157. package/internal/utils/uuid.mjs +11 -0
  158. package/internal/utils/uuid.mjs.map +1 -0
  159. package/internal/utils/values.d.mts +15 -0
  160. package/internal/utils/values.d.mts.map +1 -0
  161. package/internal/utils/values.d.ts +15 -0
  162. package/internal/utils/values.d.ts.map +1 -0
  163. package/internal/utils/values.js +100 -0
  164. package/internal/utils/values.js.map +1 -0
  165. package/internal/utils/values.mjs +84 -0
  166. package/internal/utils/values.mjs.map +1 -0
  167. package/internal/utils.d.mts +7 -0
  168. package/internal/utils.d.mts.map +1 -0
  169. package/internal/utils.d.ts +7 -0
  170. package/internal/utils.d.ts.map +1 -0
  171. package/{_shims/auto/runtime-bun.js → internal/utils.js} +8 -5
  172. package/internal/utils.js.map +1 -0
  173. package/internal/utils.mjs +8 -0
  174. package/internal/utils.mjs.map +1 -0
  175. package/lib/MessageStream.d.mts +95 -0
  176. package/lib/MessageStream.d.mts.map +1 -0
  177. package/lib/MessageStream.d.ts +7 -7
  178. package/lib/MessageStream.d.ts.map +1 -1
  179. package/lib/MessageStream.js +2 -2
  180. package/lib/MessageStream.js.map +1 -1
  181. package/lib/MessageStream.mjs +2 -2
  182. package/lib/MessageStream.mjs.map +1 -1
  183. package/package.json +120 -64
  184. package/pagination.d.mts +63 -0
  185. package/pagination.d.mts.map +1 -0
  186. package/pagination.d.ts +41 -4
  187. package/pagination.d.ts.map +1 -1
  188. package/pagination.js +95 -21
  189. package/pagination.js.map +1 -1
  190. package/pagination.mjs +91 -19
  191. package/pagination.mjs.map +1 -1
  192. package/resource.d.mts +6 -0
  193. package/resource.d.mts.map +1 -0
  194. package/resource.d.ts +3 -3
  195. package/resource.d.ts.map +1 -1
  196. package/resource.js.map +1 -1
  197. package/resource.mjs.map +1 -1
  198. package/resources/beta/beta.d.mts +57 -0
  199. package/resources/beta/beta.d.mts.map +1 -0
  200. package/resources/beta/beta.d.ts +1 -1
  201. package/resources/beta/beta.d.ts.map +1 -1
  202. package/resources/beta/beta.js +0 -1
  203. package/resources/beta/beta.js.map +1 -1
  204. package/resources/beta/beta.mjs +1 -2
  205. package/resources/beta/beta.mjs.map +1 -1
  206. package/resources/beta/index.d.mts +4 -0
  207. package/resources/beta/index.d.mts.map +1 -0
  208. package/resources/beta/index.d.ts +1 -1
  209. package/resources/beta/index.d.ts.map +1 -1
  210. package/resources/beta/index.js +3 -4
  211. package/resources/beta/index.js.map +1 -1
  212. package/resources/beta/index.mjs +1 -1
  213. package/resources/beta/index.mjs.map +1 -1
  214. package/resources/beta/messages/batches.d.mts +261 -0
  215. package/resources/beta/messages/batches.d.mts.map +1 -0
  216. package/resources/beta/messages/batches.d.ts +33 -13
  217. package/resources/beta/messages/batches.d.ts.map +1 -1
  218. package/resources/beta/messages/batches.js +54 -29
  219. package/resources/beta/messages/batches.js.map +1 -1
  220. package/resources/beta/messages/batches.mjs +53 -27
  221. package/resources/beta/messages/batches.mjs.map +1 -1
  222. package/resources/beta/messages/index.d.mts +3 -0
  223. package/resources/beta/messages/index.d.mts.map +1 -0
  224. package/resources/beta/messages/index.d.ts +1 -1
  225. package/resources/beta/messages/index.d.ts.map +1 -1
  226. package/resources/beta/messages/index.js +1 -2
  227. package/resources/beta/messages/index.js.map +1 -1
  228. package/resources/beta/messages/index.mjs +1 -1
  229. package/resources/beta/messages/index.mjs.map +1 -1
  230. package/resources/beta/messages/messages.d.mts +879 -0
  231. package/resources/beta/messages/messages.d.mts.map +1 -0
  232. package/resources/beta/messages/messages.d.ts +8 -8
  233. package/resources/beta/messages/messages.d.ts.map +1 -1
  234. package/resources/beta/messages/messages.js +0 -1
  235. package/resources/beta/messages/messages.js.map +1 -1
  236. package/resources/beta/messages/messages.mjs +1 -2
  237. package/resources/beta/messages/messages.mjs.map +1 -1
  238. package/resources/beta/models.d.mts +48 -0
  239. package/resources/beta/models.d.mts.map +1 -0
  240. package/resources/beta/models.d.ts +7 -8
  241. package/resources/beta/models.d.ts.map +1 -1
  242. package/resources/beta/models.js +10 -12
  243. package/resources/beta/models.js.map +1 -1
  244. package/resources/beta/models.mjs +9 -10
  245. package/resources/beta/models.mjs.map +1 -1
  246. package/resources/completions.d.mts +166 -0
  247. package/resources/completions.d.mts.map +1 -0
  248. package/resources/completions.d.ts +5 -5
  249. package/resources/completions.d.ts.map +1 -1
  250. package/resources/completions.js.map +1 -1
  251. package/resources/completions.mjs.map +1 -1
  252. package/resources/index.d.mts +6 -0
  253. package/resources/index.d.mts.map +1 -0
  254. package/resources/index.d.ts +1 -1
  255. package/resources/index.d.ts.map +1 -1
  256. package/resources/index.js +1 -2
  257. package/resources/index.js.map +1 -1
  258. package/resources/index.mjs +1 -1
  259. package/resources/index.mjs.map +1 -1
  260. package/resources/messages/batches.d.mts +229 -0
  261. package/resources/messages/batches.d.mts.map +1 -0
  262. package/resources/messages/batches.d.ts +27 -10
  263. package/resources/messages/batches.d.ts.map +1 -1
  264. package/resources/messages/batches.js +20 -16
  265. package/resources/messages/batches.js.map +1 -1
  266. package/resources/messages/batches.mjs +19 -14
  267. package/resources/messages/batches.mjs.map +1 -1
  268. package/resources/messages/index.d.mts +3 -0
  269. package/resources/messages/index.d.mts.map +1 -0
  270. package/resources/messages/index.d.ts +1 -1
  271. package/resources/messages/index.d.ts.map +1 -1
  272. package/resources/messages/index.js +1 -2
  273. package/resources/messages/index.js.map +1 -1
  274. package/resources/messages/index.mjs +1 -1
  275. package/resources/messages/index.mjs.map +1 -1
  276. package/resources/messages/messages.d.mts +859 -0
  277. package/resources/messages/messages.d.mts.map +1 -0
  278. package/resources/messages/messages.d.ts +9 -9
  279. package/resources/messages/messages.d.ts.map +1 -1
  280. package/resources/messages/messages.js +0 -1
  281. package/resources/messages/messages.js.map +1 -1
  282. package/resources/messages/messages.mjs +1 -2
  283. package/resources/messages/messages.mjs.map +1 -1
  284. package/resources/models.d.mts +48 -0
  285. package/resources/models.d.mts.map +1 -0
  286. package/resources/models.d.ts +7 -8
  287. package/resources/models.d.ts.map +1 -1
  288. package/resources/models.js +10 -12
  289. package/resources/models.js.map +1 -1
  290. package/resources/models.mjs +9 -10
  291. package/resources/models.mjs.map +1 -1
  292. package/resources/shared.d.mts +42 -0
  293. package/resources/shared.d.mts.map +1 -0
  294. package/resources/top-level.d.mts +2 -0
  295. package/resources/top-level.d.mts.map +1 -0
  296. package/src/api-promise.ts +93 -0
  297. package/src/client.ts +863 -0
  298. package/src/error.ts +3 -3
  299. package/src/index.ts +12 -406
  300. package/src/internal/builtin-types.ts +79 -0
  301. package/src/internal/decoders/jsonl.ts +3 -4
  302. package/src/internal/decoders/line.ts +1 -1
  303. package/src/internal/detect-platform.ts +192 -0
  304. package/src/internal/errors.ts +18 -0
  305. package/src/internal/headers.ts +96 -0
  306. package/src/internal/parse.ts +70 -0
  307. package/src/internal/polyfill/crypto.node.d.ts +10 -0
  308. package/src/internal/polyfill/crypto.node.js +11 -0
  309. package/src/internal/polyfill/crypto.node.mjs +2 -0
  310. package/src/internal/polyfill/file.node.d.ts +9 -0
  311. package/src/internal/polyfill/file.node.js +17 -0
  312. package/src/internal/polyfill/file.node.mjs +9 -0
  313. package/src/internal/request-options.ts +71 -0
  314. package/src/internal/shim-types.d.ts +28 -0
  315. package/src/internal/shims.ts +124 -0
  316. package/src/internal/types.ts +6 -0
  317. package/src/internal/utils/base64.ts +40 -0
  318. package/src/internal/utils/env.ts +20 -0
  319. package/src/internal/utils/log.ts +9 -0
  320. package/src/internal/utils/sleep.ts +3 -0
  321. package/src/internal/utils/uuid.ts +13 -0
  322. package/src/internal/utils/values.ts +94 -0
  323. package/src/internal/utils.ts +8 -0
  324. package/src/lib/MessageStream.ts +9 -9
  325. package/src/pagination.ts +122 -18
  326. package/src/resource.ts +3 -3
  327. package/src/resources/beta/beta.ts +6 -7
  328. package/src/resources/beta/index.ts +3 -3
  329. package/src/resources/beta/messages/batches.ts +76 -74
  330. package/src/resources/beta/messages/index.ts +5 -3
  331. package/src/resources/beta/messages/messages.ts +20 -17
  332. package/src/resources/beta/models.ts +12 -22
  333. package/src/resources/completions.ts +10 -13
  334. package/src/resources/index.ts +5 -5
  335. package/src/resources/messages/batches.ts +46 -32
  336. package/src/resources/messages/index.ts +4 -3
  337. package/src/resources/messages/messages.ts +18 -20
  338. package/src/resources/models.ts +12 -19
  339. package/src/streaming.ts +7 -12
  340. package/src/tsconfig.json +1 -1
  341. package/src/uploads.ts +57 -54
  342. package/src/version.ts +1 -1
  343. package/streaming.d.mts +41 -0
  344. package/streaming.d.mts.map +1 -0
  345. package/streaming.d.ts +1 -1
  346. package/streaming.d.ts.map +1 -1
  347. package/streaming.js +3 -4
  348. package/streaming.js.map +1 -1
  349. package/streaming.mjs +3 -4
  350. package/streaming.mjs.map +1 -1
  351. package/uploads.d.mts +79 -0
  352. package/uploads.d.mts.map +1 -0
  353. package/uploads.d.ts +23 -19
  354. package/uploads.d.ts.map +1 -1
  355. package/uploads.js +33 -27
  356. package/uploads.js.map +1 -1
  357. package/uploads.mjs +29 -21
  358. package/uploads.mjs.map +1 -1
  359. package/version.d.mts +2 -0
  360. package/version.d.mts.map +1 -0
  361. package/version.d.ts +1 -1
  362. package/version.d.ts.map +1 -1
  363. package/version.js +1 -1
  364. package/version.js.map +1 -1
  365. package/version.mjs +1 -1
  366. package/version.mjs.map +1 -1
  367. package/_shims/MultipartBody.d.ts +0 -9
  368. package/_shims/MultipartBody.d.ts.map +0 -1
  369. package/_shims/MultipartBody.js +0 -16
  370. package/_shims/MultipartBody.js.map +0 -1
  371. package/_shims/MultipartBody.mjs +0 -12
  372. package/_shims/MultipartBody.mjs.map +0 -1
  373. package/_shims/README.md +0 -46
  374. package/_shims/auto/runtime-bun.d.ts +0 -5
  375. package/_shims/auto/runtime-bun.d.ts.map +0 -1
  376. package/_shims/auto/runtime-bun.js.map +0 -1
  377. package/_shims/auto/runtime-bun.mjs +0 -2
  378. package/_shims/auto/runtime-bun.mjs.map +0 -1
  379. package/_shims/auto/runtime-node.d.ts +0 -5
  380. package/_shims/auto/runtime-node.d.ts.map +0 -1
  381. package/_shims/auto/runtime-node.js +0 -21
  382. package/_shims/auto/runtime-node.js.map +0 -1
  383. package/_shims/auto/runtime-node.mjs +0 -2
  384. package/_shims/auto/runtime-node.mjs.map +0 -1
  385. package/_shims/auto/runtime.d.ts +0 -5
  386. package/_shims/auto/runtime.d.ts.map +0 -1
  387. package/_shims/auto/runtime.js +0 -21
  388. package/_shims/auto/runtime.js.map +0 -1
  389. package/_shims/auto/runtime.mjs +0 -2
  390. package/_shims/auto/runtime.mjs.map +0 -1
  391. package/_shims/auto/types-node.d.ts +0 -5
  392. package/_shims/auto/types-node.d.ts.map +0 -1
  393. package/_shims/auto/types-node.js +0 -21
  394. package/_shims/auto/types-node.js.map +0 -1
  395. package/_shims/auto/types-node.mjs +0 -2
  396. package/_shims/auto/types-node.mjs.map +0 -1
  397. package/_shims/auto/types.d.ts +0 -101
  398. package/_shims/auto/types.js +0 -3
  399. package/_shims/auto/types.mjs +0 -3
  400. package/_shims/bun-runtime.d.ts +0 -6
  401. package/_shims/bun-runtime.d.ts.map +0 -1
  402. package/_shims/bun-runtime.js +0 -14
  403. package/_shims/bun-runtime.js.map +0 -1
  404. package/_shims/bun-runtime.mjs +0 -10
  405. package/_shims/bun-runtime.mjs.map +0 -1
  406. package/_shims/index.d.ts +0 -81
  407. package/_shims/index.js +0 -13
  408. package/_shims/index.mjs +0 -7
  409. package/_shims/manual-types.d.ts +0 -12
  410. package/_shims/manual-types.js +0 -3
  411. package/_shims/manual-types.mjs +0 -3
  412. package/_shims/node-runtime.d.ts +0 -3
  413. package/_shims/node-runtime.d.ts.map +0 -1
  414. package/_shims/node-runtime.js +0 -89
  415. package/_shims/node-runtime.js.map +0 -1
  416. package/_shims/node-runtime.mjs +0 -56
  417. package/_shims/node-runtime.mjs.map +0 -1
  418. package/_shims/node-types.d.ts +0 -42
  419. package/_shims/node-types.js +0 -3
  420. package/_shims/node-types.mjs +0 -3
  421. package/_shims/registry.d.ts +0 -37
  422. package/_shims/registry.d.ts.map +0 -1
  423. package/_shims/registry.js +0 -41
  424. package/_shims/registry.js.map +0 -1
  425. package/_shims/registry.mjs +0 -37
  426. package/_shims/registry.mjs.map +0 -1
  427. package/_shims/web-runtime.d.ts +0 -5
  428. package/_shims/web-runtime.d.ts.map +0 -1
  429. package/_shims/web-runtime.js +0 -78
  430. package/_shims/web-runtime.js.map +0 -1
  431. package/_shims/web-runtime.mjs +0 -71
  432. package/_shims/web-runtime.mjs.map +0 -1
  433. package/_shims/web-types.d.ts +0 -83
  434. package/_shims/web-types.js +0 -3
  435. package/_shims/web-types.mjs +0 -3
  436. package/core.d.ts +0 -248
  437. package/core.d.ts.map +0 -1
  438. package/core.js +0 -920
  439. package/core.js.map +0 -1
  440. package/core.mjs +0 -888
  441. package/core.mjs.map +0 -1
  442. package/shims/node.d.ts +0 -30
  443. package/shims/node.d.ts.map +0 -1
  444. package/shims/node.js +0 -31
  445. package/shims/node.js.map +0 -1
  446. package/shims/node.mjs +0 -5
  447. package/shims/node.mjs.map +0 -1
  448. package/shims/web.d.ts +0 -26
  449. package/shims/web.d.ts.map +0 -1
  450. package/shims/web.js +0 -31
  451. package/shims/web.js.map +0 -1
  452. package/shims/web.mjs +0 -5
  453. package/shims/web.mjs.map +0 -1
  454. package/src/_shims/MultipartBody.ts +0 -9
  455. package/src/_shims/README.md +0 -46
  456. package/src/_shims/auto/runtime-bun.ts +0 -4
  457. package/src/_shims/auto/runtime-node.ts +0 -4
  458. package/src/_shims/auto/runtime.ts +0 -4
  459. package/src/_shims/auto/types-node.ts +0 -4
  460. package/src/_shims/auto/types.d.ts +0 -101
  461. package/src/_shims/auto/types.js +0 -3
  462. package/src/_shims/auto/types.mjs +0 -3
  463. package/src/_shims/bun-runtime.ts +0 -14
  464. package/src/_shims/index.d.ts +0 -81
  465. package/src/_shims/index.js +0 -13
  466. package/src/_shims/index.mjs +0 -7
  467. package/src/_shims/manual-types.d.ts +0 -12
  468. package/src/_shims/manual-types.js +0 -3
  469. package/src/_shims/manual-types.mjs +0 -3
  470. package/src/_shims/node-runtime.ts +0 -81
  471. package/src/_shims/node-types.d.ts +0 -42
  472. package/src/_shims/node-types.js +0 -3
  473. package/src/_shims/node-types.mjs +0 -3
  474. package/src/_shims/registry.ts +0 -67
  475. package/src/_shims/web-runtime.ts +0 -103
  476. package/src/_shims/web-types.d.ts +0 -83
  477. package/src/_shims/web-types.js +0 -3
  478. package/src/_shims/web-types.mjs +0 -3
  479. package/src/core.ts +0 -1232
  480. package/src/shims/node.ts +0 -50
  481. package/src/shims/web.ts +0 -50
@@ -0,0 +1,879 @@
1
+ import { APIResource } from "../../../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 "../../../api-promise.mjs";
8
+ import { Stream } from "../../../streaming.mjs";
9
+ import { RequestOptions } from "../../../internal/request-options.mjs";
10
+ export declare class Messages extends APIResource {
11
+ batches: BatchesAPI.Batches;
12
+ /**
13
+ * Send a structured list of input messages with text and/or image content, and the
14
+ * model will generate the next message in the conversation.
15
+ *
16
+ * The Messages API can be used for either single queries or stateless multi-turn
17
+ * conversations.
18
+ */
19
+ create(params: MessageCreateParamsNonStreaming, options?: RequestOptions): APIPromise<BetaMessage>;
20
+ create(params: MessageCreateParamsStreaming, options?: RequestOptions): APIPromise<Stream<BetaRawMessageStreamEvent>>;
21
+ create(params: MessageCreateParamsBase, options?: RequestOptions): APIPromise<Stream<BetaRawMessageStreamEvent> | BetaMessage>;
22
+ /**
23
+ * Count the number of tokens in a Message.
24
+ *
25
+ * The Token Count API can be used to count the number of tokens in a Message,
26
+ * including tools, images, and documents, without creating it.
27
+ */
28
+ countTokens(params: MessageCountTokensParams, options?: RequestOptions): APIPromise<BetaMessageTokensCount>;
29
+ }
30
+ export interface BetaBase64PDFBlock {
31
+ source: BetaBase64PDFSource;
32
+ type: 'document';
33
+ cache_control?: BetaCacheControlEphemeral | null;
34
+ }
35
+ export interface BetaBase64PDFSource {
36
+ data: string;
37
+ media_type: 'application/pdf';
38
+ type: 'base64';
39
+ }
40
+ export interface BetaCacheControlEphemeral {
41
+ type: 'ephemeral';
42
+ }
43
+ export type BetaContentBlock = BetaTextBlock | BetaToolUseBlock;
44
+ export type BetaContentBlockParam = BetaTextBlockParam | BetaImageBlockParam | BetaToolUseBlockParam | BetaToolResultBlockParam | BetaBase64PDFBlock;
45
+ export interface BetaImageBlockParam {
46
+ source: BetaImageBlockParam.Source;
47
+ type: 'image';
48
+ cache_control?: BetaCacheControlEphemeral | null;
49
+ }
50
+ export declare namespace BetaImageBlockParam {
51
+ interface Source {
52
+ data: string;
53
+ media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
54
+ type: 'base64';
55
+ }
56
+ }
57
+ export interface BetaInputJSONDelta {
58
+ partial_json: string;
59
+ type: 'input_json_delta';
60
+ }
61
+ export interface BetaMessage {
62
+ /**
63
+ * Unique object identifier.
64
+ *
65
+ * The format and length of IDs may change over time.
66
+ */
67
+ id: string;
68
+ /**
69
+ * Content generated by the model.
70
+ *
71
+ * This is an array of content blocks, each of which has a `type` that determines
72
+ * its shape.
73
+ *
74
+ * Example:
75
+ *
76
+ * ```json
77
+ * [{ "type": "text", "text": "Hi, I'm Claude." }]
78
+ * ```
79
+ *
80
+ * If the request input `messages` ended with an `assistant` turn, then the
81
+ * response `content` will continue directly from that last turn. You can use this
82
+ * to constrain the model's output.
83
+ *
84
+ * For example, if the input `messages` were:
85
+ *
86
+ * ```json
87
+ * [
88
+ * {
89
+ * "role": "user",
90
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
91
+ * },
92
+ * { "role": "assistant", "content": "The best answer is (" }
93
+ * ]
94
+ * ```
95
+ *
96
+ * Then the response `content` might be:
97
+ *
98
+ * ```json
99
+ * [{ "type": "text", "text": "B)" }]
100
+ * ```
101
+ */
102
+ content: Array<BetaContentBlock>;
103
+ /**
104
+ * The model that will complete your prompt.\n\nSee
105
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
106
+ * details and options.
107
+ */
108
+ model: MessagesAPI.Model;
109
+ /**
110
+ * Conversational role of the generated message.
111
+ *
112
+ * This will always be `"assistant"`.
113
+ */
114
+ role: 'assistant';
115
+ /**
116
+ * The reason that we stopped.
117
+ *
118
+ * This may be one the following values:
119
+ *
120
+ * - `"end_turn"`: the model reached a natural stopping point
121
+ * - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
122
+ * - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
123
+ * - `"tool_use"`: the model invoked one or more tools
124
+ *
125
+ * In non-streaming mode this value is always non-null. In streaming mode, it is
126
+ * null in the `message_start` event and non-null otherwise.
127
+ */
128
+ stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null;
129
+ /**
130
+ * Which custom stop sequence was generated, if any.
131
+ *
132
+ * This value will be a non-null string if one of your custom stop sequences was
133
+ * generated.
134
+ */
135
+ stop_sequence: string | null;
136
+ /**
137
+ * Object type.
138
+ *
139
+ * For Messages, this is always `"message"`.
140
+ */
141
+ type: 'message';
142
+ /**
143
+ * Billing and rate-limit usage.
144
+ *
145
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
146
+ * underlying cost to our systems.
147
+ *
148
+ * Under the hood, the API transforms requests into a format suitable for the
149
+ * model. The model's output then goes through a parsing stage before becoming an
150
+ * API response. As a result, the token counts in `usage` will not match one-to-one
151
+ * with the exact visible content of an API request or response.
152
+ *
153
+ * For example, `output_tokens` will be non-zero, even for an empty string response
154
+ * from Claude.
155
+ */
156
+ usage: BetaUsage;
157
+ }
158
+ export interface BetaMessageDeltaUsage {
159
+ /**
160
+ * The cumulative number of output tokens which were used.
161
+ */
162
+ output_tokens: number;
163
+ }
164
+ export interface BetaMessageParam {
165
+ content: string | Array<BetaContentBlockParam>;
166
+ role: 'user' | 'assistant';
167
+ }
168
+ export interface BetaMessageTokensCount {
169
+ /**
170
+ * The total number of tokens across the provided list of messages, system prompt,
171
+ * and tools.
172
+ */
173
+ input_tokens: number;
174
+ }
175
+ export interface BetaMetadata {
176
+ /**
177
+ * An external identifier for the user who is associated with the request.
178
+ *
179
+ * This should be a uuid, hash value, or other opaque identifier. Anthropic may use
180
+ * this id to help detect abuse. Do not include any identifying information such as
181
+ * name, email address, or phone number.
182
+ */
183
+ user_id?: string | null;
184
+ }
185
+ export interface BetaRawContentBlockDeltaEvent {
186
+ delta: BetaTextDelta | BetaInputJSONDelta;
187
+ index: number;
188
+ type: 'content_block_delta';
189
+ }
190
+ export interface BetaRawContentBlockStartEvent {
191
+ content_block: BetaTextBlock | BetaToolUseBlock;
192
+ index: number;
193
+ type: 'content_block_start';
194
+ }
195
+ export interface BetaRawContentBlockStopEvent {
196
+ index: number;
197
+ type: 'content_block_stop';
198
+ }
199
+ export interface BetaRawMessageDeltaEvent {
200
+ delta: BetaRawMessageDeltaEvent.Delta;
201
+ type: 'message_delta';
202
+ /**
203
+ * Billing and rate-limit usage.
204
+ *
205
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
206
+ * underlying cost to our systems.
207
+ *
208
+ * Under the hood, the API transforms requests into a format suitable for the
209
+ * model. The model's output then goes through a parsing stage before becoming an
210
+ * API response. As a result, the token counts in `usage` will not match one-to-one
211
+ * with the exact visible content of an API request or response.
212
+ *
213
+ * For example, `output_tokens` will be non-zero, even for an empty string response
214
+ * from Claude.
215
+ */
216
+ usage: BetaMessageDeltaUsage;
217
+ }
218
+ export declare namespace BetaRawMessageDeltaEvent {
219
+ interface Delta {
220
+ stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null;
221
+ stop_sequence: string | null;
222
+ }
223
+ }
224
+ export interface BetaRawMessageStartEvent {
225
+ message: BetaMessage;
226
+ type: 'message_start';
227
+ }
228
+ export interface BetaRawMessageStopEvent {
229
+ type: 'message_stop';
230
+ }
231
+ export type BetaRawMessageStreamEvent = BetaRawMessageStartEvent | BetaRawMessageDeltaEvent | BetaRawMessageStopEvent | BetaRawContentBlockStartEvent | BetaRawContentBlockDeltaEvent | BetaRawContentBlockStopEvent;
232
+ export interface BetaTextBlock {
233
+ text: string;
234
+ type: 'text';
235
+ }
236
+ export interface BetaTextBlockParam {
237
+ text: string;
238
+ type: 'text';
239
+ cache_control?: BetaCacheControlEphemeral | null;
240
+ }
241
+ export interface BetaTextDelta {
242
+ text: string;
243
+ type: 'text_delta';
244
+ }
245
+ export interface BetaTool {
246
+ /**
247
+ * [JSON schema](https://json-schema.org/) for this tool's input.
248
+ *
249
+ * This defines the shape of the `input` that your tool accepts and that the model
250
+ * will produce.
251
+ */
252
+ input_schema: BetaTool.InputSchema;
253
+ /**
254
+ * Name of the tool.
255
+ *
256
+ * This is how the tool will be called by the model and in tool_use blocks.
257
+ */
258
+ name: string;
259
+ cache_control?: BetaCacheControlEphemeral | null;
260
+ /**
261
+ * Description of what this tool does.
262
+ *
263
+ * Tool descriptions should be as detailed as possible. The more information that
264
+ * the model has about what the tool is and how to use it, the better it will
265
+ * perform. You can use natural language descriptions to reinforce important
266
+ * aspects of the tool input JSON schema.
267
+ */
268
+ description?: string;
269
+ type?: 'custom' | null;
270
+ }
271
+ export declare namespace BetaTool {
272
+ /**
273
+ * [JSON schema](https://json-schema.org/) for this tool's input.
274
+ *
275
+ * This defines the shape of the `input` that your tool accepts and that the model
276
+ * will produce.
277
+ */
278
+ interface InputSchema {
279
+ type: 'object';
280
+ properties?: unknown | null;
281
+ [k: string]: unknown;
282
+ }
283
+ }
284
+ export interface BetaToolBash20241022 {
285
+ /**
286
+ * Name of the tool.
287
+ *
288
+ * This is how the tool will be called by the model and in tool_use blocks.
289
+ */
290
+ name: 'bash';
291
+ type: 'bash_20241022';
292
+ cache_control?: BetaCacheControlEphemeral | null;
293
+ }
294
+ /**
295
+ * How the model should use the provided tools. The model can use a specific tool,
296
+ * any available tool, or decide by itself.
297
+ */
298
+ export type BetaToolChoice = BetaToolChoiceAuto | BetaToolChoiceAny | BetaToolChoiceTool;
299
+ /**
300
+ * The model will use any available tools.
301
+ */
302
+ export interface BetaToolChoiceAny {
303
+ type: 'any';
304
+ /**
305
+ * Whether to disable parallel tool use.
306
+ *
307
+ * Defaults to `false`. If set to `true`, the model will output exactly one tool
308
+ * use.
309
+ */
310
+ disable_parallel_tool_use?: boolean;
311
+ }
312
+ /**
313
+ * The model will automatically decide whether to use tools.
314
+ */
315
+ export interface BetaToolChoiceAuto {
316
+ type: 'auto';
317
+ /**
318
+ * Whether to disable parallel tool use.
319
+ *
320
+ * Defaults to `false`. If set to `true`, the model will output at most one tool
321
+ * use.
322
+ */
323
+ disable_parallel_tool_use?: boolean;
324
+ }
325
+ /**
326
+ * The model will use the specified tool with `tool_choice.name`.
327
+ */
328
+ export interface BetaToolChoiceTool {
329
+ /**
330
+ * The name of the tool to use.
331
+ */
332
+ name: string;
333
+ type: 'tool';
334
+ /**
335
+ * Whether to disable parallel tool use.
336
+ *
337
+ * Defaults to `false`. If set to `true`, the model will output exactly one tool
338
+ * use.
339
+ */
340
+ disable_parallel_tool_use?: boolean;
341
+ }
342
+ export interface BetaToolComputerUse20241022 {
343
+ /**
344
+ * The height of the display in pixels.
345
+ */
346
+ display_height_px: number;
347
+ /**
348
+ * The width of the display in pixels.
349
+ */
350
+ display_width_px: number;
351
+ /**
352
+ * Name of the tool.
353
+ *
354
+ * This is how the tool will be called by the model and in tool_use blocks.
355
+ */
356
+ name: 'computer';
357
+ type: 'computer_20241022';
358
+ cache_control?: BetaCacheControlEphemeral | null;
359
+ /**
360
+ * The X11 display number (e.g. 0, 1) for the display.
361
+ */
362
+ display_number?: number | null;
363
+ }
364
+ export interface BetaToolResultBlockParam {
365
+ tool_use_id: string;
366
+ type: 'tool_result';
367
+ cache_control?: BetaCacheControlEphemeral | null;
368
+ content?: string | Array<BetaTextBlockParam | BetaImageBlockParam>;
369
+ is_error?: boolean;
370
+ }
371
+ export interface BetaToolTextEditor20241022 {
372
+ /**
373
+ * Name of the tool.
374
+ *
375
+ * This is how the tool will be called by the model and in tool_use blocks.
376
+ */
377
+ name: 'str_replace_editor';
378
+ type: 'text_editor_20241022';
379
+ cache_control?: BetaCacheControlEphemeral | null;
380
+ }
381
+ export type BetaToolUnion = BetaTool | BetaToolComputerUse20241022 | BetaToolBash20241022 | BetaToolTextEditor20241022;
382
+ export interface BetaToolUseBlock {
383
+ id: string;
384
+ input: unknown;
385
+ name: string;
386
+ type: 'tool_use';
387
+ }
388
+ export interface BetaToolUseBlockParam {
389
+ id: string;
390
+ input: unknown;
391
+ name: string;
392
+ type: 'tool_use';
393
+ cache_control?: BetaCacheControlEphemeral | null;
394
+ }
395
+ export interface BetaUsage {
396
+ /**
397
+ * The number of input tokens used to create the cache entry.
398
+ */
399
+ cache_creation_input_tokens: number | null;
400
+ /**
401
+ * The number of input tokens read from the cache.
402
+ */
403
+ cache_read_input_tokens: number | null;
404
+ /**
405
+ * The number of input tokens which were used.
406
+ */
407
+ input_tokens: number;
408
+ /**
409
+ * The number of output tokens which were used.
410
+ */
411
+ output_tokens: number;
412
+ }
413
+ export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
414
+ export interface MessageCreateParamsBase {
415
+ /**
416
+ * Body param: The maximum number of tokens to generate before stopping.
417
+ *
418
+ * Note that our models may stop _before_ reaching this maximum. This parameter
419
+ * only specifies the absolute maximum number of tokens to generate.
420
+ *
421
+ * Different models have different maximum values for this parameter. See
422
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for details.
423
+ */
424
+ max_tokens: number;
425
+ /**
426
+ * Body param: Input messages.
427
+ *
428
+ * Our models are trained to operate on alternating `user` and `assistant`
429
+ * conversational turns. When creating a new `Message`, you specify the prior
430
+ * conversational turns with the `messages` parameter, and the model then generates
431
+ * the next `Message` in the conversation. Consecutive `user` or `assistant` turns
432
+ * in your request will be combined into a single turn.
433
+ *
434
+ * Each input message must be an object with a `role` and `content`. You can
435
+ * specify a single `user`-role message, or you can include multiple `user` and
436
+ * `assistant` messages.
437
+ *
438
+ * If the final message uses the `assistant` role, the response content will
439
+ * continue immediately from the content in that message. This can be used to
440
+ * constrain part of the model's response.
441
+ *
442
+ * Example with a single `user` message:
443
+ *
444
+ * ```json
445
+ * [{ "role": "user", "content": "Hello, Claude" }]
446
+ * ```
447
+ *
448
+ * Example with multiple conversational turns:
449
+ *
450
+ * ```json
451
+ * [
452
+ * { "role": "user", "content": "Hello there." },
453
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
454
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
455
+ * ]
456
+ * ```
457
+ *
458
+ * Example with a partially-filled response from Claude:
459
+ *
460
+ * ```json
461
+ * [
462
+ * {
463
+ * "role": "user",
464
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
465
+ * },
466
+ * { "role": "assistant", "content": "The best answer is (" }
467
+ * ]
468
+ * ```
469
+ *
470
+ * Each input message `content` may be either a single `string` or an array of
471
+ * content blocks, where each block has a specific `type`. Using a `string` for
472
+ * `content` is shorthand for an array of one content block of type `"text"`. The
473
+ * following input messages are equivalent:
474
+ *
475
+ * ```json
476
+ * { "role": "user", "content": "Hello, Claude" }
477
+ * ```
478
+ *
479
+ * ```json
480
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
481
+ * ```
482
+ *
483
+ * Starting with Claude 3 models, you can also send image content blocks:
484
+ *
485
+ * ```json
486
+ * {
487
+ * "role": "user",
488
+ * "content": [
489
+ * {
490
+ * "type": "image",
491
+ * "source": {
492
+ * "type": "base64",
493
+ * "media_type": "image/jpeg",
494
+ * "data": "/9j/4AAQSkZJRg..."
495
+ * }
496
+ * },
497
+ * { "type": "text", "text": "What is in this image?" }
498
+ * ]
499
+ * }
500
+ * ```
501
+ *
502
+ * We currently support the `base64` source type for images, and the `image/jpeg`,
503
+ * `image/png`, `image/gif`, and `image/webp` media types.
504
+ *
505
+ * See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
506
+ * more input examples.
507
+ *
508
+ * Note that if you want to include a
509
+ * [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
510
+ * the top-level `system` parameter — there is no `"system"` role for input
511
+ * messages in the Messages API.
512
+ */
513
+ messages: Array<BetaMessageParam>;
514
+ /**
515
+ * Body param: The model that will complete your prompt.\n\nSee
516
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
517
+ * details and options.
518
+ */
519
+ model: MessagesAPI.Model;
520
+ /**
521
+ * Body param: An object describing metadata about the request.
522
+ */
523
+ metadata?: BetaMetadata;
524
+ /**
525
+ * Body param: Custom text sequences that will cause the model to stop generating.
526
+ *
527
+ * Our models will normally stop when they have naturally completed their turn,
528
+ * which will result in a response `stop_reason` of `"end_turn"`.
529
+ *
530
+ * If you want the model to stop generating when it encounters custom strings of
531
+ * text, you can use the `stop_sequences` parameter. If the model encounters one of
532
+ * the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
533
+ * and the response `stop_sequence` value will contain the matched stop sequence.
534
+ */
535
+ stop_sequences?: Array<string>;
536
+ /**
537
+ * Body param: Whether to incrementally stream the response using server-sent
538
+ * events.
539
+ *
540
+ * See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
541
+ * details.
542
+ */
543
+ stream?: boolean;
544
+ /**
545
+ * Body param: System prompt.
546
+ *
547
+ * A system prompt is a way of providing context and instructions to Claude, such
548
+ * as specifying a particular goal or role. See our
549
+ * [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
550
+ */
551
+ system?: string | Array<BetaTextBlockParam>;
552
+ /**
553
+ * Body param: Amount of randomness injected into the response.
554
+ *
555
+ * Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
556
+ * for analytical / multiple choice, and closer to `1.0` for creative and
557
+ * generative tasks.
558
+ *
559
+ * Note that even with `temperature` of `0.0`, the results will not be fully
560
+ * deterministic.
561
+ */
562
+ temperature?: number;
563
+ /**
564
+ * Body param: How the model should use the provided tools. The model can use a
565
+ * specific tool, any available tool, or decide by itself.
566
+ */
567
+ tool_choice?: BetaToolChoice;
568
+ /**
569
+ * Body param: Definitions of tools that the model may use.
570
+ *
571
+ * If you include `tools` in your API request, the model may return `tool_use`
572
+ * content blocks that represent the model's use of those tools. You can then run
573
+ * those tools using the tool input generated by the model and then optionally
574
+ * return results back to the model using `tool_result` content blocks.
575
+ *
576
+ * Each tool definition includes:
577
+ *
578
+ * - `name`: Name of the tool.
579
+ * - `description`: Optional, but strongly-recommended description of the tool.
580
+ * - `input_schema`: [JSON schema](https://json-schema.org/) for the tool `input`
581
+ * shape that the model will produce in `tool_use` output content blocks.
582
+ *
583
+ * For example, if you defined `tools` as:
584
+ *
585
+ * ```json
586
+ * [
587
+ * {
588
+ * "name": "get_stock_price",
589
+ * "description": "Get the current stock price for a given ticker symbol.",
590
+ * "input_schema": {
591
+ * "type": "object",
592
+ * "properties": {
593
+ * "ticker": {
594
+ * "type": "string",
595
+ * "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
596
+ * }
597
+ * },
598
+ * "required": ["ticker"]
599
+ * }
600
+ * }
601
+ * ]
602
+ * ```
603
+ *
604
+ * And then asked the model "What's the S&P 500 at today?", the model might produce
605
+ * `tool_use` content blocks in the response like this:
606
+ *
607
+ * ```json
608
+ * [
609
+ * {
610
+ * "type": "tool_use",
611
+ * "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
612
+ * "name": "get_stock_price",
613
+ * "input": { "ticker": "^GSPC" }
614
+ * }
615
+ * ]
616
+ * ```
617
+ *
618
+ * You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
619
+ * input, and return the following back to the model in a subsequent `user`
620
+ * message:
621
+ *
622
+ * ```json
623
+ * [
624
+ * {
625
+ * "type": "tool_result",
626
+ * "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
627
+ * "content": "259.75 USD"
628
+ * }
629
+ * ]
630
+ * ```
631
+ *
632
+ * Tools can be used for workflows that include running client-side tools and
633
+ * functions, or more generally whenever you want the model to produce a particular
634
+ * JSON structure of output.
635
+ *
636
+ * See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
637
+ */
638
+ tools?: Array<BetaToolUnion>;
639
+ /**
640
+ * Body param: Only sample from the top K options for each subsequent token.
641
+ *
642
+ * Used to remove "long tail" low probability responses.
643
+ * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
644
+ *
645
+ * Recommended for advanced use cases only. You usually only need to use
646
+ * `temperature`.
647
+ */
648
+ top_k?: number;
649
+ /**
650
+ * Body param: Use nucleus sampling.
651
+ *
652
+ * In nucleus sampling, we compute the cumulative distribution over all the options
653
+ * for each subsequent token in decreasing probability order and cut it off once it
654
+ * reaches a particular probability specified by `top_p`. You should either alter
655
+ * `temperature` or `top_p`, but not both.
656
+ *
657
+ * Recommended for advanced use cases only. You usually only need to use
658
+ * `temperature`.
659
+ */
660
+ top_p?: number;
661
+ /**
662
+ * Header param: Optional header to specify the beta version(s) you want to use.
663
+ */
664
+ betas?: Array<BetaAPI.AnthropicBeta>;
665
+ }
666
+ export declare namespace MessageCreateParams {
667
+ type MessageCreateParamsNonStreaming = MessagesMessagesAPI.MessageCreateParamsNonStreaming;
668
+ type MessageCreateParamsStreaming = MessagesMessagesAPI.MessageCreateParamsStreaming;
669
+ }
670
+ export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase {
671
+ /**
672
+ * Body param: Whether to incrementally stream the response using server-sent
673
+ * events.
674
+ *
675
+ * See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
676
+ * details.
677
+ */
678
+ stream?: false;
679
+ }
680
+ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
681
+ /**
682
+ * Body param: Whether to incrementally stream the response using server-sent
683
+ * events.
684
+ *
685
+ * See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
686
+ * details.
687
+ */
688
+ stream: true;
689
+ }
690
+ export interface MessageCountTokensParams {
691
+ /**
692
+ * Body param: Input messages.
693
+ *
694
+ * Our models are trained to operate on alternating `user` and `assistant`
695
+ * conversational turns. When creating a new `Message`, you specify the prior
696
+ * conversational turns with the `messages` parameter, and the model then generates
697
+ * the next `Message` in the conversation. Consecutive `user` or `assistant` turns
698
+ * in your request will be combined into a single turn.
699
+ *
700
+ * Each input message must be an object with a `role` and `content`. You can
701
+ * specify a single `user`-role message, or you can include multiple `user` and
702
+ * `assistant` messages.
703
+ *
704
+ * If the final message uses the `assistant` role, the response content will
705
+ * continue immediately from the content in that message. This can be used to
706
+ * constrain part of the model's response.
707
+ *
708
+ * Example with a single `user` message:
709
+ *
710
+ * ```json
711
+ * [{ "role": "user", "content": "Hello, Claude" }]
712
+ * ```
713
+ *
714
+ * Example with multiple conversational turns:
715
+ *
716
+ * ```json
717
+ * [
718
+ * { "role": "user", "content": "Hello there." },
719
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
720
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
721
+ * ]
722
+ * ```
723
+ *
724
+ * Example with a partially-filled response from Claude:
725
+ *
726
+ * ```json
727
+ * [
728
+ * {
729
+ * "role": "user",
730
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
731
+ * },
732
+ * { "role": "assistant", "content": "The best answer is (" }
733
+ * ]
734
+ * ```
735
+ *
736
+ * Each input message `content` may be either a single `string` or an array of
737
+ * content blocks, where each block has a specific `type`. Using a `string` for
738
+ * `content` is shorthand for an array of one content block of type `"text"`. The
739
+ * following input messages are equivalent:
740
+ *
741
+ * ```json
742
+ * { "role": "user", "content": "Hello, Claude" }
743
+ * ```
744
+ *
745
+ * ```json
746
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
747
+ * ```
748
+ *
749
+ * Starting with Claude 3 models, you can also send image content blocks:
750
+ *
751
+ * ```json
752
+ * {
753
+ * "role": "user",
754
+ * "content": [
755
+ * {
756
+ * "type": "image",
757
+ * "source": {
758
+ * "type": "base64",
759
+ * "media_type": "image/jpeg",
760
+ * "data": "/9j/4AAQSkZJRg..."
761
+ * }
762
+ * },
763
+ * { "type": "text", "text": "What is in this image?" }
764
+ * ]
765
+ * }
766
+ * ```
767
+ *
768
+ * We currently support the `base64` source type for images, and the `image/jpeg`,
769
+ * `image/png`, `image/gif`, and `image/webp` media types.
770
+ *
771
+ * See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
772
+ * more input examples.
773
+ *
774
+ * Note that if you want to include a
775
+ * [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
776
+ * the top-level `system` parameter — there is no `"system"` role for input
777
+ * messages in the Messages API.
778
+ */
779
+ messages: Array<BetaMessageParam>;
780
+ /**
781
+ * Body param: The model that will complete your prompt.\n\nSee
782
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
783
+ * details and options.
784
+ */
785
+ model: MessagesAPI.Model;
786
+ /**
787
+ * Body param: System prompt.
788
+ *
789
+ * A system prompt is a way of providing context and instructions to Claude, such
790
+ * as specifying a particular goal or role. See our
791
+ * [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
792
+ */
793
+ system?: string | Array<BetaTextBlockParam>;
794
+ /**
795
+ * Body param: How the model should use the provided tools. The model can use a
796
+ * specific tool, any available tool, or decide by itself.
797
+ */
798
+ tool_choice?: BetaToolChoice;
799
+ /**
800
+ * Body param: Definitions of tools that the model may use.
801
+ *
802
+ * If you include `tools` in your API request, the model may return `tool_use`
803
+ * content blocks that represent the model's use of those tools. You can then run
804
+ * those tools using the tool input generated by the model and then optionally
805
+ * return results back to the model using `tool_result` content blocks.
806
+ *
807
+ * Each tool definition includes:
808
+ *
809
+ * - `name`: Name of the tool.
810
+ * - `description`: Optional, but strongly-recommended description of the tool.
811
+ * - `input_schema`: [JSON schema](https://json-schema.org/) for the tool `input`
812
+ * shape that the model will produce in `tool_use` output content blocks.
813
+ *
814
+ * For example, if you defined `tools` as:
815
+ *
816
+ * ```json
817
+ * [
818
+ * {
819
+ * "name": "get_stock_price",
820
+ * "description": "Get the current stock price for a given ticker symbol.",
821
+ * "input_schema": {
822
+ * "type": "object",
823
+ * "properties": {
824
+ * "ticker": {
825
+ * "type": "string",
826
+ * "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
827
+ * }
828
+ * },
829
+ * "required": ["ticker"]
830
+ * }
831
+ * }
832
+ * ]
833
+ * ```
834
+ *
835
+ * And then asked the model "What's the S&P 500 at today?", the model might produce
836
+ * `tool_use` content blocks in the response like this:
837
+ *
838
+ * ```json
839
+ * [
840
+ * {
841
+ * "type": "tool_use",
842
+ * "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
843
+ * "name": "get_stock_price",
844
+ * "input": { "ticker": "^GSPC" }
845
+ * }
846
+ * ]
847
+ * ```
848
+ *
849
+ * You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
850
+ * input, and return the following back to the model in a subsequent `user`
851
+ * message:
852
+ *
853
+ * ```json
854
+ * [
855
+ * {
856
+ * "type": "tool_result",
857
+ * "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
858
+ * "content": "259.75 USD"
859
+ * }
860
+ * ]
861
+ * ```
862
+ *
863
+ * Tools can be used for workflows that include running client-side tools and
864
+ * functions, or more generally whenever you want the model to produce a particular
865
+ * JSON structure of output.
866
+ *
867
+ * See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
868
+ */
869
+ tools?: Array<BetaTool | BetaToolComputerUse20241022 | BetaToolBash20241022 | BetaToolTextEditor20241022>;
870
+ /**
871
+ * Header param: Optional header to specify the beta version(s) you want to use.
872
+ */
873
+ betas?: Array<BetaAPI.AnthropicBeta>;
874
+ }
875
+ export declare namespace Messages {
876
+ export { type BetaBase64PDFBlock as BetaBase64PDFBlock, type BetaBase64PDFSource as BetaBase64PDFSource, type BetaCacheControlEphemeral as BetaCacheControlEphemeral, type BetaContentBlock as BetaContentBlock, type BetaContentBlockParam as BetaContentBlockParam, 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 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 BetaTextBlock as BetaTextBlock, type BetaTextBlockParam as BetaTextBlockParam, type BetaTextDelta as BetaTextDelta, type BetaTool as BetaTool, type BetaToolBash20241022 as BetaToolBash20241022, type BetaToolChoice as BetaToolChoice, type BetaToolChoiceAny as BetaToolChoiceAny, type BetaToolChoiceAuto as BetaToolChoiceAuto, type BetaToolChoiceTool as BetaToolChoiceTool, type BetaToolComputerUse20241022 as BetaToolComputerUse20241022, type BetaToolResultBlockParam as BetaToolResultBlockParam, type BetaToolTextEditor20241022 as BetaToolTextEditor20241022, type BetaToolUnion as BetaToolUnion, type BetaToolUseBlock as BetaToolUseBlock, type BetaToolUseBlockParam as BetaToolUseBlockParam, type BetaUsage as BetaUsage, type MessageCreateParams as MessageCreateParams, type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming, type MessageCreateParamsStreaming as MessageCreateParamsStreaming, type MessageCountTokensParams as MessageCountTokensParams, };
877
+ 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, };
878
+ }
879
+ //# sourceMappingURL=messages.d.mts.map