anthropic 1.16.2 → 1.17.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 (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/README.md +38 -10
  4. data/lib/anthropic/helpers/messages.rb +87 -2
  5. data/lib/anthropic/helpers/streaming/message_stream.rb +54 -29
  6. data/lib/anthropic/models/beta/beta_code_execution_tool_20250522.rb +2 -1
  7. data/lib/anthropic/models/beta/beta_code_execution_tool_20250825.rb +2 -1
  8. data/lib/anthropic/models/beta/beta_memory_tool_20250818.rb +2 -1
  9. data/lib/anthropic/models/beta/beta_output_config.rb +22 -4
  10. data/lib/anthropic/models/beta/beta_server_tool_use_block.rb +25 -25
  11. data/lib/anthropic/models/beta/beta_tool.rb +2 -1
  12. data/lib/anthropic/models/beta/beta_tool_bash_20241022.rb +2 -1
  13. data/lib/anthropic/models/beta/beta_tool_bash_20250124.rb +2 -1
  14. data/lib/anthropic/models/beta/beta_tool_computer_use_20241022.rb +2 -1
  15. data/lib/anthropic/models/beta/beta_tool_computer_use_20250124.rb +2 -1
  16. data/lib/anthropic/models/beta/beta_tool_computer_use_20251124.rb +2 -1
  17. data/lib/anthropic/models/beta/beta_tool_search_tool_bm25_20251119.rb +2 -1
  18. data/lib/anthropic/models/beta/beta_tool_search_tool_regex_20251119.rb +2 -1
  19. data/lib/anthropic/models/beta/beta_tool_text_editor_20241022.rb +2 -1
  20. data/lib/anthropic/models/beta/beta_tool_text_editor_20250124.rb +2 -1
  21. data/lib/anthropic/models/beta/beta_tool_text_editor_20250429.rb +2 -1
  22. data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +2 -1
  23. data/lib/anthropic/models/beta/beta_web_fetch_tool_20250910.rb +2 -1
  24. data/lib/anthropic/models/beta/beta_web_search_tool_20250305.rb +2 -1
  25. data/lib/anthropic/models/beta/beta_web_search_tool_result_error_code.rb +1 -0
  26. data/lib/anthropic/models/beta/message_count_tokens_params.rb +10 -5
  27. data/lib/anthropic/models/beta/message_create_params.rb +10 -5
  28. data/lib/anthropic/models/beta/messages/batch_create_params.rb +10 -5
  29. data/lib/anthropic/models/json_output_format.rb +23 -0
  30. data/lib/anthropic/models/message.rb +12 -0
  31. data/lib/anthropic/models/message_count_tokens_params.rb +9 -1
  32. data/lib/anthropic/models/message_create_params.rb +9 -1
  33. data/lib/anthropic/models/messages/batch_create_params.rb +9 -1
  34. data/lib/anthropic/models/model.rb +6 -0
  35. data/lib/anthropic/models/output_config.rb +20 -0
  36. data/lib/anthropic/models/text_block.rb +8 -0
  37. data/lib/anthropic/models/tool.rb +9 -1
  38. data/lib/anthropic/models/tool_bash_20250124.rb +9 -1
  39. data/lib/anthropic/models/tool_text_editor_20250124.rb +9 -1
  40. data/lib/anthropic/models/tool_text_editor_20250429.rb +9 -1
  41. data/lib/anthropic/models/tool_text_editor_20250728.rb +9 -1
  42. data/lib/anthropic/models/web_search_tool_20250305.rb +9 -1
  43. data/lib/anthropic/models/web_search_tool_request_error.rb +1 -0
  44. data/lib/anthropic/models/web_search_tool_result_error.rb +1 -0
  45. data/lib/anthropic/models.rb +4 -0
  46. data/lib/anthropic/resources/beta/messages.rb +26 -14
  47. data/lib/anthropic/resources/messages.rb +15 -4
  48. data/lib/anthropic/version.rb +1 -1
  49. data/lib/anthropic.rb +2 -0
  50. data/rbi/anthropic/models/beta/beta_code_execution_tool_20250522.rbi +2 -0
  51. data/rbi/anthropic/models/beta/beta_code_execution_tool_20250825.rbi +2 -0
  52. data/rbi/anthropic/models/beta/beta_memory_tool_20250818.rbi +2 -0
  53. data/rbi/anthropic/models/beta/beta_output_config.rbi +32 -6
  54. data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +48 -36
  55. data/rbi/anthropic/models/beta/beta_tool.rbi +2 -0
  56. data/rbi/anthropic/models/beta/beta_tool_bash_20241022.rbi +2 -0
  57. data/rbi/anthropic/models/beta/beta_tool_bash_20250124.rbi +2 -0
  58. data/rbi/anthropic/models/beta/beta_tool_computer_use_20241022.rbi +2 -0
  59. data/rbi/anthropic/models/beta/beta_tool_computer_use_20250124.rbi +2 -0
  60. data/rbi/anthropic/models/beta/beta_tool_computer_use_20251124.rbi +2 -0
  61. data/rbi/anthropic/models/beta/beta_tool_search_tool_bm25_20251119.rbi +2 -0
  62. data/rbi/anthropic/models/beta/beta_tool_search_tool_regex_20251119.rbi +2 -0
  63. data/rbi/anthropic/models/beta/beta_tool_text_editor_20241022.rbi +2 -0
  64. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250124.rbi +2 -0
  65. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250429.rbi +2 -0
  66. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +2 -0
  67. data/rbi/anthropic/models/beta/beta_web_fetch_tool_20250910.rbi +2 -0
  68. data/rbi/anthropic/models/beta/beta_web_search_tool_20250305.rbi +2 -0
  69. data/rbi/anthropic/models/beta/beta_web_search_tool_result_error_code.rbi +5 -0
  70. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +12 -6
  71. data/rbi/anthropic/models/beta/message_create_params.rbi +12 -6
  72. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +12 -6
  73. data/rbi/anthropic/models/json_output_format.rbi +37 -0
  74. data/rbi/anthropic/models/message.rbi +5 -0
  75. data/rbi/anthropic/models/message_count_tokens_params.rbi +11 -0
  76. data/rbi/anthropic/models/message_create_params.rbi +11 -0
  77. data/rbi/anthropic/models/messages/batch_create_params.rbi +11 -0
  78. data/rbi/anthropic/models/output_config.rbi +40 -0
  79. data/rbi/anthropic/models/tool.rbi +11 -0
  80. data/rbi/anthropic/models/tool_bash_20250124.rbi +12 -1
  81. data/rbi/anthropic/models/tool_text_editor_20250124.rbi +12 -1
  82. data/rbi/anthropic/models/tool_text_editor_20250429.rbi +12 -1
  83. data/rbi/anthropic/models/tool_text_editor_20250728.rbi +12 -1
  84. data/rbi/anthropic/models/web_search_tool_20250305.rbi +11 -0
  85. data/rbi/anthropic/models/web_search_tool_request_error.rbi +5 -0
  86. data/rbi/anthropic/models/web_search_tool_result_error.rbi +5 -0
  87. data/rbi/anthropic/models.rbi +4 -0
  88. data/rbi/anthropic/resources/beta/messages.rbi +21 -9
  89. data/rbi/anthropic/resources/messages.rbi +9 -0
  90. data/sig/anthropic/models/beta/beta_output_config.rbs +10 -3
  91. data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +21 -17
  92. data/sig/anthropic/models/beta/beta_web_search_tool_result_error_code.rbs +2 -0
  93. data/sig/anthropic/models/json_output_format.rbs +16 -0
  94. data/sig/anthropic/models/message_count_tokens_params.rbs +7 -0
  95. data/sig/anthropic/models/message_create_params.rbs +7 -0
  96. data/sig/anthropic/models/messages/batch_create_params.rbs +9 -0
  97. data/sig/anthropic/models/output_config.rbs +13 -0
  98. data/sig/anthropic/models/tool.rbs +7 -0
  99. data/sig/anthropic/models/tool_bash_20250124.rbs +9 -2
  100. data/sig/anthropic/models/tool_text_editor_20250124.rbs +9 -2
  101. data/sig/anthropic/models/tool_text_editor_20250429.rbs +9 -2
  102. data/sig/anthropic/models/tool_text_editor_20250728.rbs +9 -2
  103. data/sig/anthropic/models/web_search_tool_20250305.rbs +7 -0
  104. data/sig/anthropic/models/web_search_tool_request_error.rbs +2 -0
  105. data/sig/anthropic/models/web_search_tool_result_error.rbs +2 -0
  106. data/sig/anthropic/models.rbs +4 -0
  107. data/sig/anthropic/resources/messages.rbs +3 -0
  108. metadata +22 -2
@@ -77,6 +77,7 @@ module Anthropic
77
77
  sig { returns(T.nilable(Integer)) }
78
78
  attr_accessor :max_characters
79
79
 
80
+ # When true, guarantees schema validation on tool names and inputs
80
81
  sig { returns(T.nilable(T::Boolean)) }
81
82
  attr_reader :strict
82
83
 
@@ -110,6 +111,7 @@ module Anthropic
110
111
  # Maximum number of characters to display when viewing a file. If not specified,
111
112
  # defaults to displaying the full file.
112
113
  max_characters: nil,
114
+ # When true, guarantees schema validation on tool names and inputs
113
115
  strict: nil,
114
116
  # Name of the tool.
115
117
  #
@@ -94,6 +94,7 @@ module Anthropic
94
94
  sig { returns(T.nilable(Integer)) }
95
95
  attr_accessor :max_uses
96
96
 
97
+ # When true, guarantees schema validation on tool names and inputs
97
98
  sig { returns(T.nilable(T::Boolean)) }
98
99
  attr_reader :strict
99
100
 
@@ -139,6 +140,7 @@ module Anthropic
139
140
  max_content_tokens: nil,
140
141
  # Maximum number of times the tool can be used in the API request.
141
142
  max_uses: nil,
143
+ # When true, guarantees schema validation on tool names and inputs
142
144
  strict: nil,
143
145
  # Name of the tool.
144
146
  #
@@ -78,6 +78,7 @@ module Anthropic
78
78
  sig { returns(T.nilable(Integer)) }
79
79
  attr_accessor :max_uses
80
80
 
81
+ # When true, guarantees schema validation on tool names and inputs
81
82
  sig { returns(T.nilable(T::Boolean)) }
82
83
  attr_reader :strict
83
84
 
@@ -139,6 +140,7 @@ module Anthropic
139
140
  defer_loading: nil,
140
141
  # Maximum number of times the tool can be used in the API request.
141
142
  max_uses: nil,
143
+ # When true, guarantees schema validation on tool names and inputs
142
144
  strict: nil,
143
145
  # Parameters for the user's location. Used to provide more relevant search
144
146
  # results.
@@ -39,6 +39,11 @@ module Anthropic
39
39
  :query_too_long,
40
40
  Anthropic::Beta::BetaWebSearchToolResultErrorCode::TaggedSymbol
41
41
  )
42
+ REQUEST_TOO_LARGE =
43
+ T.let(
44
+ :request_too_large,
45
+ Anthropic::Beta::BetaWebSearchToolResultErrorCode::TaggedSymbol
46
+ )
42
47
 
43
48
  sig do
44
49
  override.returns(
@@ -124,8 +124,7 @@ module Anthropic
124
124
  end
125
125
  attr_writer :mcp_servers
126
126
 
127
- # Configuration options for the model's output. Controls aspects like how much
128
- # effort the model puts into its response.
127
+ # Configuration options for the model's output, such as the output format.
129
128
  sig { returns(T.nilable(Anthropic::Beta::BetaOutputConfig)) }
130
129
  attr_reader :output_config
131
130
 
@@ -134,7 +133,11 @@ module Anthropic
134
133
  end
135
134
  attr_writer :output_config
136
135
 
137
- # A schema to specify Claude's output format in responses.
136
+ # Deprecated: Use `output_config.format` instead. See
137
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
138
+ #
139
+ # A schema to specify Claude's output format in responses. This parameter will be
140
+ # removed in a future release.
138
141
  sig { returns(T.nilable(Anthropic::Beta::BetaJSONOutputFormat)) }
139
142
  attr_reader :output_format
140
143
 
@@ -511,10 +514,13 @@ module Anthropic
511
514
  context_management: nil,
512
515
  # MCP servers to be utilized in this request
513
516
  mcp_servers: nil,
514
- # Configuration options for the model's output. Controls aspects like how much
515
- # effort the model puts into its response.
517
+ # Configuration options for the model's output, such as the output format.
516
518
  output_config: nil,
517
- # A schema to specify Claude's output format in responses.
519
+ # Deprecated: Use `output_config.format` instead. See
520
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
521
+ #
522
+ # A schema to specify Claude's output format in responses. This parameter will be
523
+ # removed in a future release.
518
524
  output_format: nil,
519
525
  # System prompt.
520
526
  #
@@ -149,8 +149,7 @@ module Anthropic
149
149
  sig { params(metadata: Anthropic::Beta::BetaMetadata::OrHash).void }
150
150
  attr_writer :metadata
151
151
 
152
- # Configuration options for the model's output. Controls aspects like how much
153
- # effort the model puts into its response.
152
+ # Configuration options for the model's output, such as the output format.
154
153
  sig { returns(T.nilable(Anthropic::Beta::BetaOutputConfig)) }
155
154
  attr_reader :output_config
156
155
 
@@ -159,7 +158,11 @@ module Anthropic
159
158
  end
160
159
  attr_writer :output_config
161
160
 
162
- # A schema to specify Claude's output format in responses.
161
+ # Deprecated: Use `output_config.format` instead. See
162
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
163
+ #
164
+ # A schema to specify Claude's output format in responses. This parameter will be
165
+ # removed in a future release.
163
166
  sig { returns(T.nilable(Anthropic::Beta::BetaJSONOutputFormat)) }
164
167
  attr_reader :output_format
165
168
 
@@ -636,10 +639,13 @@ module Anthropic
636
639
  mcp_servers: nil,
637
640
  # An object describing metadata about the request.
638
641
  metadata: nil,
639
- # Configuration options for the model's output. Controls aspects like how much
640
- # effort the model puts into its response.
642
+ # Configuration options for the model's output, such as the output format.
641
643
  output_config: nil,
642
- # A schema to specify Claude's output format in responses.
644
+ # Deprecated: Use `output_config.format` instead. See
645
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
646
+ #
647
+ # A schema to specify Claude's output format in responses. This parameter will be
648
+ # removed in a future release.
643
649
  output_format: nil,
644
650
  # Determines whether to use priority capacity (if available) or standard capacity
645
651
  # for this request.
@@ -296,8 +296,7 @@ module Anthropic
296
296
  end
297
297
  attr_writer :metadata
298
298
 
299
- # Configuration options for the model's output. Controls aspects like how much
300
- # effort the model puts into its response.
299
+ # Configuration options for the model's output, such as the output format.
301
300
  sig { returns(T.nilable(Anthropic::Beta::BetaOutputConfig)) }
302
301
  attr_reader :output_config
303
302
 
@@ -308,7 +307,11 @@ module Anthropic
308
307
  end
309
308
  attr_writer :output_config
310
309
 
311
- # A schema to specify Claude's output format in responses.
310
+ # Deprecated: Use `output_config.format` instead. See
311
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
312
+ #
313
+ # A schema to specify Claude's output format in responses. This parameter will be
314
+ # removed in a future release.
312
315
  sig { returns(T.nilable(Anthropic::Beta::BetaJSONOutputFormat)) }
313
316
  attr_reader :output_format
314
317
 
@@ -789,10 +792,13 @@ module Anthropic
789
792
  mcp_servers: nil,
790
793
  # An object describing metadata about the request.
791
794
  metadata: nil,
792
- # Configuration options for the model's output. Controls aspects like how much
793
- # effort the model puts into its response.
795
+ # Configuration options for the model's output, such as the output format.
794
796
  output_config: nil,
795
- # A schema to specify Claude's output format in responses.
797
+ # Deprecated: Use `output_config.format` instead. See
798
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
799
+ #
800
+ # A schema to specify Claude's output format in responses. This parameter will be
801
+ # removed in a future release.
796
802
  output_format: nil,
797
803
  # Determines whether to use priority capacity (if available) or standard capacity
798
804
  # for this request.
@@ -0,0 +1,37 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ class JSONOutputFormat < Anthropic::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Anthropic::JSONOutputFormat, Anthropic::Internal::AnyHash)
9
+ end
10
+
11
+ # The JSON schema of the format
12
+ sig { returns(T::Hash[Symbol, T.anything]) }
13
+ attr_accessor :schema
14
+
15
+ sig { returns(Symbol) }
16
+ attr_accessor :type
17
+
18
+ sig do
19
+ params(schema: T::Hash[Symbol, T.anything], type: Symbol).returns(
20
+ T.attached_class
21
+ )
22
+ end
23
+ def self.new(
24
+ # The JSON schema of the format
25
+ schema:,
26
+ type: :json_schema
27
+ )
28
+ end
29
+
30
+ sig do
31
+ override.returns({ schema: T::Hash[Symbol, T.anything], type: Symbol })
32
+ end
33
+ def to_hash
34
+ end
35
+ end
36
+ end
37
+ end
@@ -47,6 +47,11 @@ module Anthropic
47
47
  sig { returns(T::Array[Anthropic::ContentBlock::Variants]) }
48
48
  attr_accessor :content
49
49
 
50
+ # Parsed value of response when a JSON output schema object has been specified via :output_config
51
+ sig { returns(T.untyped) }
52
+ def parsed_output
53
+ end
54
+
50
55
  # The model that will complete your prompt.\n\nSee
51
56
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
52
57
  # details and options.
@@ -88,6 +88,13 @@ module Anthropic
88
88
  sig { returns(T.any(Anthropic::Model::OrSymbol, String)) }
89
89
  attr_accessor :model
90
90
 
91
+ # Configuration options for the model's output, such as the output format.
92
+ sig { returns(T.nilable(Anthropic::OutputConfig)) }
93
+ attr_reader :output_config
94
+
95
+ sig { params(output_config: Anthropic::OutputConfig::OrHash).void }
96
+ attr_writer :output_config
97
+
91
98
  # System prompt.
92
99
  #
93
100
  # A system prompt is a way of providing context and instructions to Claude, such
@@ -282,6 +289,7 @@ module Anthropic
282
289
  params(
283
290
  messages: T::Array[Anthropic::MessageParam::OrHash],
284
291
  model: T.any(Anthropic::Model::OrSymbol, String),
292
+ output_config: Anthropic::OutputConfig::OrHash,
285
293
  system_: Anthropic::MessageCountTokensParams::System::Variants,
286
294
  thinking:
287
295
  T.any(
@@ -380,6 +388,8 @@ module Anthropic
380
388
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
381
389
  # details and options.
382
390
  model:,
391
+ # Configuration options for the model's output, such as the output format.
392
+ output_config: nil,
383
393
  # System prompt.
384
394
  #
385
395
  # A system prompt is a way of providing context and instructions to Claude, such
@@ -484,6 +494,7 @@ module Anthropic
484
494
  {
485
495
  messages: T::Array[Anthropic::MessageParam],
486
496
  model: T.any(Anthropic::Model::OrSymbol, String),
497
+ output_config: Anthropic::OutputConfig,
487
498
  system_: Anthropic::MessageCountTokensParams::System::Variants,
488
499
  thinking:
489
500
  T.any(
@@ -102,6 +102,13 @@ module Anthropic
102
102
  sig { params(metadata: Anthropic::Metadata::OrHash).void }
103
103
  attr_writer :metadata
104
104
 
105
+ # Configuration options for the model's output, such as the output format.
106
+ sig { returns(T.nilable(Anthropic::OutputConfig)) }
107
+ attr_reader :output_config
108
+
109
+ sig { params(output_config: Anthropic::OutputConfig::OrHash).void }
110
+ attr_writer :output_config
111
+
105
112
  # Determines whether to use priority capacity (if available) or standard capacity
106
113
  # for this request.
107
114
  #
@@ -370,6 +377,7 @@ module Anthropic
370
377
  messages: T::Array[Anthropic::MessageParam::OrHash],
371
378
  model: T.any(Anthropic::Model::OrSymbol, String),
372
379
  metadata: Anthropic::Metadata::OrHash,
380
+ output_config: Anthropic::OutputConfig::OrHash,
373
381
  service_tier: Anthropic::MessageCreateParams::ServiceTier::OrSymbol,
374
382
  stop_sequences: T::Array[String],
375
383
  system_: Anthropic::MessageCreateParams::System::Variants,
@@ -483,6 +491,8 @@ module Anthropic
483
491
  model:,
484
492
  # An object describing metadata about the request.
485
493
  metadata: nil,
494
+ # Configuration options for the model's output, such as the output format.
495
+ output_config: nil,
486
496
  # Determines whether to use priority capacity (if available) or standard capacity
487
497
  # for this request.
488
498
  #
@@ -632,6 +642,7 @@ module Anthropic
632
642
  messages: T::Array[Anthropic::MessageParam],
633
643
  model: T.any(Anthropic::Model::OrSymbol, String),
634
644
  metadata: Anthropic::Metadata,
645
+ output_config: Anthropic::OutputConfig,
635
646
  service_tier: Anthropic::MessageCreateParams::ServiceTier::OrSymbol,
636
647
  stop_sequences: T::Array[String],
637
648
  system_: Anthropic::MessageCreateParams::System::Variants,
@@ -214,6 +214,13 @@ module Anthropic
214
214
  sig { params(metadata: Anthropic::Metadata::OrHash).void }
215
215
  attr_writer :metadata
216
216
 
217
+ # Configuration options for the model's output, such as the output format.
218
+ sig { returns(T.nilable(Anthropic::OutputConfig)) }
219
+ attr_reader :output_config
220
+
221
+ sig { params(output_config: Anthropic::OutputConfig::OrHash).void }
222
+ attr_writer :output_config
223
+
217
224
  # Determines whether to use priority capacity (if available) or standard capacity
218
225
  # for this request.
219
226
  #
@@ -505,6 +512,7 @@ module Anthropic
505
512
  messages: T::Array[Anthropic::MessageParam::OrHash],
506
513
  model: T.any(Anthropic::Model::OrSymbol, String),
507
514
  metadata: Anthropic::Metadata::OrHash,
515
+ output_config: Anthropic::OutputConfig::OrHash,
508
516
  service_tier:
509
517
  Anthropic::Messages::BatchCreateParams::Request::Params::ServiceTier::OrSymbol,
510
518
  stop_sequences: T::Array[String],
@@ -620,6 +628,8 @@ module Anthropic
620
628
  model:,
621
629
  # An object describing metadata about the request.
622
630
  metadata: nil,
631
+ # Configuration options for the model's output, such as the output format.
632
+ output_config: nil,
623
633
  # Determines whether to use priority capacity (if available) or standard capacity
624
634
  # for this request.
625
635
  #
@@ -772,6 +782,7 @@ module Anthropic
772
782
  messages: T::Array[Anthropic::MessageParam],
773
783
  model: T.any(Anthropic::Model::OrSymbol, String),
774
784
  metadata: Anthropic::Metadata,
785
+ output_config: Anthropic::OutputConfig,
775
786
  service_tier:
776
787
  Anthropic::Messages::BatchCreateParams::Request::Params::ServiceTier::OrSymbol,
777
788
  stop_sequences: T::Array[String],
@@ -0,0 +1,40 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ class OutputConfig < Anthropic::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Anthropic::OutputConfig, Anthropic::Internal::AnyHash)
9
+ end
10
+
11
+ # A schema to specify Claude's output format in responses. See
12
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
13
+ sig { returns(T.nilable(Anthropic::JSONOutputFormat)) }
14
+ attr_reader :format_
15
+
16
+ sig do
17
+ params(format_: T.nilable(Anthropic::JSONOutputFormat::OrHash)).void
18
+ end
19
+ attr_writer :format_
20
+
21
+ sig do
22
+ params(format_: T.nilable(Anthropic::JSONOutputFormat::OrHash)).returns(
23
+ T.attached_class
24
+ )
25
+ end
26
+ def self.new(
27
+ # A schema to specify Claude's output format in responses. See
28
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
29
+ format_: nil
30
+ )
31
+ end
32
+
33
+ sig do
34
+ override.returns({ format_: T.nilable(Anthropic::JSONOutputFormat) })
35
+ end
36
+ def to_hash
37
+ end
38
+ end
39
+ end
40
+ end
@@ -45,6 +45,13 @@ module Anthropic
45
45
  sig { params(description: String).void }
46
46
  attr_writer :description
47
47
 
48
+ # When true, guarantees schema validation on tool names and inputs
49
+ sig { returns(T.nilable(T::Boolean)) }
50
+ attr_reader :strict
51
+
52
+ sig { params(strict: T::Boolean).void }
53
+ attr_writer :strict
54
+
48
55
  sig { returns(T.nilable(Anthropic::Tool::Type::OrSymbol)) }
49
56
  attr_accessor :type
50
57
 
@@ -54,6 +61,7 @@ module Anthropic
54
61
  name: String,
55
62
  cache_control: T.nilable(Anthropic::CacheControlEphemeral::OrHash),
56
63
  description: String,
64
+ strict: T::Boolean,
57
65
  type: T.nilable(Anthropic::Tool::Type::OrSymbol)
58
66
  ).returns(T.attached_class)
59
67
  end
@@ -76,6 +84,8 @@ module Anthropic
76
84
  # perform. You can use natural language descriptions to reinforce important
77
85
  # aspects of the tool input JSON schema.
78
86
  description: nil,
87
+ # When true, guarantees schema validation on tool names and inputs
88
+ strict: nil,
79
89
  type: nil
80
90
  )
81
91
  end
@@ -87,6 +97,7 @@ module Anthropic
87
97
  name: String,
88
98
  cache_control: T.nilable(Anthropic::CacheControlEphemeral),
89
99
  description: String,
100
+ strict: T::Boolean,
90
101
  type: T.nilable(Anthropic::Tool::Type::OrSymbol)
91
102
  }
92
103
  )
@@ -28,9 +28,17 @@ module Anthropic
28
28
  end
29
29
  attr_writer :cache_control
30
30
 
31
+ # When true, guarantees schema validation on tool names and inputs
32
+ sig { returns(T.nilable(T::Boolean)) }
33
+ attr_reader :strict
34
+
35
+ sig { params(strict: T::Boolean).void }
36
+ attr_writer :strict
37
+
31
38
  sig do
32
39
  params(
33
40
  cache_control: T.nilable(Anthropic::CacheControlEphemeral::OrHash),
41
+ strict: T::Boolean,
34
42
  name: Symbol,
35
43
  type: Symbol
36
44
  ).returns(T.attached_class)
@@ -38,6 +46,8 @@ module Anthropic
38
46
  def self.new(
39
47
  # Create a cache control breakpoint at this content block.
40
48
  cache_control: nil,
49
+ # When true, guarantees schema validation on tool names and inputs
50
+ strict: nil,
41
51
  # Name of the tool.
42
52
  #
43
53
  # This is how the tool will be called by the model and in `tool_use` blocks.
@@ -51,7 +61,8 @@ module Anthropic
51
61
  {
52
62
  name: Symbol,
53
63
  type: Symbol,
54
- cache_control: T.nilable(Anthropic::CacheControlEphemeral)
64
+ cache_control: T.nilable(Anthropic::CacheControlEphemeral),
65
+ strict: T::Boolean
55
66
  }
56
67
  )
57
68
  end
@@ -28,9 +28,17 @@ module Anthropic
28
28
  end
29
29
  attr_writer :cache_control
30
30
 
31
+ # When true, guarantees schema validation on tool names and inputs
32
+ sig { returns(T.nilable(T::Boolean)) }
33
+ attr_reader :strict
34
+
35
+ sig { params(strict: T::Boolean).void }
36
+ attr_writer :strict
37
+
31
38
  sig do
32
39
  params(
33
40
  cache_control: T.nilable(Anthropic::CacheControlEphemeral::OrHash),
41
+ strict: T::Boolean,
34
42
  name: Symbol,
35
43
  type: Symbol
36
44
  ).returns(T.attached_class)
@@ -38,6 +46,8 @@ module Anthropic
38
46
  def self.new(
39
47
  # Create a cache control breakpoint at this content block.
40
48
  cache_control: nil,
49
+ # When true, guarantees schema validation on tool names and inputs
50
+ strict: nil,
41
51
  # Name of the tool.
42
52
  #
43
53
  # This is how the tool will be called by the model and in `tool_use` blocks.
@@ -51,7 +61,8 @@ module Anthropic
51
61
  {
52
62
  name: Symbol,
53
63
  type: Symbol,
54
- cache_control: T.nilable(Anthropic::CacheControlEphemeral)
64
+ cache_control: T.nilable(Anthropic::CacheControlEphemeral),
65
+ strict: T::Boolean
55
66
  }
56
67
  )
57
68
  end
@@ -28,9 +28,17 @@ module Anthropic
28
28
  end
29
29
  attr_writer :cache_control
30
30
 
31
+ # When true, guarantees schema validation on tool names and inputs
32
+ sig { returns(T.nilable(T::Boolean)) }
33
+ attr_reader :strict
34
+
35
+ sig { params(strict: T::Boolean).void }
36
+ attr_writer :strict
37
+
31
38
  sig do
32
39
  params(
33
40
  cache_control: T.nilable(Anthropic::CacheControlEphemeral::OrHash),
41
+ strict: T::Boolean,
34
42
  name: Symbol,
35
43
  type: Symbol
36
44
  ).returns(T.attached_class)
@@ -38,6 +46,8 @@ module Anthropic
38
46
  def self.new(
39
47
  # Create a cache control breakpoint at this content block.
40
48
  cache_control: nil,
49
+ # When true, guarantees schema validation on tool names and inputs
50
+ strict: nil,
41
51
  # Name of the tool.
42
52
  #
43
53
  # This is how the tool will be called by the model and in `tool_use` blocks.
@@ -51,7 +61,8 @@ module Anthropic
51
61
  {
52
62
  name: Symbol,
53
63
  type: Symbol,
54
- cache_control: T.nilable(Anthropic::CacheControlEphemeral)
64
+ cache_control: T.nilable(Anthropic::CacheControlEphemeral),
65
+ strict: T::Boolean
55
66
  }
56
67
  )
57
68
  end
@@ -33,10 +33,18 @@ module Anthropic
33
33
  sig { returns(T.nilable(Integer)) }
34
34
  attr_accessor :max_characters
35
35
 
36
+ # When true, guarantees schema validation on tool names and inputs
37
+ sig { returns(T.nilable(T::Boolean)) }
38
+ attr_reader :strict
39
+
40
+ sig { params(strict: T::Boolean).void }
41
+ attr_writer :strict
42
+
36
43
  sig do
37
44
  params(
38
45
  cache_control: T.nilable(Anthropic::CacheControlEphemeral::OrHash),
39
46
  max_characters: T.nilable(Integer),
47
+ strict: T::Boolean,
40
48
  name: Symbol,
41
49
  type: Symbol
42
50
  ).returns(T.attached_class)
@@ -47,6 +55,8 @@ module Anthropic
47
55
  # Maximum number of characters to display when viewing a file. If not specified,
48
56
  # defaults to displaying the full file.
49
57
  max_characters: nil,
58
+ # When true, guarantees schema validation on tool names and inputs
59
+ strict: nil,
50
60
  # Name of the tool.
51
61
  #
52
62
  # This is how the tool will be called by the model and in `tool_use` blocks.
@@ -61,7 +71,8 @@ module Anthropic
61
71
  name: Symbol,
62
72
  type: Symbol,
63
73
  cache_control: T.nilable(Anthropic::CacheControlEphemeral),
64
- max_characters: T.nilable(Integer)
74
+ max_characters: T.nilable(Integer),
75
+ strict: T::Boolean
65
76
  }
66
77
  )
67
78
  end
@@ -42,6 +42,13 @@ module Anthropic
42
42
  sig { returns(T.nilable(Integer)) }
43
43
  attr_accessor :max_uses
44
44
 
45
+ # When true, guarantees schema validation on tool names and inputs
46
+ sig { returns(T.nilable(T::Boolean)) }
47
+ attr_reader :strict
48
+
49
+ sig { params(strict: T::Boolean).void }
50
+ attr_writer :strict
51
+
45
52
  # Parameters for the user's location. Used to provide more relevant search
46
53
  # results.
47
54
  sig { returns(T.nilable(Anthropic::WebSearchTool20250305::UserLocation)) }
@@ -61,6 +68,7 @@ module Anthropic
61
68
  blocked_domains: T.nilable(T::Array[String]),
62
69
  cache_control: T.nilable(Anthropic::CacheControlEphemeral::OrHash),
63
70
  max_uses: T.nilable(Integer),
71
+ strict: T::Boolean,
64
72
  user_location:
65
73
  T.nilable(Anthropic::WebSearchTool20250305::UserLocation::OrHash),
66
74
  name: Symbol,
@@ -78,6 +86,8 @@ module Anthropic
78
86
  cache_control: nil,
79
87
  # Maximum number of times the tool can be used in the API request.
80
88
  max_uses: nil,
89
+ # When true, guarantees schema validation on tool names and inputs
90
+ strict: nil,
81
91
  # Parameters for the user's location. Used to provide more relevant search
82
92
  # results.
83
93
  user_location: nil,
@@ -98,6 +108,7 @@ module Anthropic
98
108
  blocked_domains: T.nilable(T::Array[String]),
99
109
  cache_control: T.nilable(Anthropic::CacheControlEphemeral),
100
110
  max_uses: T.nilable(Integer),
111
+ strict: T::Boolean,
101
112
  user_location:
102
113
  T.nilable(Anthropic::WebSearchTool20250305::UserLocation)
103
114
  }
@@ -72,6 +72,11 @@ module Anthropic
72
72
  :query_too_long,
73
73
  Anthropic::WebSearchToolRequestError::ErrorCode::TaggedSymbol
74
74
  )
75
+ REQUEST_TOO_LARGE =
76
+ T.let(
77
+ :request_too_large,
78
+ Anthropic::WebSearchToolRequestError::ErrorCode::TaggedSymbol
79
+ )
75
80
 
76
81
  sig do
77
82
  override.returns(
@@ -74,6 +74,11 @@ module Anthropic
74
74
  :query_too_long,
75
75
  Anthropic::WebSearchToolResultError::ErrorCode::TaggedSymbol
76
76
  )
77
+ REQUEST_TOO_LARGE =
78
+ T.let(
79
+ :request_too_large,
80
+ Anthropic::WebSearchToolResultError::ErrorCode::TaggedSymbol
81
+ )
77
82
 
78
83
  sig do
79
84
  override.returns(
@@ -96,6 +96,8 @@ module Anthropic
96
96
 
97
97
  InvalidRequestError = Anthropic::Models::InvalidRequestError
98
98
 
99
+ JSONOutputFormat = Anthropic::Models::JSONOutputFormat
100
+
99
101
  Message = Anthropic::Models::Message
100
102
 
101
103
  MessageCountTokensParams = Anthropic::Models::MessageCountTokensParams
@@ -124,6 +126,8 @@ module Anthropic
124
126
 
125
127
  NotFoundError = Anthropic::Models::NotFoundError
126
128
 
129
+ OutputConfig = Anthropic::Models::OutputConfig
130
+
127
131
  OverloadedError = Anthropic::Models::OverloadedError
128
132
 
129
133
  PermissionError = Anthropic::Models::PermissionError