anthropic 1.1.1 → 1.6.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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +123 -0
  3. data/README.md +32 -16
  4. data/lib/anthropic/client.rb +5 -2
  5. data/lib/anthropic/errors.rb +22 -0
  6. data/lib/anthropic/helpers/bedrock/client.rb +34 -4
  7. data/lib/anthropic/helpers/streaming/events.rb +141 -0
  8. data/lib/anthropic/helpers/streaming/message_stream.rb +238 -0
  9. data/lib/anthropic/helpers/streaming.rb +37 -0
  10. data/lib/anthropic/helpers/vertex/client.rb +4 -1
  11. data/lib/anthropic/internal/stream.rb +4 -2
  12. data/lib/anthropic/internal/transport/base_client.rb +29 -3
  13. data/lib/anthropic/internal/type/array_of.rb +7 -1
  14. data/lib/anthropic/internal/type/base_model.rb +80 -24
  15. data/lib/anthropic/internal/type/base_stream.rb +3 -1
  16. data/lib/anthropic/internal/type/boolean.rb +7 -1
  17. data/lib/anthropic/internal/type/converter.rb +69 -34
  18. data/lib/anthropic/internal/type/enum.rb +16 -5
  19. data/lib/anthropic/internal/type/file_input.rb +6 -1
  20. data/lib/anthropic/internal/type/hash_of.rb +7 -1
  21. data/lib/anthropic/internal/type/union.rb +26 -16
  22. data/lib/anthropic/internal/type/unknown.rb +7 -1
  23. data/lib/anthropic/internal/util.rb +8 -9
  24. data/lib/anthropic/models/anthropic_beta.rb +3 -0
  25. data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +1 -65
  26. data/lib/anthropic/models/beta/beta_citation_char_location.rb +7 -1
  27. data/lib/anthropic/models/beta/beta_citation_content_block_location.rb +7 -1
  28. data/lib/anthropic/models/beta/beta_citation_page_location.rb +7 -1
  29. data/lib/anthropic/models/beta/beta_citation_search_result_location.rb +55 -0
  30. data/lib/anthropic/models/beta/beta_citation_search_result_location_param.rb +55 -0
  31. data/lib/anthropic/models/beta/beta_citations_delta.rb +5 -3
  32. data/lib/anthropic/models/beta/beta_content_block.rb +5 -5
  33. data/lib/anthropic/models/beta/beta_content_block_param.rb +20 -17
  34. data/lib/anthropic/models/beta/beta_message.rb +6 -2
  35. data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
  36. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +7 -7
  37. data/lib/anthropic/models/beta/beta_request_document_block.rb +75 -0
  38. data/lib/anthropic/models/beta/beta_search_result_block_param.rb +55 -0
  39. data/lib/anthropic/models/beta/beta_text_block.rb +2 -2
  40. data/lib/anthropic/models/beta/beta_text_block_param.rb +2 -2
  41. data/lib/anthropic/models/beta/beta_text_citation.rb +3 -1
  42. data/lib/anthropic/models/beta/beta_text_citation_param.rb +3 -1
  43. data/lib/anthropic/models/beta/beta_tool.rb +7 -1
  44. data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +6 -4
  45. data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +49 -0
  46. data/lib/anthropic/models/beta/beta_tool_union.rb +9 -7
  47. data/lib/anthropic/models/beta/message_count_tokens_params.rb +18 -10
  48. data/lib/anthropic/models/beta/message_create_params.rb +9 -3
  49. data/lib/anthropic/models/beta/messages/batch_create_params.rb +9 -3
  50. data/lib/anthropic/models/citation_char_location.rb +7 -1
  51. data/lib/anthropic/models/citation_content_block_location.rb +7 -1
  52. data/lib/anthropic/models/citation_page_location.rb +7 -1
  53. data/lib/anthropic/models/citation_search_result_location_param.rb +51 -0
  54. data/lib/anthropic/models/citations_delta.rb +5 -3
  55. data/lib/anthropic/models/citations_search_result_location.rb +51 -0
  56. data/lib/anthropic/models/content_block.rb +5 -5
  57. data/lib/anthropic/models/content_block_param.rb +14 -11
  58. data/lib/anthropic/models/message.rb +6 -2
  59. data/lib/anthropic/models/message_count_tokens_params.rb +9 -3
  60. data/lib/anthropic/models/message_count_tokens_tool.rb +5 -1
  61. data/lib/anthropic/models/message_create_params.rb +9 -3
  62. data/lib/anthropic/models/message_param.rb +3 -3
  63. data/lib/anthropic/models/messages/batch_create_params.rb +9 -3
  64. data/lib/anthropic/models/model.rb +10 -21
  65. data/lib/anthropic/models/raw_content_block_start_event.rb +7 -7
  66. data/lib/anthropic/models/search_result_block_param.rb +51 -0
  67. data/lib/anthropic/models/text_block.rb +2 -2
  68. data/lib/anthropic/models/text_block_param.rb +2 -2
  69. data/lib/anthropic/models/text_citation.rb +3 -1
  70. data/lib/anthropic/models/text_citation_param.rb +3 -1
  71. data/lib/anthropic/models/tool.rb +7 -1
  72. data/lib/anthropic/models/tool_result_block_param.rb +6 -4
  73. data/lib/anthropic/models/tool_text_editor_20250429.rb +36 -0
  74. data/lib/anthropic/models/tool_text_editor_20250728.rb +45 -0
  75. data/lib/anthropic/models/tool_union.rb +5 -1
  76. data/lib/anthropic/models/tool_use_block.rb +6 -0
  77. data/lib/anthropic/models.rb +14 -4
  78. data/lib/anthropic/resources/beta/messages.rb +73 -6
  79. data/lib/anthropic/resources/messages.rb +68 -7
  80. data/lib/anthropic/streaming.rb +5 -0
  81. data/lib/anthropic/version.rb +1 -1
  82. data/lib/anthropic.rb +14 -0
  83. data/rbi/anthropic/errors.rbi +16 -0
  84. data/rbi/anthropic/helpers/bedrock/client.rbi +17 -6
  85. data/rbi/anthropic/helpers/streaming/events.rbi +95 -0
  86. data/rbi/anthropic/helpers/streaming/message_stream.rbi +73 -0
  87. data/rbi/anthropic/helpers/vertex/client.rbi +17 -6
  88. data/rbi/anthropic/internal/transport/base_client.rbi +1 -1
  89. data/rbi/anthropic/internal/type/base_stream.rbi +8 -1
  90. data/rbi/anthropic/internal/type/boolean.rbi +2 -0
  91. data/rbi/anthropic/internal/type/converter.rbi +69 -15
  92. data/rbi/anthropic/internal/type/union.rbi +14 -2
  93. data/rbi/anthropic/internal/type/unknown.rbi +2 -0
  94. data/rbi/anthropic/internal/util.rbi +2 -0
  95. data/rbi/anthropic/models/anthropic_beta.rbi +2 -0
  96. data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +1 -128
  97. data/rbi/anthropic/models/beta/beta_citation_char_location.rbi +6 -0
  98. data/rbi/anthropic/models/beta/beta_citation_content_block_location.rbi +6 -0
  99. data/rbi/anthropic/models/beta/beta_citation_page_location.rbi +6 -0
  100. data/rbi/anthropic/models/beta/beta_citation_search_result_location.rbi +78 -0
  101. data/rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi +79 -0
  102. data/rbi/anthropic/models/beta/beta_citations_delta.rbi +4 -2
  103. data/rbi/anthropic/models/beta/beta_content_block.rbi +3 -3
  104. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +8 -7
  105. data/rbi/anthropic/models/beta/beta_message.rbi +11 -3
  106. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +6 -6
  107. data/rbi/anthropic/models/beta/beta_request_document_block.rbi +140 -0
  108. data/rbi/anthropic/models/beta/beta_search_result_block_param.rbi +91 -0
  109. data/rbi/anthropic/models/beta/beta_text_block.rbi +2 -1
  110. data/rbi/anthropic/models/beta/beta_text_block_param.rbi +6 -3
  111. data/rbi/anthropic/models/beta/beta_text_citation.rbi +2 -1
  112. data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +2 -1
  113. data/rbi/anthropic/models/beta/beta_tool.rbi +14 -5
  114. data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +2 -1
  115. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +82 -0
  116. data/rbi/anthropic/models/beta/beta_tool_union.rbi +6 -5
  117. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +44 -27
  118. data/rbi/anthropic/models/beta/message_create_params.rbi +38 -22
  119. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +38 -22
  120. data/rbi/anthropic/models/citation_char_location.rbi +6 -0
  121. data/rbi/anthropic/models/citation_content_block_location.rbi +6 -0
  122. data/rbi/anthropic/models/citation_page_location.rbi +6 -0
  123. data/rbi/anthropic/models/citation_search_result_location_param.rbi +74 -0
  124. data/rbi/anthropic/models/citations_delta.rbi +4 -2
  125. data/rbi/anthropic/models/citations_search_result_location.rbi +74 -0
  126. data/rbi/anthropic/models/content_block.rbi +3 -3
  127. data/rbi/anthropic/models/content_block_param.rbi +6 -5
  128. data/rbi/anthropic/models/message.rbi +11 -3
  129. data/rbi/anthropic/models/message_count_tokens_params.rbi +22 -2
  130. data/rbi/anthropic/models/message_count_tokens_tool.rbi +2 -0
  131. data/rbi/anthropic/models/message_create_params.rbi +22 -2
  132. data/rbi/anthropic/models/messages/batch_create_params.rbi +22 -2
  133. data/rbi/anthropic/models/model.rbi +4 -8
  134. data/rbi/anthropic/models/raw_content_block_start_event.rbi +6 -6
  135. data/rbi/anthropic/models/search_result_block_param.rbi +77 -0
  136. data/rbi/anthropic/models/text_block.rbi +2 -1
  137. data/rbi/anthropic/models/text_block_param.rbi +6 -3
  138. data/rbi/anthropic/models/text_citation.rbi +2 -1
  139. data/rbi/anthropic/models/text_citation_param.rbi +2 -1
  140. data/rbi/anthropic/models/tool.rbi +16 -5
  141. data/rbi/anthropic/models/tool_result_block_param.rbi +5 -1
  142. data/rbi/anthropic/models/tool_text_editor_20250429.rbi +62 -0
  143. data/rbi/anthropic/models/tool_text_editor_20250728.rbi +72 -0
  144. data/rbi/anthropic/models/tool_union.rbi +2 -0
  145. data/rbi/anthropic/models.rbi +12 -0
  146. data/rbi/anthropic/resources/beta/messages.rbi +39 -18
  147. data/rbi/anthropic/resources/messages.rbi +318 -3
  148. data/rbi/anthropic/streaming.rbi +5 -0
  149. data/sig/anthropic/errors.rbs +9 -0
  150. data/sig/anthropic/helpers/streaming/events.rbs +117 -0
  151. data/sig/anthropic/helpers/streaming/message_stream.rbs +57 -0
  152. data/sig/anthropic/internal/transport/base_client.rbs +1 -1
  153. data/sig/anthropic/internal/type/base_stream.rbs +4 -0
  154. data/sig/anthropic/internal/type/converter.rbs +24 -1
  155. data/sig/anthropic/internal/type/union.rbs +2 -2
  156. data/sig/anthropic/models/anthropic_beta.rbs +2 -0
  157. data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +1 -58
  158. data/sig/anthropic/models/beta/beta_citation_char_location.rbs +5 -0
  159. data/sig/anthropic/models/beta/beta_citation_content_block_location.rbs +5 -0
  160. data/sig/anthropic/models/beta/beta_citation_page_location.rbs +5 -0
  161. data/sig/anthropic/models/beta/beta_citation_search_result_location.rbs +54 -0
  162. data/sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs +54 -0
  163. data/sig/anthropic/models/beta/beta_citations_delta.rbs +1 -0
  164. data/sig/anthropic/models/beta/beta_content_block.rbs +2 -2
  165. data/sig/anthropic/models/beta/beta_content_block_param.rbs +9 -8
  166. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -2
  167. data/sig/anthropic/models/beta/beta_request_document_block.rbs +66 -0
  168. data/sig/anthropic/models/beta/beta_search_result_block_param.rbs +53 -0
  169. data/sig/anthropic/models/beta/beta_text_citation.rbs +1 -0
  170. data/sig/anthropic/models/beta/beta_text_citation_param.rbs +1 -0
  171. data/sig/anthropic/models/beta/beta_tool.rbs +14 -3
  172. data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +1 -0
  173. data/sig/anthropic/models/beta/beta_tool_text_editor_20250728.rbs +39 -0
  174. data/sig/anthropic/models/beta/beta_tool_union.rbs +5 -4
  175. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +5 -4
  176. data/sig/anthropic/models/citation_char_location.rbs +5 -0
  177. data/sig/anthropic/models/citation_content_block_location.rbs +5 -0
  178. data/sig/anthropic/models/citation_page_location.rbs +5 -0
  179. data/sig/anthropic/models/citation_search_result_location_param.rbs +50 -0
  180. data/sig/anthropic/models/citations_delta.rbs +1 -0
  181. data/sig/anthropic/models/citations_search_result_location.rbs +50 -0
  182. data/sig/anthropic/models/content_block.rbs +2 -2
  183. data/sig/anthropic/models/content_block_param.rbs +6 -5
  184. data/sig/anthropic/models/message_count_tokens_tool.rbs +2 -0
  185. data/sig/anthropic/models/model.rbs +4 -10
  186. data/sig/anthropic/models/raw_content_block_start_event.rbs +2 -2
  187. data/sig/anthropic/models/search_result_block_param.rbs +49 -0
  188. data/sig/anthropic/models/text_citation.rbs +1 -0
  189. data/sig/anthropic/models/text_citation_param.rbs +1 -0
  190. data/sig/anthropic/models/tool.rbs +14 -3
  191. data/sig/anthropic/models/tool_result_block_param.rbs +4 -1
  192. data/sig/anthropic/models/tool_text_editor_20250429.rbs +30 -0
  193. data/sig/anthropic/models/tool_text_editor_20250728.rbs +35 -0
  194. data/sig/anthropic/models/tool_union.rbs +2 -0
  195. data/sig/anthropic/models.rbs +10 -0
  196. data/sig/anthropic/streaming.rbs +3 -0
  197. metadata +44 -3
@@ -112,7 +112,7 @@ module Anthropic
112
112
  # the top-level `system` parameter — there is no `"system"` role for input
113
113
  # messages in the Messages API.
114
114
  #
115
- # There is a limit of 100000 messages in a single request.
115
+ # There is a limit of 100,000 messages in a single request.
116
116
  sig { returns(T::Array[Anthropic::Beta::BetaMessageParam]) }
117
117
  attr_accessor :messages
118
118
 
@@ -291,6 +291,12 @@ module Anthropic
291
291
  # those tools using the tool input generated by the model and then optionally
292
292
  # return results back to the model using `tool_result` content blocks.
293
293
  #
294
+ # There are two types of tools: **client tools** and **server tools**. The
295
+ # behavior described below applies to client tools. For
296
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
297
+ # see their individual documentation as each has its own behavior (e.g., the
298
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
299
+ #
294
300
  # Each tool definition includes:
295
301
  #
296
302
  # - `name`: Name of the tool.
@@ -359,15 +365,16 @@ module Anthropic
359
365
  T::Array[
360
366
  T.any(
361
367
  Anthropic::Beta::BetaTool,
362
- Anthropic::Beta::BetaToolComputerUse20241022,
363
368
  Anthropic::Beta::BetaToolBash20241022,
364
- Anthropic::Beta::BetaToolTextEditor20241022,
365
- Anthropic::Beta::BetaToolComputerUse20250124,
366
369
  Anthropic::Beta::BetaToolBash20250124,
370
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
371
+ Anthropic::Beta::BetaToolComputerUse20241022,
372
+ Anthropic::Beta::BetaToolComputerUse20250124,
373
+ Anthropic::Beta::BetaToolTextEditor20241022,
367
374
  Anthropic::Beta::BetaToolTextEditor20250124,
368
375
  Anthropic::Beta::BetaToolTextEditor20250429,
369
- Anthropic::Beta::BetaWebSearchTool20250305,
370
- Anthropic::Beta::BetaCodeExecutionTool20250522
376
+ Anthropic::Beta::BetaToolTextEditor20250728,
377
+ Anthropic::Beta::BetaWebSearchTool20250305
371
378
  )
372
379
  ]
373
380
  )
@@ -381,15 +388,16 @@ module Anthropic
381
388
  T::Array[
382
389
  T.any(
383
390
  Anthropic::Beta::BetaTool::OrHash,
384
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
385
391
  Anthropic::Beta::BetaToolBash20241022::OrHash,
386
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
387
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
388
392
  Anthropic::Beta::BetaToolBash20250124::OrHash,
393
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
394
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
395
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
396
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
389
397
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
390
398
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
391
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
392
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
399
+ Anthropic::Beta::BetaToolTextEditor20250728::OrHash,
400
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
393
401
  )
394
402
  ]
395
403
  ).void
@@ -473,15 +481,16 @@ module Anthropic
473
481
  T::Array[
474
482
  T.any(
475
483
  Anthropic::Beta::BetaTool::OrHash,
476
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
477
484
  Anthropic::Beta::BetaToolBash20241022::OrHash,
478
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
479
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
480
485
  Anthropic::Beta::BetaToolBash20250124::OrHash,
486
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
487
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
488
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
489
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
481
490
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
482
491
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
483
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
484
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
492
+ Anthropic::Beta::BetaToolTextEditor20250728::OrHash,
493
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
485
494
  )
486
495
  ],
487
496
  top_k: Integer,
@@ -586,7 +595,7 @@ module Anthropic
586
595
  # the top-level `system` parameter — there is no `"system"` role for input
587
596
  # messages in the Messages API.
588
597
  #
589
- # There is a limit of 100000 messages in a single request.
598
+ # There is a limit of 100,000 messages in a single request.
590
599
  messages:,
591
600
  # The model that will complete your prompt.\n\nSee
592
601
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -649,6 +658,12 @@ module Anthropic
649
658
  # those tools using the tool input generated by the model and then optionally
650
659
  # return results back to the model using `tool_result` content blocks.
651
660
  #
661
+ # There are two types of tools: **client tools** and **server tools**. The
662
+ # behavior described below applies to client tools. For
663
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
664
+ # see their individual documentation as each has its own behavior (e.g., the
665
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
666
+ #
652
667
  # Each tool definition includes:
653
668
  #
654
669
  # - `name`: Name of the tool.
@@ -767,15 +782,16 @@ module Anthropic
767
782
  T::Array[
768
783
  T.any(
769
784
  Anthropic::Beta::BetaTool,
770
- Anthropic::Beta::BetaToolComputerUse20241022,
771
785
  Anthropic::Beta::BetaToolBash20241022,
772
- Anthropic::Beta::BetaToolTextEditor20241022,
773
- Anthropic::Beta::BetaToolComputerUse20250124,
774
786
  Anthropic::Beta::BetaToolBash20250124,
787
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
788
+ Anthropic::Beta::BetaToolComputerUse20241022,
789
+ Anthropic::Beta::BetaToolComputerUse20250124,
790
+ Anthropic::Beta::BetaToolTextEditor20241022,
775
791
  Anthropic::Beta::BetaToolTextEditor20250124,
776
792
  Anthropic::Beta::BetaToolTextEditor20250429,
777
- Anthropic::Beta::BetaWebSearchTool20250305,
778
- Anthropic::Beta::BetaCodeExecutionTool20250522
793
+ Anthropic::Beta::BetaToolTextEditor20250728,
794
+ Anthropic::Beta::BetaWebSearchTool20250305
779
795
  )
780
796
  ],
781
797
  top_k: Integer,
@@ -253,7 +253,7 @@ module Anthropic
253
253
  # the top-level `system` parameter — there is no `"system"` role for input
254
254
  # messages in the Messages API.
255
255
  #
256
- # There is a limit of 100000 messages in a single request.
256
+ # There is a limit of 100,000 messages in a single request.
257
257
  sig { returns(T::Array[Anthropic::Beta::BetaMessageParam]) }
258
258
  attr_accessor :messages
259
259
 
@@ -447,6 +447,12 @@ module Anthropic
447
447
  # those tools using the tool input generated by the model and then optionally
448
448
  # return results back to the model using `tool_result` content blocks.
449
449
  #
450
+ # There are two types of tools: **client tools** and **server tools**. The
451
+ # behavior described below applies to client tools. For
452
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
453
+ # see their individual documentation as each has its own behavior (e.g., the
454
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
455
+ #
450
456
  # Each tool definition includes:
451
457
  #
452
458
  # - `name`: Name of the tool.
@@ -515,15 +521,16 @@ module Anthropic
515
521
  T::Array[
516
522
  T.any(
517
523
  Anthropic::Beta::BetaTool,
518
- Anthropic::Beta::BetaToolComputerUse20241022,
519
524
  Anthropic::Beta::BetaToolBash20241022,
520
- Anthropic::Beta::BetaToolTextEditor20241022,
521
- Anthropic::Beta::BetaToolComputerUse20250124,
522
525
  Anthropic::Beta::BetaToolBash20250124,
526
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
527
+ Anthropic::Beta::BetaToolComputerUse20241022,
528
+ Anthropic::Beta::BetaToolComputerUse20250124,
529
+ Anthropic::Beta::BetaToolTextEditor20241022,
523
530
  Anthropic::Beta::BetaToolTextEditor20250124,
524
531
  Anthropic::Beta::BetaToolTextEditor20250429,
525
- Anthropic::Beta::BetaWebSearchTool20250305,
526
- Anthropic::Beta::BetaCodeExecutionTool20250522
532
+ Anthropic::Beta::BetaToolTextEditor20250728,
533
+ Anthropic::Beta::BetaWebSearchTool20250305
527
534
  )
528
535
  ]
529
536
  )
@@ -537,15 +544,16 @@ module Anthropic
537
544
  T::Array[
538
545
  T.any(
539
546
  Anthropic::Beta::BetaTool::OrHash,
540
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
541
547
  Anthropic::Beta::BetaToolBash20241022::OrHash,
542
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
543
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
544
548
  Anthropic::Beta::BetaToolBash20250124::OrHash,
549
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
550
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
551
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
552
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
545
553
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
546
554
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
547
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
548
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
555
+ Anthropic::Beta::BetaToolTextEditor20250728::OrHash,
556
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
549
557
  )
550
558
  ]
551
559
  ).void
@@ -618,15 +626,16 @@ module Anthropic
618
626
  T::Array[
619
627
  T.any(
620
628
  Anthropic::Beta::BetaTool::OrHash,
621
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
622
629
  Anthropic::Beta::BetaToolBash20241022::OrHash,
623
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
624
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
625
630
  Anthropic::Beta::BetaToolBash20250124::OrHash,
631
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
632
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
633
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
634
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
626
635
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
627
636
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
628
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
629
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
637
+ Anthropic::Beta::BetaToolTextEditor20250728::OrHash,
638
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
630
639
  )
631
640
  ],
632
641
  top_k: Integer,
@@ -729,7 +738,7 @@ module Anthropic
729
738
  # the top-level `system` parameter — there is no `"system"` role for input
730
739
  # messages in the Messages API.
731
740
  #
732
- # There is a limit of 100000 messages in a single request.
741
+ # There is a limit of 100,000 messages in a single request.
733
742
  messages:,
734
743
  # The model that will complete your prompt.\n\nSee
735
744
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -797,6 +806,12 @@ module Anthropic
797
806
  # those tools using the tool input generated by the model and then optionally
798
807
  # return results back to the model using `tool_result` content blocks.
799
808
  #
809
+ # There are two types of tools: **client tools** and **server tools**. The
810
+ # behavior described below applies to client tools. For
811
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
812
+ # see their individual documentation as each has its own behavior (e.g., the
813
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
814
+ #
800
815
  # Each tool definition includes:
801
816
  #
802
817
  # - `name`: Name of the tool.
@@ -916,15 +931,16 @@ module Anthropic
916
931
  T::Array[
917
932
  T.any(
918
933
  Anthropic::Beta::BetaTool,
919
- Anthropic::Beta::BetaToolComputerUse20241022,
920
934
  Anthropic::Beta::BetaToolBash20241022,
921
- Anthropic::Beta::BetaToolTextEditor20241022,
922
- Anthropic::Beta::BetaToolComputerUse20250124,
923
935
  Anthropic::Beta::BetaToolBash20250124,
936
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
937
+ Anthropic::Beta::BetaToolComputerUse20241022,
938
+ Anthropic::Beta::BetaToolComputerUse20250124,
939
+ Anthropic::Beta::BetaToolTextEditor20241022,
924
940
  Anthropic::Beta::BetaToolTextEditor20250124,
925
941
  Anthropic::Beta::BetaToolTextEditor20250429,
926
- Anthropic::Beta::BetaWebSearchTool20250305,
927
- Anthropic::Beta::BetaCodeExecutionTool20250522
942
+ Anthropic::Beta::BetaToolTextEditor20250728,
943
+ Anthropic::Beta::BetaWebSearchTool20250305
928
944
  )
929
945
  ],
930
946
  top_k: Integer,
@@ -20,6 +20,9 @@ module Anthropic
20
20
  sig { returns(Integer) }
21
21
  attr_accessor :end_char_index
22
22
 
23
+ sig { returns(T.nilable(String)) }
24
+ attr_accessor :file_id
25
+
23
26
  sig { returns(Integer) }
24
27
  attr_accessor :start_char_index
25
28
 
@@ -32,6 +35,7 @@ module Anthropic
32
35
  document_index: Integer,
33
36
  document_title: T.nilable(String),
34
37
  end_char_index: Integer,
38
+ file_id: T.nilable(String),
35
39
  start_char_index: Integer,
36
40
  type: Symbol
37
41
  ).returns(T.attached_class)
@@ -41,6 +45,7 @@ module Anthropic
41
45
  document_index:,
42
46
  document_title:,
43
47
  end_char_index:,
48
+ file_id:,
44
49
  start_char_index:,
45
50
  type: :char_location
46
51
  )
@@ -53,6 +58,7 @@ module Anthropic
53
58
  document_index: Integer,
54
59
  document_title: T.nilable(String),
55
60
  end_char_index: Integer,
61
+ file_id: T.nilable(String),
56
62
  start_char_index: Integer,
57
63
  type: Symbol
58
64
  }
@@ -23,6 +23,9 @@ module Anthropic
23
23
  sig { returns(Integer) }
24
24
  attr_accessor :end_block_index
25
25
 
26
+ sig { returns(T.nilable(String)) }
27
+ attr_accessor :file_id
28
+
26
29
  sig { returns(Integer) }
27
30
  attr_accessor :start_block_index
28
31
 
@@ -35,6 +38,7 @@ module Anthropic
35
38
  document_index: Integer,
36
39
  document_title: T.nilable(String),
37
40
  end_block_index: Integer,
41
+ file_id: T.nilable(String),
38
42
  start_block_index: Integer,
39
43
  type: Symbol
40
44
  ).returns(T.attached_class)
@@ -44,6 +48,7 @@ module Anthropic
44
48
  document_index:,
45
49
  document_title:,
46
50
  end_block_index:,
51
+ file_id:,
47
52
  start_block_index:,
48
53
  type: :content_block_location
49
54
  )
@@ -56,6 +61,7 @@ module Anthropic
56
61
  document_index: Integer,
57
62
  document_title: T.nilable(String),
58
63
  end_block_index: Integer,
64
+ file_id: T.nilable(String),
59
65
  start_block_index: Integer,
60
66
  type: Symbol
61
67
  }
@@ -20,6 +20,9 @@ module Anthropic
20
20
  sig { returns(Integer) }
21
21
  attr_accessor :end_page_number
22
22
 
23
+ sig { returns(T.nilable(String)) }
24
+ attr_accessor :file_id
25
+
23
26
  sig { returns(Integer) }
24
27
  attr_accessor :start_page_number
25
28
 
@@ -32,6 +35,7 @@ module Anthropic
32
35
  document_index: Integer,
33
36
  document_title: T.nilable(String),
34
37
  end_page_number: Integer,
38
+ file_id: T.nilable(String),
35
39
  start_page_number: Integer,
36
40
  type: Symbol
37
41
  ).returns(T.attached_class)
@@ -41,6 +45,7 @@ module Anthropic
41
45
  document_index:,
42
46
  document_title:,
43
47
  end_page_number:,
48
+ file_id:,
44
49
  start_page_number:,
45
50
  type: :page_location
46
51
  )
@@ -53,6 +58,7 @@ module Anthropic
53
58
  document_index: Integer,
54
59
  document_title: T.nilable(String),
55
60
  end_page_number: Integer,
61
+ file_id: T.nilable(String),
56
62
  start_page_number: Integer,
57
63
  type: Symbol
58
64
  }
@@ -0,0 +1,74 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ class CitationSearchResultLocationParam < Anthropic::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Anthropic::CitationSearchResultLocationParam,
10
+ Anthropic::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ sig { returns(String) }
15
+ attr_accessor :cited_text
16
+
17
+ sig { returns(Integer) }
18
+ attr_accessor :end_block_index
19
+
20
+ sig { returns(Integer) }
21
+ attr_accessor :search_result_index
22
+
23
+ sig { returns(String) }
24
+ attr_accessor :source
25
+
26
+ sig { returns(Integer) }
27
+ attr_accessor :start_block_index
28
+
29
+ sig { returns(T.nilable(String)) }
30
+ attr_accessor :title
31
+
32
+ sig { returns(Symbol) }
33
+ attr_accessor :type
34
+
35
+ sig do
36
+ params(
37
+ cited_text: String,
38
+ end_block_index: Integer,
39
+ search_result_index: Integer,
40
+ source: String,
41
+ start_block_index: Integer,
42
+ title: T.nilable(String),
43
+ type: Symbol
44
+ ).returns(T.attached_class)
45
+ end
46
+ def self.new(
47
+ cited_text:,
48
+ end_block_index:,
49
+ search_result_index:,
50
+ source:,
51
+ start_block_index:,
52
+ title:,
53
+ type: :search_result_location
54
+ )
55
+ end
56
+
57
+ sig do
58
+ override.returns(
59
+ {
60
+ cited_text: String,
61
+ end_block_index: Integer,
62
+ search_result_index: Integer,
63
+ source: String,
64
+ start_block_index: Integer,
65
+ title: T.nilable(String),
66
+ type: Symbol
67
+ }
68
+ )
69
+ end
70
+ def to_hash
71
+ end
72
+ end
73
+ end
74
+ end
@@ -21,7 +21,8 @@ module Anthropic
21
21
  Anthropic::CitationCharLocation::OrHash,
22
22
  Anthropic::CitationPageLocation::OrHash,
23
23
  Anthropic::CitationContentBlockLocation::OrHash,
24
- Anthropic::CitationsWebSearchResultLocation::OrHash
24
+ Anthropic::CitationsWebSearchResultLocation::OrHash,
25
+ Anthropic::CitationsSearchResultLocation::OrHash
25
26
  ),
26
27
  type: Symbol
27
28
  ).returns(T.attached_class)
@@ -49,7 +50,8 @@ module Anthropic
49
50
  Anthropic::CitationCharLocation,
50
51
  Anthropic::CitationPageLocation,
51
52
  Anthropic::CitationContentBlockLocation,
52
- Anthropic::CitationsWebSearchResultLocation
53
+ Anthropic::CitationsWebSearchResultLocation,
54
+ Anthropic::CitationsSearchResultLocation
53
55
  )
54
56
  end
55
57
 
@@ -0,0 +1,74 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ class CitationsSearchResultLocation < Anthropic::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Anthropic::CitationsSearchResultLocation,
10
+ Anthropic::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ sig { returns(String) }
15
+ attr_accessor :cited_text
16
+
17
+ sig { returns(Integer) }
18
+ attr_accessor :end_block_index
19
+
20
+ sig { returns(Integer) }
21
+ attr_accessor :search_result_index
22
+
23
+ sig { returns(String) }
24
+ attr_accessor :source
25
+
26
+ sig { returns(Integer) }
27
+ attr_accessor :start_block_index
28
+
29
+ sig { returns(T.nilable(String)) }
30
+ attr_accessor :title
31
+
32
+ sig { returns(Symbol) }
33
+ attr_accessor :type
34
+
35
+ sig do
36
+ params(
37
+ cited_text: String,
38
+ end_block_index: Integer,
39
+ search_result_index: Integer,
40
+ source: String,
41
+ start_block_index: Integer,
42
+ title: T.nilable(String),
43
+ type: Symbol
44
+ ).returns(T.attached_class)
45
+ end
46
+ def self.new(
47
+ cited_text:,
48
+ end_block_index:,
49
+ search_result_index:,
50
+ source:,
51
+ start_block_index:,
52
+ title:,
53
+ type: :search_result_location
54
+ )
55
+ end
56
+
57
+ sig do
58
+ override.returns(
59
+ {
60
+ cited_text: String,
61
+ end_block_index: Integer,
62
+ search_result_index: Integer,
63
+ source: String,
64
+ start_block_index: Integer,
65
+ title: T.nilable(String),
66
+ type: Symbol
67
+ }
68
+ )
69
+ end
70
+ def to_hash
71
+ end
72
+ end
73
+ end
74
+ end
@@ -9,11 +9,11 @@ module Anthropic
9
9
  T.type_alias do
10
10
  T.any(
11
11
  Anthropic::TextBlock,
12
+ Anthropic::ThinkingBlock,
13
+ Anthropic::RedactedThinkingBlock,
12
14
  Anthropic::ToolUseBlock,
13
15
  Anthropic::ServerToolUseBlock,
14
- Anthropic::WebSearchToolResultBlock,
15
- Anthropic::ThinkingBlock,
16
- Anthropic::RedactedThinkingBlock
16
+ Anthropic::WebSearchToolResultBlock
17
17
  )
18
18
  end
19
19
 
@@ -9,15 +9,16 @@ module Anthropic
9
9
  Variants =
10
10
  T.type_alias do
11
11
  T.any(
12
- Anthropic::ServerToolUseBlockParam,
13
- Anthropic::WebSearchToolResultBlockParam,
14
12
  Anthropic::TextBlockParam,
15
13
  Anthropic::ImageBlockParam,
16
- Anthropic::ToolUseBlockParam,
17
- Anthropic::ToolResultBlockParam,
18
14
  Anthropic::DocumentBlockParam,
15
+ Anthropic::SearchResultBlockParam,
19
16
  Anthropic::ThinkingBlockParam,
20
- Anthropic::RedactedThinkingBlockParam
17
+ Anthropic::RedactedThinkingBlockParam,
18
+ Anthropic::ToolUseBlockParam,
19
+ Anthropic::ToolResultBlockParam,
20
+ Anthropic::ServerToolUseBlockParam,
21
+ Anthropic::WebSearchToolResultBlockParam
21
22
  )
22
23
  end
23
24
 
@@ -67,6 +67,10 @@ module Anthropic
67
67
  # - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
68
68
  # - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
69
69
  # - `"tool_use"`: the model invoked one or more tools
70
+ # - `"pause_turn"`: we paused a long-running turn. You may provide the response
71
+ # back as-is in a subsequent request to let the model continue.
72
+ # - `"refusal"`: when streaming classifiers intervene to handle potential policy
73
+ # violations
70
74
  #
71
75
  # In non-streaming mode this value is always non-null. In streaming mode, it is
72
76
  # null in the `message_start` event and non-null otherwise.
@@ -114,11 +118,11 @@ module Anthropic
114
118
  T::Array[
115
119
  T.any(
116
120
  Anthropic::TextBlock::OrHash,
121
+ Anthropic::ThinkingBlock::OrHash,
122
+ Anthropic::RedactedThinkingBlock::OrHash,
117
123
  Anthropic::ToolUseBlock::OrHash,
118
124
  Anthropic::ServerToolUseBlock::OrHash,
119
- Anthropic::WebSearchToolResultBlock::OrHash,
120
- Anthropic::ThinkingBlock::OrHash,
121
- Anthropic::RedactedThinkingBlock::OrHash
125
+ Anthropic::WebSearchToolResultBlock::OrHash
122
126
  )
123
127
  ],
124
128
  model: T.any(Anthropic::Model::OrSymbol, String),
@@ -179,6 +183,10 @@ module Anthropic
179
183
  # - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
180
184
  # - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
181
185
  # - `"tool_use"`: the model invoked one or more tools
186
+ # - `"pause_turn"`: we paused a long-running turn. You may provide the response
187
+ # back as-is in a subsequent request to let the model continue.
188
+ # - `"refusal"`: when streaming classifiers intervene to handle potential policy
189
+ # violations
182
190
  #
183
191
  # In non-streaming mode this value is always non-null. In streaming mode, it is
184
192
  # null in the `message_start` event and non-null otherwise.