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
@@ -67,6 +67,7 @@ module Anthropic
67
67
  Anthropic::Internal::Type::ArrayOf[Anthropic::Internal::Type::HashOf[Anthropic::Internal::Type::Unknown]]
68
68
 
69
69
  # @!attribute strict
70
+ # When true, guarantees schema validation on tool names and inputs
70
71
  #
71
72
  # @return [Boolean, nil]
72
73
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -91,7 +92,7 @@ module Anthropic
91
92
  #
92
93
  # @param input_examples [Array<Hash{Symbol=>Object}>]
93
94
  #
94
- # @param strict [Boolean]
95
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
95
96
  #
96
97
  # @param name [Symbol, :computer] Name of the tool.
97
98
  #
@@ -37,6 +37,7 @@ module Anthropic
37
37
  optional :defer_loading, Anthropic::Internal::Type::Boolean
38
38
 
39
39
  # @!attribute strict
40
+ # When true, guarantees schema validation on tool names and inputs
40
41
  #
41
42
  # @return [Boolean, nil]
42
43
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -53,7 +54,7 @@ module Anthropic
53
54
  #
54
55
  # @param defer_loading [Boolean] If true, tool will not be included in initial system prompt. Only loaded when re
55
56
  #
56
- # @param strict [Boolean]
57
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
57
58
  #
58
59
  # @param name [Symbol, :tool_search_tool_bm25] Name of the tool.
59
60
 
@@ -37,6 +37,7 @@ module Anthropic
37
37
  optional :defer_loading, Anthropic::Internal::Type::Boolean
38
38
 
39
39
  # @!attribute strict
40
+ # When true, guarantees schema validation on tool names and inputs
40
41
  #
41
42
  # @return [Boolean, nil]
42
43
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -53,7 +54,7 @@ module Anthropic
53
54
  #
54
55
  # @param defer_loading [Boolean] If true, tool will not be included in initial system prompt. Only loaded when re
55
56
  #
56
- # @param strict [Boolean]
57
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
57
58
  #
58
59
  # @param name [Symbol, :tool_search_tool_regex] Name of the tool.
59
60
 
@@ -43,6 +43,7 @@ module Anthropic
43
43
  Anthropic::Internal::Type::ArrayOf[Anthropic::Internal::Type::HashOf[Anthropic::Internal::Type::Unknown]]
44
44
 
45
45
  # @!attribute strict
46
+ # When true, guarantees schema validation on tool names and inputs
46
47
  #
47
48
  # @return [Boolean, nil]
48
49
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -59,7 +60,7 @@ module Anthropic
59
60
  #
60
61
  # @param input_examples [Array<Hash{Symbol=>Object}>]
61
62
  #
62
- # @param strict [Boolean]
63
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
63
64
  #
64
65
  # @param name [Symbol, :str_replace_editor] Name of the tool.
65
66
  #
@@ -43,6 +43,7 @@ module Anthropic
43
43
  Anthropic::Internal::Type::ArrayOf[Anthropic::Internal::Type::HashOf[Anthropic::Internal::Type::Unknown]]
44
44
 
45
45
  # @!attribute strict
46
+ # When true, guarantees schema validation on tool names and inputs
46
47
  #
47
48
  # @return [Boolean, nil]
48
49
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -59,7 +60,7 @@ module Anthropic
59
60
  #
60
61
  # @param input_examples [Array<Hash{Symbol=>Object}>]
61
62
  #
62
- # @param strict [Boolean]
63
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
63
64
  #
64
65
  # @param name [Symbol, :str_replace_editor] Name of the tool.
65
66
  #
@@ -43,6 +43,7 @@ module Anthropic
43
43
  Anthropic::Internal::Type::ArrayOf[Anthropic::Internal::Type::HashOf[Anthropic::Internal::Type::Unknown]]
44
44
 
45
45
  # @!attribute strict
46
+ # When true, guarantees schema validation on tool names and inputs
46
47
  #
47
48
  # @return [Boolean, nil]
48
49
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -59,7 +60,7 @@ module Anthropic
59
60
  #
60
61
  # @param input_examples [Array<Hash{Symbol=>Object}>]
61
62
  #
62
- # @param strict [Boolean]
63
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
63
64
  #
64
65
  # @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
65
66
  #
@@ -50,6 +50,7 @@ module Anthropic
50
50
  optional :max_characters, Integer, nil?: true
51
51
 
52
52
  # @!attribute strict
53
+ # When true, guarantees schema validation on tool names and inputs
53
54
  #
54
55
  # @return [Boolean, nil]
55
56
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -68,7 +69,7 @@ module Anthropic
68
69
  #
69
70
  # @param max_characters [Integer, nil] Maximum number of characters to display when viewing a file. If not specified, d
70
71
  #
71
- # @param strict [Boolean]
72
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
72
73
  #
73
74
  # @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
74
75
  #
@@ -69,6 +69,7 @@ module Anthropic
69
69
  optional :max_uses, Integer, nil?: true
70
70
 
71
71
  # @!attribute strict
72
+ # When true, guarantees schema validation on tool names and inputs
72
73
  #
73
74
  # @return [Boolean, nil]
74
75
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -93,7 +94,7 @@ module Anthropic
93
94
  #
94
95
  # @param max_uses [Integer, nil] Maximum number of times the tool can be used in the API request.
95
96
  #
96
- # @param strict [Boolean]
97
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
97
98
  #
98
99
  # @param name [Symbol, :web_fetch] Name of the tool.
99
100
  #
@@ -57,6 +57,7 @@ module Anthropic
57
57
  optional :max_uses, Integer, nil?: true
58
58
 
59
59
  # @!attribute strict
60
+ # When true, guarantees schema validation on tool names and inputs
60
61
  #
61
62
  # @return [Boolean, nil]
62
63
  optional :strict, Anthropic::Internal::Type::Boolean
@@ -84,7 +85,7 @@ module Anthropic
84
85
  #
85
86
  # @param max_uses [Integer, nil] Maximum number of times the tool can be used in the API request.
86
87
  #
87
- # @param strict [Boolean]
88
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
88
89
  #
89
90
  # @param user_location [Anthropic::Models::Beta::BetaWebSearchTool20250305::UserLocation, nil] Parameters for the user's location. Used to provide more relevant search results
90
91
  #
@@ -11,6 +11,7 @@ module Anthropic
11
11
  MAX_USES_EXCEEDED = :max_uses_exceeded
12
12
  TOO_MANY_REQUESTS = :too_many_requests
13
13
  QUERY_TOO_LONG = :query_too_long
14
+ REQUEST_TOO_LARGE = :request_too_large
14
15
 
15
16
  # @!method self.values
16
17
  # @return [Array<Symbol>]
@@ -103,14 +103,19 @@ module Anthropic
103
103
  -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaRequestMCPServerURLDefinition] }
104
104
 
105
105
  # @!attribute output_config
106
- # Configuration options for the model's output. Controls aspects like how much
107
- # effort the model puts into its response.
106
+ # Configuration options for the model's output, such as the output format.
108
107
  #
109
108
  # @return [Anthropic::Models::Beta::BetaOutputConfig, nil]
110
109
  optional :output_config, -> { Anthropic::Beta::BetaOutputConfig }
111
110
 
112
111
  # @!attribute output_format
113
- # A schema to specify Claude's output format in responses.
112
+ # @deprecated
113
+ #
114
+ # Deprecated: Use `output_config.format` instead. See
115
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
116
+ #
117
+ # A schema to specify Claude's output format in responses. This parameter will be
118
+ # removed in a future release.
114
119
  #
115
120
  # @return [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
116
121
  optional :output_format, -> { Anthropic::Beta::BetaJSONOutputFormat }, nil?: true
@@ -245,9 +250,9 @@ module Anthropic
245
250
  #
246
251
  # @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] MCP servers to be utilized in this request
247
252
  #
248
- # @param output_config [Anthropic::Models::Beta::BetaOutputConfig] Configuration options for the model's output. Controls aspects like how much eff
253
+ # @param output_config [Anthropic::Models::Beta::BetaOutputConfig] Configuration options for the model's output, such as the output format.
249
254
  #
250
- # @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
255
+ # @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil] Deprecated: Use `output_config.format` instead. See [structured outputs](https:/
251
256
  #
252
257
  # @param system_ [String, Array<Anthropic::Models::Beta::BetaTextBlockParam>] System prompt.
253
258
  #
@@ -129,14 +129,19 @@ module Anthropic
129
129
  optional :metadata, -> { Anthropic::Beta::BetaMetadata }
130
130
 
131
131
  # @!attribute output_config
132
- # Configuration options for the model's output. Controls aspects like how much
133
- # effort the model puts into its response.
132
+ # Configuration options for the model's output, such as the output format.
134
133
  #
135
134
  # @return [Anthropic::Models::Beta::BetaOutputConfig, nil]
136
135
  optional :output_config, -> { Anthropic::Beta::BetaOutputConfig }
137
136
 
138
137
  # @!attribute output_format
139
- # A schema to specify Claude's output format in responses.
138
+ # @deprecated
139
+ #
140
+ # Deprecated: Use `output_config.format` instead. See
141
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
142
+ #
143
+ # A schema to specify Claude's output format in responses. This parameter will be
144
+ # removed in a future release.
140
145
  #
141
146
  # @return [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
142
147
  optional :output_format, -> { Anthropic::Beta::BetaJSONOutputFormat }, nil?: true
@@ -339,9 +344,9 @@ module Anthropic
339
344
  #
340
345
  # @param metadata [Anthropic::Models::Beta::BetaMetadata] An object describing metadata about the request.
341
346
  #
342
- # @param output_config [Anthropic::Models::Beta::BetaOutputConfig] Configuration options for the model's output. Controls aspects like how much eff
347
+ # @param output_config [Anthropic::Models::Beta::BetaOutputConfig] Configuration options for the model's output, such as the output format.
343
348
  #
344
- # @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
349
+ # @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil] Deprecated: Use `output_config.format` instead. See [structured outputs](https:/
345
350
  #
346
351
  # @param service_tier [Symbol, Anthropic::Models::Beta::MessageCreateParams::ServiceTier] Determines whether to use priority capacity (if available) or standard capacity
347
352
  #
@@ -184,14 +184,19 @@ module Anthropic
184
184
  optional :metadata, -> { Anthropic::Beta::BetaMetadata }
185
185
 
186
186
  # @!attribute output_config
187
- # Configuration options for the model's output. Controls aspects like how much
188
- # effort the model puts into its response.
187
+ # Configuration options for the model's output, such as the output format.
189
188
  #
190
189
  # @return [Anthropic::Models::Beta::BetaOutputConfig, nil]
191
190
  optional :output_config, -> { Anthropic::Beta::BetaOutputConfig }
192
191
 
193
192
  # @!attribute output_format
194
- # A schema to specify Claude's output format in responses.
193
+ # @deprecated
194
+ #
195
+ # Deprecated: Use `output_config.format` instead. See
196
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
197
+ #
198
+ # A schema to specify Claude's output format in responses. This parameter will be
199
+ # removed in a future release.
195
200
  #
196
201
  # @return [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
197
202
  optional :output_format, -> { Anthropic::Beta::BetaJSONOutputFormat }, nil?: true
@@ -405,9 +410,9 @@ module Anthropic
405
410
  #
406
411
  # @param metadata [Anthropic::Models::Beta::BetaMetadata] An object describing metadata about the request.
407
412
  #
408
- # @param output_config [Anthropic::Models::Beta::BetaOutputConfig] Configuration options for the model's output. Controls aspects like how much eff
413
+ # @param output_config [Anthropic::Models::Beta::BetaOutputConfig] Configuration options for the model's output, such as the output format.
409
414
  #
410
- # @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
415
+ # @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil] Deprecated: Use `output_config.format` instead. See [structured outputs](https:/
411
416
  #
412
417
  # @param service_tier [Symbol, Anthropic::Models::Beta::Messages::BatchCreateParams::Request::Params::ServiceTier] Determines whether to use priority capacity (if available) or standard capacity
413
418
  #
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ class JSONOutputFormat < Anthropic::Internal::Type::BaseModel
6
+ # @!attribute schema
7
+ # The JSON schema of the format
8
+ #
9
+ # @return [Hash{Symbol=>Object}]
10
+ required :schema, Anthropic::Internal::Type::HashOf[Anthropic::Internal::Type::Unknown]
11
+
12
+ # @!attribute type
13
+ #
14
+ # @return [Symbol, :json_schema]
15
+ required :type, const: :json_schema
16
+
17
+ # @!method initialize(schema:, type: :json_schema)
18
+ # @param schema [Hash{Symbol=>Object}] The JSON schema of the format
19
+ #
20
+ # @param type [Symbol, :json_schema]
21
+ end
22
+ end
23
+ end
@@ -51,6 +51,18 @@ module Anthropic
51
51
  # @return [Array<Anthropic::Models::TextBlock, Anthropic::Models::ThinkingBlock, Anthropic::Models::RedactedThinkingBlock, Anthropic::Models::ToolUseBlock, Anthropic::Models::ServerToolUseBlock, Anthropic::Models::WebSearchToolResultBlock>]
52
52
  required :content, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::ContentBlock] }
53
53
 
54
+ # Parsed value of response when a JSON output schema object has been specified via :output_config
55
+ #
56
+ # @return [Object, nil]
57
+ def parsed_output
58
+ case content
59
+ in [*, {parsed:}]
60
+ parsed
61
+ else
62
+ nil
63
+ end
64
+ end
65
+
54
66
  # @!attribute model
55
67
  # The model that will complete your prompt.\n\nSee
56
68
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -85,6 +85,12 @@ module Anthropic
85
85
  # @return [Symbol, String, Anthropic::Models::Model]
86
86
  required :model, union: -> { Anthropic::Model }
87
87
 
88
+ # @!attribute output_config
89
+ # Configuration options for the model's output, such as the output format.
90
+ #
91
+ # @return [Anthropic::Models::OutputConfig, nil]
92
+ optional :output_config, -> { Anthropic::OutputConfig }
93
+
88
94
  # @!attribute system_
89
95
  # System prompt.
90
96
  #
@@ -196,7 +202,7 @@ module Anthropic
196
202
  # @return [Array<Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::ToolTextEditor20250429, Anthropic::Models::ToolTextEditor20250728, Anthropic::Models::WebSearchTool20250305>, nil]
197
203
  optional :tools, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::MessageCountTokensTool] }
198
204
 
199
- # @!method initialize(messages:, model:, system_: nil, thinking: nil, tool_choice: nil, tools: nil, request_options: {})
205
+ # @!method initialize(messages:, model:, output_config: nil, system_: nil, thinking: nil, tool_choice: nil, tools: nil, request_options: {})
200
206
  # Some parameter documentations has been truncated, see
201
207
  # {Anthropic::Models::MessageCountTokensParams} for more details.
202
208
  #
@@ -204,6 +210,8 @@ module Anthropic
204
210
  #
205
211
  # @param model [Symbol, String, Anthropic::Models::Model] The model that will complete your prompt.\n\nSee [models](https://docs.anthropic
206
212
  #
213
+ # @param output_config [Anthropic::Models::OutputConfig] Configuration options for the model's output, such as the output format.
214
+ #
207
215
  # @param system_ [String, Array<Anthropic::Models::TextBlockParam>] System prompt.
208
216
  #
209
217
  # @param thinking [Anthropic::Models::ThinkingConfigEnabled, Anthropic::Models::ThinkingConfigDisabled] Configuration for enabling Claude's extended thinking.
@@ -105,6 +105,12 @@ module Anthropic
105
105
  # @return [Anthropic::Models::Metadata, nil]
106
106
  optional :metadata, -> { Anthropic::Metadata }
107
107
 
108
+ # @!attribute output_config
109
+ # Configuration options for the model's output, such as the output format.
110
+ #
111
+ # @return [Anthropic::Models::OutputConfig, nil]
112
+ optional :output_config, -> { Anthropic::OutputConfig }
113
+
108
114
  # @!attribute service_tier
109
115
  # Determines whether to use priority capacity (if available) or standard capacity
110
116
  # for this request.
@@ -279,7 +285,7 @@ module Anthropic
279
285
  # @return [Float, nil]
280
286
  optional :top_p, Float
281
287
 
282
- # @!method initialize(max_tokens:, messages:, model:, metadata: nil, service_tier: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, request_options: {})
288
+ # @!method initialize(max_tokens:, messages:, model:, metadata: nil, output_config: nil, service_tier: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, request_options: {})
283
289
  # Some parameter documentations has been truncated, see
284
290
  # {Anthropic::Models::MessageCreateParams} for more details.
285
291
  #
@@ -291,6 +297,8 @@ module Anthropic
291
297
  #
292
298
  # @param metadata [Anthropic::Models::Metadata] An object describing metadata about the request.
293
299
  #
300
+ # @param output_config [Anthropic::Models::OutputConfig] Configuration options for the model's output, such as the output format.
301
+ #
294
302
  # @param service_tier [Symbol, Anthropic::Models::MessageCreateParams::ServiceTier] Determines whether to use priority capacity (if available) or standard capacity
295
303
  #
296
304
  # @param stop_sequences [Array<String>] Custom text sequences that will cause the model to stop generating.
@@ -149,6 +149,12 @@ module Anthropic
149
149
  # @return [Anthropic::Models::Metadata, nil]
150
150
  optional :metadata, -> { Anthropic::Metadata }
151
151
 
152
+ # @!attribute output_config
153
+ # Configuration options for the model's output, such as the output format.
154
+ #
155
+ # @return [Anthropic::Models::OutputConfig, nil]
156
+ optional :output_config, -> { Anthropic::OutputConfig }
157
+
152
158
  # @!attribute service_tier
153
159
  # Determines whether to use priority capacity (if available) or standard capacity
154
160
  # for this request.
@@ -333,7 +339,7 @@ module Anthropic
333
339
  # @return [Float, nil]
334
340
  optional :top_p, Float
335
341
 
336
- # @!method initialize(max_tokens:, messages:, model:, metadata: nil, service_tier: nil, stop_sequences: nil, stream: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil)
342
+ # @!method initialize(max_tokens:, messages:, model:, metadata: nil, output_config: nil, service_tier: nil, stop_sequences: nil, stream: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil)
337
343
  # Some parameter documentations has been truncated, see
338
344
  # {Anthropic::Models::Messages::BatchCreateParams::Request::Params} for more
339
345
  # details.
@@ -351,6 +357,8 @@ module Anthropic
351
357
  #
352
358
  # @param metadata [Anthropic::Models::Metadata] An object describing metadata about the request.
353
359
  #
360
+ # @param output_config [Anthropic::Models::OutputConfig] Configuration options for the model's output, such as the output format.
361
+ #
354
362
  # @param service_tier [Symbol, Anthropic::Models::Messages::BatchCreateParams::Request::Params::ServiceTier] Determines whether to use priority capacity (if available) or standard capacity
355
363
  #
356
364
  # @param stop_sequences [Array<String>] Custom text sequences that will cause the model to stop generating.
@@ -78,9 +78,15 @@ module Anthropic
78
78
  CLAUDE_3_7_SONNET_20250219 = :"claude-3-7-sonnet-20250219"
79
79
 
80
80
  # Fastest and most compact model for near-instant responsiveness
81
+ # @deprecated Will reach end-of-life on February 19th, 2026. Please migrate to a newer model.
82
+ # Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more
83
+ # information.
81
84
  CLAUDE_3_5_HAIKU_LATEST = :"claude-3-5-haiku-latest"
82
85
 
83
86
  # Our fastest model
87
+ # @deprecated Will reach end-of-life on February 19th, 2026. Please migrate to a newer model.
88
+ # Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more
89
+ # information.
84
90
  CLAUDE_3_5_HAIKU_20241022 = :"claude-3-5-haiku-20241022"
85
91
 
86
92
  # Hybrid model, capable of near-instant responses and extended thinking
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ class OutputConfig < Anthropic::Internal::Type::BaseModel
6
+ # @!attribute format_
7
+ # A schema to specify Claude's output format in responses. See
8
+ # [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
9
+ #
10
+ # @return [Anthropic::Models::JSONOutputFormat, nil]
11
+ optional :format_, -> { Anthropic::JSONOutputFormat }, api_name: :format, nil?: true
12
+
13
+ # @!method initialize(format_: nil)
14
+ # Some parameter documentations has been truncated, see
15
+ # {Anthropic::Models::OutputConfig} for more details.
16
+ #
17
+ # @param format_ [Anthropic::Models::JSONOutputFormat, nil] A schema to specify Claude's output format in responses. See [structured outputs
18
+ end
19
+ end
20
+ end
@@ -22,6 +22,14 @@ module Anthropic
22
22
  # @return [String]
23
23
  required :text, String
24
24
 
25
+ response_only do
26
+ # @!attribute parsed
27
+ # parsed value of `#text` when a JSON output schema object has been specified
28
+ #
29
+ # @return [Object, nil]
30
+ optional :parsed, Anthropic::Helpers::InputSchema::ParsedJson
31
+ end
32
+
25
33
  # @!attribute type
26
34
  #
27
35
  # @return [Symbol, :text]
@@ -37,12 +37,18 @@ module Anthropic
37
37
  # @return [String, nil]
38
38
  optional :description, String
39
39
 
40
+ # @!attribute strict
41
+ # When true, guarantees schema validation on tool names and inputs
42
+ #
43
+ # @return [Boolean, nil]
44
+ optional :strict, Anthropic::Internal::Type::Boolean
45
+
40
46
  # @!attribute type
41
47
  #
42
48
  # @return [Symbol, Anthropic::Models::Tool::Type, nil]
43
49
  optional :type, enum: -> { Anthropic::Tool::Type }, nil?: true
44
50
 
45
- # @!method initialize(input_schema:, name:, cache_control: nil, description: nil, type: nil)
51
+ # @!method initialize(input_schema:, name:, cache_control: nil, description: nil, strict: nil, type: nil)
46
52
  # Some parameter documentations has been truncated, see {Anthropic::Models::Tool}
47
53
  # for more details.
48
54
  #
@@ -54,6 +60,8 @@ module Anthropic
54
60
  #
55
61
  # @param description [String] Description of what this tool does.
56
62
  #
63
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
64
+ #
57
65
  # @param type [Symbol, Anthropic::Models::Tool::Type, nil]
58
66
 
59
67
  # @see Anthropic::Models::Tool#input_schema
@@ -22,12 +22,20 @@ module Anthropic
22
22
  # @return [Anthropic::Models::CacheControlEphemeral, nil]
23
23
  optional :cache_control, -> { Anthropic::CacheControlEphemeral }, nil?: true
24
24
 
25
- # @!method initialize(cache_control: nil, name: :bash, type: :bash_20250124)
25
+ # @!attribute strict
26
+ # When true, guarantees schema validation on tool names and inputs
27
+ #
28
+ # @return [Boolean, nil]
29
+ optional :strict, Anthropic::Internal::Type::Boolean
30
+
31
+ # @!method initialize(cache_control: nil, strict: nil, name: :bash, type: :bash_20250124)
26
32
  # Some parameter documentations has been truncated, see
27
33
  # {Anthropic::Models::ToolBash20250124} for more details.
28
34
  #
29
35
  # @param cache_control [Anthropic::Models::CacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
30
36
  #
37
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
38
+ #
31
39
  # @param name [Symbol, :bash] Name of the tool.
32
40
  #
33
41
  # @param type [Symbol, :bash_20250124]
@@ -22,12 +22,20 @@ module Anthropic
22
22
  # @return [Anthropic::Models::CacheControlEphemeral, nil]
23
23
  optional :cache_control, -> { Anthropic::CacheControlEphemeral }, nil?: true
24
24
 
25
- # @!method initialize(cache_control: nil, name: :str_replace_editor, type: :text_editor_20250124)
25
+ # @!attribute strict
26
+ # When true, guarantees schema validation on tool names and inputs
27
+ #
28
+ # @return [Boolean, nil]
29
+ optional :strict, Anthropic::Internal::Type::Boolean
30
+
31
+ # @!method initialize(cache_control: nil, strict: nil, name: :str_replace_editor, type: :text_editor_20250124)
26
32
  # Some parameter documentations has been truncated, see
27
33
  # {Anthropic::Models::ToolTextEditor20250124} for more details.
28
34
  #
29
35
  # @param cache_control [Anthropic::Models::CacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
30
36
  #
37
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
38
+ #
31
39
  # @param name [Symbol, :str_replace_editor] Name of the tool.
32
40
  #
33
41
  # @param type [Symbol, :text_editor_20250124]
@@ -22,12 +22,20 @@ module Anthropic
22
22
  # @return [Anthropic::Models::CacheControlEphemeral, nil]
23
23
  optional :cache_control, -> { Anthropic::CacheControlEphemeral }, nil?: true
24
24
 
25
- # @!method initialize(cache_control: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250429)
25
+ # @!attribute strict
26
+ # When true, guarantees schema validation on tool names and inputs
27
+ #
28
+ # @return [Boolean, nil]
29
+ optional :strict, Anthropic::Internal::Type::Boolean
30
+
31
+ # @!method initialize(cache_control: nil, strict: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250429)
26
32
  # Some parameter documentations has been truncated, see
27
33
  # {Anthropic::Models::ToolTextEditor20250429} for more details.
28
34
  #
29
35
  # @param cache_control [Anthropic::Models::CacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
30
36
  #
37
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
38
+ #
31
39
  # @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
32
40
  #
33
41
  # @param type [Symbol, :text_editor_20250429]
@@ -29,7 +29,13 @@ module Anthropic
29
29
  # @return [Integer, nil]
30
30
  optional :max_characters, Integer, nil?: true
31
31
 
32
- # @!method initialize(cache_control: nil, max_characters: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250728)
32
+ # @!attribute strict
33
+ # When true, guarantees schema validation on tool names and inputs
34
+ #
35
+ # @return [Boolean, nil]
36
+ optional :strict, Anthropic::Internal::Type::Boolean
37
+
38
+ # @!method initialize(cache_control: nil, max_characters: nil, strict: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250728)
33
39
  # Some parameter documentations has been truncated, see
34
40
  # {Anthropic::Models::ToolTextEditor20250728} for more details.
35
41
  #
@@ -37,6 +43,8 @@ module Anthropic
37
43
  #
38
44
  # @param max_characters [Integer, nil] Maximum number of characters to display when viewing a file. If not specified, d
39
45
  #
46
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
47
+ #
40
48
  # @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
41
49
  #
42
50
  # @param type [Symbol, :text_editor_20250728]
@@ -42,6 +42,12 @@ module Anthropic
42
42
  # @return [Integer, nil]
43
43
  optional :max_uses, Integer, nil?: true
44
44
 
45
+ # @!attribute strict
46
+ # When true, guarantees schema validation on tool names and inputs
47
+ #
48
+ # @return [Boolean, nil]
49
+ optional :strict, Anthropic::Internal::Type::Boolean
50
+
45
51
  # @!attribute user_location
46
52
  # Parameters for the user's location. Used to provide more relevant search
47
53
  # results.
@@ -49,7 +55,7 @@ module Anthropic
49
55
  # @return [Anthropic::Models::WebSearchTool20250305::UserLocation, nil]
50
56
  optional :user_location, -> { Anthropic::WebSearchTool20250305::UserLocation }, nil?: true
51
57
 
52
- # @!method initialize(allowed_domains: nil, blocked_domains: nil, cache_control: nil, max_uses: nil, user_location: nil, name: :web_search, type: :web_search_20250305)
58
+ # @!method initialize(allowed_domains: nil, blocked_domains: nil, cache_control: nil, max_uses: nil, strict: nil, user_location: nil, name: :web_search, type: :web_search_20250305)
53
59
  # Some parameter documentations has been truncated, see
54
60
  # {Anthropic::Models::WebSearchTool20250305} for more details.
55
61
  #
@@ -61,6 +67,8 @@ module Anthropic
61
67
  #
62
68
  # @param max_uses [Integer, nil] Maximum number of times the tool can be used in the API request.
63
69
  #
70
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
71
+ #
64
72
  # @param user_location [Anthropic::Models::WebSearchTool20250305::UserLocation, nil] Parameters for the user's location. Used to provide more relevant search results
65
73
  #
66
74
  # @param name [Symbol, :web_search] Name of the tool.
@@ -26,6 +26,7 @@ module Anthropic
26
26
  MAX_USES_EXCEEDED = :max_uses_exceeded
27
27
  TOO_MANY_REQUESTS = :too_many_requests
28
28
  QUERY_TOO_LONG = :query_too_long
29
+ REQUEST_TOO_LARGE = :request_too_large
29
30
 
30
31
  # @!method self.values
31
32
  # @return [Array<Symbol>]
@@ -26,6 +26,7 @@ module Anthropic
26
26
  MAX_USES_EXCEEDED = :max_uses_exceeded
27
27
  TOO_MANY_REQUESTS = :too_many_requests
28
28
  QUERY_TOO_LONG = :query_too_long
29
+ REQUEST_TOO_LARGE = :request_too_large
29
30
 
30
31
  # @!method self.values
31
32
  # @return [Array<Symbol>]