anthropic 1.1.1 → 1.2.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 (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/README.md +32 -16
  4. data/lib/anthropic/errors.rb +22 -0
  5. data/lib/anthropic/helpers/streaming/events.rb +141 -0
  6. data/lib/anthropic/helpers/streaming/message_stream.rb +238 -0
  7. data/lib/anthropic/helpers/streaming.rb +37 -0
  8. data/lib/anthropic/helpers/vertex/client.rb +4 -1
  9. data/lib/anthropic/internal/stream.rb +4 -2
  10. data/lib/anthropic/internal/transport/base_client.rb +10 -2
  11. data/lib/anthropic/internal/type/array_of.rb +6 -1
  12. data/lib/anthropic/internal/type/base_model.rb +77 -23
  13. data/lib/anthropic/internal/type/base_stream.rb +3 -1
  14. data/lib/anthropic/internal/type/boolean.rb +7 -1
  15. data/lib/anthropic/internal/type/converter.rb +42 -34
  16. data/lib/anthropic/internal/type/enum.rb +16 -5
  17. data/lib/anthropic/internal/type/file_input.rb +6 -1
  18. data/lib/anthropic/internal/type/hash_of.rb +6 -1
  19. data/lib/anthropic/internal/type/union.rb +17 -9
  20. data/lib/anthropic/internal/type/unknown.rb +7 -1
  21. data/lib/anthropic/internal/util.rb +8 -9
  22. data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +1 -65
  23. data/lib/anthropic/models/beta/beta_citation_search_result_location.rb +55 -0
  24. data/lib/anthropic/models/beta/beta_citation_search_result_location_param.rb +55 -0
  25. data/lib/anthropic/models/beta/beta_citations_delta.rb +5 -3
  26. data/lib/anthropic/models/beta/beta_content_block.rb +5 -5
  27. data/lib/anthropic/models/beta/beta_content_block_param.rb +20 -17
  28. data/lib/anthropic/models/beta/beta_message.rb +6 -2
  29. data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
  30. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +7 -7
  31. data/lib/anthropic/models/beta/beta_request_document_block.rb +75 -0
  32. data/lib/anthropic/models/beta/beta_search_result_block_param.rb +55 -0
  33. data/lib/anthropic/models/beta/beta_text_block.rb +2 -2
  34. data/lib/anthropic/models/beta/beta_text_block_param.rb +2 -2
  35. data/lib/anthropic/models/beta/beta_text_citation.rb +3 -1
  36. data/lib/anthropic/models/beta/beta_text_citation_param.rb +3 -1
  37. data/lib/anthropic/models/beta/beta_tool.rb +7 -1
  38. data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +6 -4
  39. data/lib/anthropic/models/beta/beta_tool_union.rb +7 -7
  40. data/lib/anthropic/models/beta/message_count_tokens_params.rb +16 -10
  41. data/lib/anthropic/models/beta/message_create_params.rb +9 -3
  42. data/lib/anthropic/models/beta/messages/batch_create_params.rb +9 -3
  43. data/lib/anthropic/models/content_block.rb +5 -5
  44. data/lib/anthropic/models/content_block_param.rb +11 -11
  45. data/lib/anthropic/models/message.rb +6 -2
  46. data/lib/anthropic/models/message_count_tokens_params.rb +9 -3
  47. data/lib/anthropic/models/message_count_tokens_tool.rb +35 -1
  48. data/lib/anthropic/models/message_create_params.rb +9 -3
  49. data/lib/anthropic/models/message_param.rb +3 -3
  50. data/lib/anthropic/models/messages/batch_create_params.rb +9 -3
  51. data/lib/anthropic/models/model.rb +6 -0
  52. data/lib/anthropic/models/raw_content_block_start_event.rb +7 -7
  53. data/lib/anthropic/models/tool.rb +7 -1
  54. data/lib/anthropic/models/tool_union.rb +34 -1
  55. data/lib/anthropic/models/tool_use_block.rb +6 -0
  56. data/lib/anthropic/models.rb +4 -4
  57. data/lib/anthropic/resources/beta/messages.rb +5 -5
  58. data/lib/anthropic/resources/messages.rb +68 -7
  59. data/lib/anthropic/streaming.rb +5 -0
  60. data/lib/anthropic/version.rb +1 -1
  61. data/lib/anthropic.rb +8 -0
  62. data/rbi/anthropic/errors.rbi +16 -0
  63. data/rbi/anthropic/helpers/streaming/events.rbi +85 -0
  64. data/rbi/anthropic/helpers/streaming/message_stream.rbi +59 -0
  65. data/rbi/anthropic/internal/type/base_stream.rbi +8 -1
  66. data/rbi/anthropic/internal/type/boolean.rbi +2 -0
  67. data/rbi/anthropic/internal/type/converter.rbi +15 -15
  68. data/rbi/anthropic/internal/type/union.rbi +5 -0
  69. data/rbi/anthropic/internal/type/unknown.rbi +2 -0
  70. data/rbi/anthropic/internal/util.rbi +2 -0
  71. data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +1 -128
  72. data/rbi/anthropic/models/beta/beta_citation_search_result_location.rbi +78 -0
  73. data/rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi +79 -0
  74. data/rbi/anthropic/models/beta/beta_citations_delta.rbi +4 -2
  75. data/rbi/anthropic/models/beta/beta_content_block.rbi +3 -3
  76. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +8 -7
  77. data/rbi/anthropic/models/beta/beta_message.rbi +11 -3
  78. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +6 -6
  79. data/rbi/anthropic/models/beta/beta_request_document_block.rbi +140 -0
  80. data/rbi/anthropic/models/beta/beta_search_result_block_param.rbi +91 -0
  81. data/rbi/anthropic/models/beta/beta_text_block.rbi +2 -1
  82. data/rbi/anthropic/models/beta/beta_text_block_param.rbi +6 -3
  83. data/rbi/anthropic/models/beta/beta_text_citation.rbi +2 -1
  84. data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +2 -1
  85. data/rbi/anthropic/models/beta/beta_tool.rbi +14 -5
  86. data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +2 -1
  87. data/rbi/anthropic/models/beta/beta_tool_union.rbi +5 -5
  88. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +39 -27
  89. data/rbi/anthropic/models/beta/message_create_params.rbi +34 -22
  90. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +34 -22
  91. data/rbi/anthropic/models/content_block.rbi +3 -3
  92. data/rbi/anthropic/models/content_block_param.rbi +5 -5
  93. data/rbi/anthropic/models/message.rbi +11 -3
  94. data/rbi/anthropic/models/message_count_tokens_params.rbi +18 -2
  95. data/rbi/anthropic/models/message_count_tokens_tool.rbi +61 -0
  96. data/rbi/anthropic/models/message_create_params.rbi +18 -2
  97. data/rbi/anthropic/models/messages/batch_create_params.rbi +18 -2
  98. data/rbi/anthropic/models/raw_content_block_start_event.rbi +6 -6
  99. data/rbi/anthropic/models/tool.rbi +16 -5
  100. data/rbi/anthropic/models/tool_union.rbi +61 -0
  101. data/rbi/anthropic/resources/beta/messages.rbi +36 -18
  102. data/rbi/anthropic/resources/messages.rbi +293 -3
  103. data/rbi/anthropic/streaming.rbi +5 -0
  104. data/sig/anthropic/errors.rbs +9 -0
  105. data/sig/anthropic/helpers/streaming/events.rbs +119 -0
  106. data/sig/anthropic/helpers/streaming/message_stream.rbs +55 -0
  107. data/sig/anthropic/internal/type/base_stream.rbs +4 -0
  108. data/sig/anthropic/internal/type/converter.rbs +7 -1
  109. data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +1 -58
  110. data/sig/anthropic/models/beta/beta_citation_search_result_location.rbs +54 -0
  111. data/sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs +54 -0
  112. data/sig/anthropic/models/beta/beta_citations_delta.rbs +1 -0
  113. data/sig/anthropic/models/beta/beta_content_block.rbs +2 -2
  114. data/sig/anthropic/models/beta/beta_content_block_param.rbs +9 -8
  115. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -2
  116. data/sig/anthropic/models/beta/beta_request_document_block.rbs +66 -0
  117. data/sig/anthropic/models/beta/beta_search_result_block_param.rbs +53 -0
  118. data/sig/anthropic/models/beta/beta_text_citation.rbs +1 -0
  119. data/sig/anthropic/models/beta/beta_text_citation_param.rbs +1 -0
  120. data/sig/anthropic/models/beta/beta_tool.rbs +14 -3
  121. data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +1 -0
  122. data/sig/anthropic/models/beta/beta_tool_union.rbs +4 -4
  123. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +4 -4
  124. data/sig/anthropic/models/content_block.rbs +2 -2
  125. data/sig/anthropic/models/content_block_param.rbs +5 -5
  126. data/sig/anthropic/models/message_count_tokens_tool.rbs +28 -0
  127. data/sig/anthropic/models/raw_content_block_start_event.rbs +2 -2
  128. data/sig/anthropic/models/tool.rbs +14 -3
  129. data/sig/anthropic/models/tool_union.rbs +28 -0
  130. data/sig/anthropic/streaming.rbs +3 -0
  131. metadata +26 -3
@@ -40,7 +40,8 @@ module Anthropic
40
40
  Anthropic::Beta::BetaCitationCharLocationParam,
41
41
  Anthropic::Beta::BetaCitationPageLocationParam,
42
42
  Anthropic::Beta::BetaCitationContentBlockLocationParam,
43
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam
43
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam,
44
+ Anthropic::Beta::BetaCitationSearchResultLocationParam
44
45
  )
45
46
  ]
46
47
  )
@@ -60,7 +61,8 @@ module Anthropic
60
61
  Anthropic::Beta::BetaCitationCharLocationParam::OrHash,
61
62
  Anthropic::Beta::BetaCitationPageLocationParam::OrHash,
62
63
  Anthropic::Beta::BetaCitationContentBlockLocationParam::OrHash,
63
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam::OrHash
64
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam::OrHash,
65
+ Anthropic::Beta::BetaCitationSearchResultLocationParam::OrHash
64
66
  )
65
67
  ]
66
68
  ),
@@ -90,7 +92,8 @@ module Anthropic
90
92
  Anthropic::Beta::BetaCitationCharLocationParam,
91
93
  Anthropic::Beta::BetaCitationPageLocationParam,
92
94
  Anthropic::Beta::BetaCitationContentBlockLocationParam,
93
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam
95
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam,
96
+ Anthropic::Beta::BetaCitationSearchResultLocationParam
94
97
  )
95
98
  ]
96
99
  )
@@ -14,7 +14,8 @@ module Anthropic
14
14
  Anthropic::Beta::BetaCitationCharLocation,
15
15
  Anthropic::Beta::BetaCitationPageLocation,
16
16
  Anthropic::Beta::BetaCitationContentBlockLocation,
17
- Anthropic::Beta::BetaCitationsWebSearchResultLocation
17
+ Anthropic::Beta::BetaCitationsWebSearchResultLocation,
18
+ Anthropic::Beta::BetaCitationSearchResultLocation
18
19
  )
19
20
  end
20
21
 
@@ -14,7 +14,8 @@ module Anthropic
14
14
  Anthropic::Beta::BetaCitationCharLocationParam,
15
15
  Anthropic::Beta::BetaCitationPageLocationParam,
16
16
  Anthropic::Beta::BetaCitationContentBlockLocationParam,
17
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam
17
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam,
18
+ Anthropic::Beta::BetaCitationSearchResultLocationParam
18
19
  )
19
20
  end
20
21
 
@@ -121,21 +121,30 @@ module Anthropic
121
121
  sig { returns(T.nilable(T.anything)) }
122
122
  attr_accessor :properties
123
123
 
124
+ sig { returns(T.nilable(T::Array[String])) }
125
+ attr_accessor :required
126
+
124
127
  # [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
125
128
  #
126
129
  # This defines the shape of the `input` that your tool accepts and that the model
127
130
  # will produce.
128
131
  sig do
129
- params(properties: T.nilable(T.anything), type: Symbol).returns(
130
- T.attached_class
131
- )
132
+ params(
133
+ properties: T.nilable(T.anything),
134
+ required: T.nilable(T::Array[String]),
135
+ type: Symbol
136
+ ).returns(T.attached_class)
132
137
  end
133
- def self.new(properties: nil, type: :object)
138
+ def self.new(properties: nil, required: nil, type: :object)
134
139
  end
135
140
 
136
141
  sig do
137
142
  override.returns(
138
- { type: Symbol, properties: T.nilable(T.anything) }
143
+ {
144
+ type: Symbol,
145
+ properties: T.nilable(T.anything),
146
+ required: T.nilable(T::Array[String])
147
+ }
139
148
  )
140
149
  end
141
150
  def to_hash
@@ -112,7 +112,8 @@ module Anthropic
112
112
  T.type_alias do
113
113
  T.any(
114
114
  Anthropic::Beta::BetaTextBlockParam,
115
- Anthropic::Beta::BetaImageBlockParam
115
+ Anthropic::Beta::BetaImageBlockParam,
116
+ Anthropic::Beta::BetaSearchResultBlockParam
116
117
  )
117
118
  end
118
119
 
@@ -12,15 +12,15 @@ module Anthropic
12
12
  T.type_alias do
13
13
  T.any(
14
14
  Anthropic::Beta::BetaTool,
15
- Anthropic::Beta::BetaToolComputerUse20241022,
16
15
  Anthropic::Beta::BetaToolBash20241022,
17
- Anthropic::Beta::BetaToolTextEditor20241022,
18
- Anthropic::Beta::BetaToolComputerUse20250124,
19
16
  Anthropic::Beta::BetaToolBash20250124,
17
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
18
+ Anthropic::Beta::BetaToolComputerUse20241022,
19
+ Anthropic::Beta::BetaToolComputerUse20250124,
20
+ Anthropic::Beta::BetaToolTextEditor20241022,
20
21
  Anthropic::Beta::BetaToolTextEditor20250124,
21
22
  Anthropic::Beta::BetaToolTextEditor20250429,
22
- Anthropic::Beta::BetaWebSearchTool20250305,
23
- Anthropic::Beta::BetaCodeExecutionTool20250522
23
+ Anthropic::Beta::BetaWebSearchTool20250305
24
24
  )
25
25
  end
26
26
 
@@ -102,7 +102,7 @@ module Anthropic
102
102
  # the top-level `system` parameter — there is no `"system"` role for input
103
103
  # messages in the Messages API.
104
104
  #
105
- # There is a limit of 100000 messages in a single request.
105
+ # There is a limit of 100,000 messages in a single request.
106
106
  sig { returns(T::Array[Anthropic::Beta::BetaMessageParam]) }
107
107
  attr_accessor :messages
108
108
 
@@ -221,6 +221,12 @@ module Anthropic
221
221
  # those tools using the tool input generated by the model and then optionally
222
222
  # return results back to the model using `tool_result` content blocks.
223
223
  #
224
+ # There are two types of tools: **client tools** and **server tools**. The
225
+ # behavior described below applies to client tools. For
226
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
227
+ # see their individual documentation as each has its own behavior (e.g., the
228
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
229
+ #
224
230
  # Each tool definition includes:
225
231
  #
226
232
  # - `name`: Name of the tool.
@@ -289,15 +295,15 @@ module Anthropic
289
295
  T::Array[
290
296
  T.any(
291
297
  Anthropic::Beta::BetaTool,
292
- Anthropic::Beta::BetaToolComputerUse20241022,
293
298
  Anthropic::Beta::BetaToolBash20241022,
294
- Anthropic::Beta::BetaToolTextEditor20241022,
295
- Anthropic::Beta::BetaToolComputerUse20250124,
296
299
  Anthropic::Beta::BetaToolBash20250124,
300
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
301
+ Anthropic::Beta::BetaToolComputerUse20241022,
302
+ Anthropic::Beta::BetaToolComputerUse20250124,
303
+ Anthropic::Beta::BetaToolTextEditor20241022,
297
304
  Anthropic::Beta::BetaToolTextEditor20250124,
298
305
  Anthropic::Beta::BetaToolTextEditor20250429,
299
- Anthropic::Beta::BetaWebSearchTool20250305,
300
- Anthropic::Beta::BetaCodeExecutionTool20250522
306
+ Anthropic::Beta::BetaWebSearchTool20250305
301
307
  )
302
308
  ]
303
309
  )
@@ -311,15 +317,15 @@ module Anthropic
311
317
  T::Array[
312
318
  T.any(
313
319
  Anthropic::Beta::BetaTool::OrHash,
314
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
315
320
  Anthropic::Beta::BetaToolBash20241022::OrHash,
316
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
317
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
318
321
  Anthropic::Beta::BetaToolBash20250124::OrHash,
322
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
323
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
324
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
325
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
319
326
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
320
327
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
321
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
322
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
328
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
323
329
  )
324
330
  ]
325
331
  ).void
@@ -369,15 +375,15 @@ module Anthropic
369
375
  T::Array[
370
376
  T.any(
371
377
  Anthropic::Beta::BetaTool::OrHash,
372
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
373
378
  Anthropic::Beta::BetaToolBash20241022::OrHash,
374
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
375
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
376
379
  Anthropic::Beta::BetaToolBash20250124::OrHash,
380
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
381
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
382
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
383
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
377
384
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
378
385
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
379
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
380
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
386
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
381
387
  )
382
388
  ],
383
389
  betas: T::Array[T.any(String, Anthropic::AnthropicBeta::OrSymbol)],
@@ -472,7 +478,7 @@ module Anthropic
472
478
  # the top-level `system` parameter — there is no `"system"` role for input
473
479
  # messages in the Messages API.
474
480
  #
475
- # There is a limit of 100000 messages in a single request.
481
+ # There is a limit of 100,000 messages in a single request.
476
482
  messages:,
477
483
  # The model that will complete your prompt.\n\nSee
478
484
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -506,6 +512,12 @@ module Anthropic
506
512
  # those tools using the tool input generated by the model and then optionally
507
513
  # return results back to the model using `tool_result` content blocks.
508
514
  #
515
+ # There are two types of tools: **client tools** and **server tools**. The
516
+ # behavior described below applies to client tools. For
517
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
518
+ # see their individual documentation as each has its own behavior (e.g., the
519
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
520
+ #
509
521
  # Each tool definition includes:
510
522
  #
511
523
  # - `name`: Name of the tool.
@@ -600,15 +612,15 @@ module Anthropic
600
612
  T::Array[
601
613
  T.any(
602
614
  Anthropic::Beta::BetaTool,
603
- Anthropic::Beta::BetaToolComputerUse20241022,
604
615
  Anthropic::Beta::BetaToolBash20241022,
605
- Anthropic::Beta::BetaToolTextEditor20241022,
606
- Anthropic::Beta::BetaToolComputerUse20250124,
607
616
  Anthropic::Beta::BetaToolBash20250124,
617
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
618
+ Anthropic::Beta::BetaToolComputerUse20241022,
619
+ Anthropic::Beta::BetaToolComputerUse20250124,
620
+ Anthropic::Beta::BetaToolTextEditor20241022,
608
621
  Anthropic::Beta::BetaToolTextEditor20250124,
609
622
  Anthropic::Beta::BetaToolTextEditor20250429,
610
- Anthropic::Beta::BetaWebSearchTool20250305,
611
- Anthropic::Beta::BetaCodeExecutionTool20250522
623
+ Anthropic::Beta::BetaWebSearchTool20250305
612
624
  )
613
625
  ],
614
626
  betas:
@@ -659,15 +671,15 @@ module Anthropic
659
671
  T.type_alias do
660
672
  T.any(
661
673
  Anthropic::Beta::BetaTool,
662
- Anthropic::Beta::BetaToolComputerUse20241022,
663
674
  Anthropic::Beta::BetaToolBash20241022,
664
- Anthropic::Beta::BetaToolTextEditor20241022,
665
- Anthropic::Beta::BetaToolComputerUse20250124,
666
675
  Anthropic::Beta::BetaToolBash20250124,
676
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
677
+ Anthropic::Beta::BetaToolComputerUse20241022,
678
+ Anthropic::Beta::BetaToolComputerUse20250124,
679
+ Anthropic::Beta::BetaToolTextEditor20241022,
667
680
  Anthropic::Beta::BetaToolTextEditor20250124,
668
681
  Anthropic::Beta::BetaToolTextEditor20250429,
669
- Anthropic::Beta::BetaWebSearchTool20250305,
670
- Anthropic::Beta::BetaCodeExecutionTool20250522
682
+ Anthropic::Beta::BetaWebSearchTool20250305
671
683
  )
672
684
  end
673
685
 
@@ -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,15 @@ 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::BetaWebSearchTool20250305
371
377
  )
372
378
  ]
373
379
  )
@@ -381,15 +387,15 @@ module Anthropic
381
387
  T::Array[
382
388
  T.any(
383
389
  Anthropic::Beta::BetaTool::OrHash,
384
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
385
390
  Anthropic::Beta::BetaToolBash20241022::OrHash,
386
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
387
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
388
391
  Anthropic::Beta::BetaToolBash20250124::OrHash,
392
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
393
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
394
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
395
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
389
396
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
390
397
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
391
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
392
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
398
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
393
399
  )
394
400
  ]
395
401
  ).void
@@ -473,15 +479,15 @@ module Anthropic
473
479
  T::Array[
474
480
  T.any(
475
481
  Anthropic::Beta::BetaTool::OrHash,
476
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
477
482
  Anthropic::Beta::BetaToolBash20241022::OrHash,
478
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
479
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
480
483
  Anthropic::Beta::BetaToolBash20250124::OrHash,
484
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
485
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
486
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
487
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
481
488
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
482
489
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
483
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
484
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
490
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
485
491
  )
486
492
  ],
487
493
  top_k: Integer,
@@ -586,7 +592,7 @@ module Anthropic
586
592
  # the top-level `system` parameter — there is no `"system"` role for input
587
593
  # messages in the Messages API.
588
594
  #
589
- # There is a limit of 100000 messages in a single request.
595
+ # There is a limit of 100,000 messages in a single request.
590
596
  messages:,
591
597
  # The model that will complete your prompt.\n\nSee
592
598
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -649,6 +655,12 @@ module Anthropic
649
655
  # those tools using the tool input generated by the model and then optionally
650
656
  # return results back to the model using `tool_result` content blocks.
651
657
  #
658
+ # There are two types of tools: **client tools** and **server tools**. The
659
+ # behavior described below applies to client tools. For
660
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
661
+ # see their individual documentation as each has its own behavior (e.g., the
662
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
663
+ #
652
664
  # Each tool definition includes:
653
665
  #
654
666
  # - `name`: Name of the tool.
@@ -767,15 +779,15 @@ module Anthropic
767
779
  T::Array[
768
780
  T.any(
769
781
  Anthropic::Beta::BetaTool,
770
- Anthropic::Beta::BetaToolComputerUse20241022,
771
782
  Anthropic::Beta::BetaToolBash20241022,
772
- Anthropic::Beta::BetaToolTextEditor20241022,
773
- Anthropic::Beta::BetaToolComputerUse20250124,
774
783
  Anthropic::Beta::BetaToolBash20250124,
784
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
785
+ Anthropic::Beta::BetaToolComputerUse20241022,
786
+ Anthropic::Beta::BetaToolComputerUse20250124,
787
+ Anthropic::Beta::BetaToolTextEditor20241022,
775
788
  Anthropic::Beta::BetaToolTextEditor20250124,
776
789
  Anthropic::Beta::BetaToolTextEditor20250429,
777
- Anthropic::Beta::BetaWebSearchTool20250305,
778
- Anthropic::Beta::BetaCodeExecutionTool20250522
790
+ Anthropic::Beta::BetaWebSearchTool20250305
779
791
  )
780
792
  ],
781
793
  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,15 @@ 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::BetaWebSearchTool20250305
527
533
  )
528
534
  ]
529
535
  )
@@ -537,15 +543,15 @@ module Anthropic
537
543
  T::Array[
538
544
  T.any(
539
545
  Anthropic::Beta::BetaTool::OrHash,
540
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
541
546
  Anthropic::Beta::BetaToolBash20241022::OrHash,
542
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
543
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
544
547
  Anthropic::Beta::BetaToolBash20250124::OrHash,
548
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
549
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
550
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
551
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
545
552
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
546
553
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
547
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
548
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
554
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
549
555
  )
550
556
  ]
551
557
  ).void
@@ -618,15 +624,15 @@ module Anthropic
618
624
  T::Array[
619
625
  T.any(
620
626
  Anthropic::Beta::BetaTool::OrHash,
621
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
622
627
  Anthropic::Beta::BetaToolBash20241022::OrHash,
623
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
624
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
625
628
  Anthropic::Beta::BetaToolBash20250124::OrHash,
629
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
630
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
631
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
632
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
626
633
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
627
634
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
628
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
629
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
635
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
630
636
  )
631
637
  ],
632
638
  top_k: Integer,
@@ -729,7 +735,7 @@ module Anthropic
729
735
  # the top-level `system` parameter — there is no `"system"` role for input
730
736
  # messages in the Messages API.
731
737
  #
732
- # There is a limit of 100000 messages in a single request.
738
+ # There is a limit of 100,000 messages in a single request.
733
739
  messages:,
734
740
  # The model that will complete your prompt.\n\nSee
735
741
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -797,6 +803,12 @@ module Anthropic
797
803
  # those tools using the tool input generated by the model and then optionally
798
804
  # return results back to the model using `tool_result` content blocks.
799
805
  #
806
+ # There are two types of tools: **client tools** and **server tools**. The
807
+ # behavior described below applies to client tools. For
808
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
809
+ # see their individual documentation as each has its own behavior (e.g., the
810
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
811
+ #
800
812
  # Each tool definition includes:
801
813
  #
802
814
  # - `name`: Name of the tool.
@@ -916,15 +928,15 @@ module Anthropic
916
928
  T::Array[
917
929
  T.any(
918
930
  Anthropic::Beta::BetaTool,
919
- Anthropic::Beta::BetaToolComputerUse20241022,
920
931
  Anthropic::Beta::BetaToolBash20241022,
921
- Anthropic::Beta::BetaToolTextEditor20241022,
922
- Anthropic::Beta::BetaToolComputerUse20250124,
923
932
  Anthropic::Beta::BetaToolBash20250124,
933
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
934
+ Anthropic::Beta::BetaToolComputerUse20241022,
935
+ Anthropic::Beta::BetaToolComputerUse20250124,
936
+ Anthropic::Beta::BetaToolTextEditor20241022,
924
937
  Anthropic::Beta::BetaToolTextEditor20250124,
925
938
  Anthropic::Beta::BetaToolTextEditor20250429,
926
- Anthropic::Beta::BetaWebSearchTool20250305,
927
- Anthropic::Beta::BetaCodeExecutionTool20250522
939
+ Anthropic::Beta::BetaWebSearchTool20250305
928
940
  )
929
941
  ],
930
942
  top_k: Integer,
@@ -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,15 @@ 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,
19
15
  Anthropic::ThinkingBlockParam,
20
- Anthropic::RedactedThinkingBlockParam
16
+ Anthropic::RedactedThinkingBlockParam,
17
+ Anthropic::ToolUseBlockParam,
18
+ Anthropic::ToolResultBlockParam,
19
+ Anthropic::ServerToolUseBlockParam,
20
+ Anthropic::WebSearchToolResultBlockParam
21
21
  )
22
22
  end
23
23
 
@@ -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.