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