anthropic 1.45.0 → 1.47.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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +1 -1
  4. data/lib/anthropic/helpers/streaming/message_stream.rb +4 -0
  5. data/lib/anthropic/models/anthropic_beta.rb +6 -0
  6. data/lib/anthropic/models/beta/agent_create_params.rb +8 -8
  7. data/lib/anthropic/models/beta/agent_update_params.rb +7 -10
  8. data/lib/anthropic/models/beta/beta_advisor_tool_20260301.rb +15 -1
  9. data/lib/anthropic/models/beta/beta_advisor_tool_result_error.rb +1 -0
  10. data/lib/anthropic/models/beta/beta_advisor_tool_result_error_param.rb +1 -0
  11. data/lib/anthropic/models/beta/beta_content_block.rb +14 -1
  12. data/lib/anthropic/models/beta/beta_content_block_param.rb +18 -1
  13. data/lib/anthropic/models/beta/beta_fallback_block.rb +54 -0
  14. data/lib/anthropic/models/beta/beta_fallback_block_param.rb +51 -0
  15. data/lib/anthropic/models/beta/beta_fallback_info.rb +28 -0
  16. data/lib/anthropic/models/beta/beta_fallback_info_param.rb +28 -0
  17. data/lib/anthropic/models/beta/beta_fallback_message_iteration_usage.rb +81 -0
  18. data/lib/anthropic/models/beta/beta_fallback_param.rb +88 -0
  19. data/lib/anthropic/models/beta/beta_iterations_usage.rb +9 -1
  20. data/lib/anthropic/models/beta/beta_managed_agents_custom_tool_input_schema.rb +10 -27
  21. data/lib/anthropic/models/beta/beta_managed_agents_model.rb +5 -0
  22. data/lib/anthropic/models/beta/beta_message.rb +2 -2
  23. data/lib/anthropic/models/beta/beta_message_delta_usage.rb +2 -2
  24. data/lib/anthropic/models/beta/beta_message_iteration_usage.rb +15 -1
  25. data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
  26. data/lib/anthropic/models/beta/beta_model_info.rb +11 -1
  27. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +16 -3
  28. data/lib/anthropic/models/beta/beta_refusal_stop_details.rb +64 -1
  29. data/lib/anthropic/models/beta/beta_tool_search_tool_result_error_param.rb +7 -1
  30. data/lib/anthropic/models/beta/beta_usage.rb +2 -2
  31. data/lib/anthropic/models/beta/beta_webhook_session_archived_event_data.rb +2 -2
  32. data/lib/anthropic/models/beta/beta_webhook_session_created_event_data.rb +2 -2
  33. data/lib/anthropic/models/beta/beta_webhook_session_deleted_event_data.rb +2 -2
  34. data/lib/anthropic/models/beta/beta_webhook_session_idled_event_data.rb +2 -2
  35. data/lib/anthropic/models/beta/beta_webhook_session_outcome_evaluation_ended_event_data.rb +2 -2
  36. data/lib/anthropic/models/beta/beta_webhook_session_pending_event_data.rb +2 -2
  37. data/lib/anthropic/models/beta/beta_webhook_session_requires_action_event_data.rb +2 -2
  38. data/lib/anthropic/models/beta/beta_webhook_session_running_event_data.rb +2 -2
  39. data/lib/anthropic/models/beta/beta_webhook_session_status_idled_event_data.rb +2 -2
  40. data/lib/anthropic/models/beta/beta_webhook_session_status_rescheduled_event_data.rb +2 -2
  41. data/lib/anthropic/models/beta/beta_webhook_session_status_run_started_event_data.rb +2 -2
  42. data/lib/anthropic/models/beta/beta_webhook_session_status_terminated_event_data.rb +2 -2
  43. data/lib/anthropic/models/beta/beta_webhook_session_thread_created_event_data.rb +2 -2
  44. data/lib/anthropic/models/beta/beta_webhook_session_thread_idled_event_data.rb +2 -2
  45. data/lib/anthropic/models/beta/beta_webhook_session_thread_terminated_event_data.rb +2 -2
  46. data/lib/anthropic/models/beta/beta_webhook_vault_archived_event_data.rb +2 -2
  47. data/lib/anthropic/models/beta/beta_webhook_vault_created_event_data.rb +2 -2
  48. data/lib/anthropic/models/beta/beta_webhook_vault_credential_archived_event_data.rb +2 -2
  49. data/lib/anthropic/models/beta/beta_webhook_vault_credential_created_event_data.rb +2 -2
  50. data/lib/anthropic/models/beta/beta_webhook_vault_credential_deleted_event_data.rb +2 -2
  51. data/lib/anthropic/models/beta/beta_webhook_vault_credential_refresh_failed_event_data.rb +2 -2
  52. data/lib/anthropic/models/beta/beta_webhook_vault_deleted_event_data.rb +2 -2
  53. data/lib/anthropic/models/beta/message_create_params.rb +39 -1
  54. data/lib/anthropic/models/beta/messages/batch_create_params.rb +39 -1
  55. data/lib/anthropic/models/beta/session_list_params.rb +2 -2
  56. data/lib/anthropic/models/model.rb +13 -0
  57. data/lib/anthropic/models/refusal_stop_details.rb +1 -0
  58. data/lib/anthropic/models/tool_search_tool_result_error_param.rb +7 -1
  59. data/lib/anthropic/resources/beta/agents.rb +7 -7
  60. data/lib/anthropic/resources/beta/messages.rb +10 -2
  61. data/lib/anthropic/resources/beta/sessions.rb +1 -1
  62. data/lib/anthropic/version.rb +1 -1
  63. data/lib/anthropic.rb +6 -0
  64. data/rbi/anthropic/models/anthropic_beta.rbi +10 -0
  65. data/rbi/anthropic/models/beta/agent_create_params.rbi +8 -8
  66. data/rbi/anthropic/models/beta/agent_update_params.rbi +6 -12
  67. data/rbi/anthropic/models/beta/beta_advisor_tool_20260301.rbi +20 -0
  68. data/rbi/anthropic/models/beta/beta_advisor_tool_result_error.rbi +5 -0
  69. data/rbi/anthropic/models/beta/beta_advisor_tool_result_error_param.rbi +5 -0
  70. data/rbi/anthropic/models/beta/beta_content_block.rbi +2 -1
  71. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +2 -1
  72. data/rbi/anthropic/models/beta/beta_fallback_block.rbi +83 -0
  73. data/rbi/anthropic/models/beta/beta_fallback_block_param.rbi +81 -0
  74. data/rbi/anthropic/models/beta/beta_fallback_info.rbi +45 -0
  75. data/rbi/anthropic/models/beta/beta_fallback_info_param.rbi +47 -0
  76. data/rbi/anthropic/models/beta/beta_fallback_message_iteration_usage.rbi +113 -0
  77. data/rbi/anthropic/models/beta/beta_fallback_param.rbi +167 -0
  78. data/rbi/anthropic/models/beta/beta_iterations_usage.rbi +2 -1
  79. data/rbi/anthropic/models/beta/beta_managed_agents_custom_tool_input_schema.rbi +9 -68
  80. data/rbi/anthropic/models/beta/beta_managed_agents_model.rbi +7 -0
  81. data/rbi/anthropic/models/beta/beta_message.rbi +2 -1
  82. data/rbi/anthropic/models/beta/beta_message_delta_usage.rbi +2 -1
  83. data/rbi/anthropic/models/beta/beta_message_iteration_usage.rbi +14 -0
  84. data/rbi/anthropic/models/beta/beta_model_info.rbi +12 -0
  85. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +4 -2
  86. data/rbi/anthropic/models/beta/beta_refusal_stop_details.rbi +105 -0
  87. data/rbi/anthropic/models/beta/beta_tool_search_tool_result_error_param.rbi +11 -2
  88. data/rbi/anthropic/models/beta/beta_usage.rbi +2 -1
  89. data/rbi/anthropic/models/beta/beta_webhook_session_archived_event_data.rbi +2 -2
  90. data/rbi/anthropic/models/beta/beta_webhook_session_created_event_data.rbi +2 -2
  91. data/rbi/anthropic/models/beta/beta_webhook_session_deleted_event_data.rbi +2 -2
  92. data/rbi/anthropic/models/beta/beta_webhook_session_idled_event_data.rbi +2 -2
  93. data/rbi/anthropic/models/beta/beta_webhook_session_outcome_evaluation_ended_event_data.rbi +2 -2
  94. data/rbi/anthropic/models/beta/beta_webhook_session_pending_event_data.rbi +2 -2
  95. data/rbi/anthropic/models/beta/beta_webhook_session_requires_action_event_data.rbi +2 -2
  96. data/rbi/anthropic/models/beta/beta_webhook_session_running_event_data.rbi +2 -2
  97. data/rbi/anthropic/models/beta/beta_webhook_session_status_idled_event_data.rbi +2 -2
  98. data/rbi/anthropic/models/beta/beta_webhook_session_status_rescheduled_event_data.rbi +2 -2
  99. data/rbi/anthropic/models/beta/beta_webhook_session_status_run_started_event_data.rbi +2 -2
  100. data/rbi/anthropic/models/beta/beta_webhook_session_status_terminated_event_data.rbi +2 -2
  101. data/rbi/anthropic/models/beta/beta_webhook_session_thread_created_event_data.rbi +2 -2
  102. data/rbi/anthropic/models/beta/beta_webhook_session_thread_idled_event_data.rbi +2 -2
  103. data/rbi/anthropic/models/beta/beta_webhook_session_thread_terminated_event_data.rbi +2 -2
  104. data/rbi/anthropic/models/beta/beta_webhook_vault_archived_event_data.rbi +2 -2
  105. data/rbi/anthropic/models/beta/beta_webhook_vault_created_event_data.rbi +2 -2
  106. data/rbi/anthropic/models/beta/beta_webhook_vault_credential_archived_event_data.rbi +2 -2
  107. data/rbi/anthropic/models/beta/beta_webhook_vault_credential_created_event_data.rbi +2 -2
  108. data/rbi/anthropic/models/beta/beta_webhook_vault_credential_deleted_event_data.rbi +2 -2
  109. data/rbi/anthropic/models/beta/beta_webhook_vault_credential_refresh_failed_event_data.rbi +2 -2
  110. data/rbi/anthropic/models/beta/beta_webhook_vault_deleted_event_data.rbi +2 -2
  111. data/rbi/anthropic/models/beta/message_create_params.rbi +58 -0
  112. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +62 -0
  113. data/rbi/anthropic/models/beta/session_list_params.rbi +2 -2
  114. data/rbi/anthropic/models/model.rbi +7 -0
  115. data/rbi/anthropic/models/refusal_stop_details.rbi +5 -0
  116. data/rbi/anthropic/models/tool_search_tool_result_error_param.rbi +11 -2
  117. data/rbi/anthropic/resources/beta/agents.rbi +8 -10
  118. data/rbi/anthropic/resources/beta/messages.rbi +54 -0
  119. data/rbi/anthropic/resources/beta/sessions.rbi +1 -1
  120. data/sig/anthropic/models/anthropic_beta.rbs +4 -0
  121. data/sig/anthropic/models/beta/beta_advisor_tool_20260301.rbs +5 -0
  122. data/sig/anthropic/models/beta/beta_advisor_tool_result_error.rbs +2 -0
  123. data/sig/anthropic/models/beta/beta_advisor_tool_result_error_param.rbs +2 -0
  124. data/sig/anthropic/models/beta/beta_content_block.rbs +1 -0
  125. data/sig/anthropic/models/beta/beta_content_block_param.rbs +1 -0
  126. data/sig/anthropic/models/beta/beta_fallback_block.rbs +34 -0
  127. data/sig/anthropic/models/beta/beta_fallback_block_param.rbs +34 -0
  128. data/sig/anthropic/models/beta/beta_fallback_info.rbs +17 -0
  129. data/sig/anthropic/models/beta/beta_fallback_info_param.rbs +17 -0
  130. data/sig/anthropic/models/beta/beta_fallback_message_iteration_usage.rbs +54 -0
  131. data/sig/anthropic/models/beta/beta_fallback_param.rbs +66 -0
  132. data/sig/anthropic/models/beta/beta_iterations_usage.rbs +1 -0
  133. data/sig/anthropic/models/beta/beta_managed_agents_custom_tool_input_schema.rbs +9 -25
  134. data/sig/anthropic/models/beta/beta_managed_agents_model.rbs +5 -1
  135. data/sig/anthropic/models/beta/beta_message_iteration_usage.rbs +5 -0
  136. data/sig/anthropic/models/beta/beta_model_info.rbs +5 -0
  137. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +1 -0
  138. data/sig/anthropic/models/beta/beta_refusal_stop_details.rbs +17 -1
  139. data/sig/anthropic/models/beta/beta_tool_search_tool_result_error_param.rbs +7 -2
  140. data/sig/anthropic/models/beta/message_create_params.rbs +10 -0
  141. data/sig/anthropic/models/beta/messages/batch_create_params.rbs +10 -0
  142. data/sig/anthropic/models/model.rbs +9 -1
  143. data/sig/anthropic/models/refusal_stop_details.rbs +2 -1
  144. data/sig/anthropic/models/tool_search_tool_result_error_param.rbs +7 -2
  145. data/sig/anthropic/resources/beta/messages.rbs +4 -0
  146. metadata +20 -2
@@ -0,0 +1,167 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaFallbackParam = Beta::BetaFallbackParam
6
+
7
+ module Beta
8
+ class BetaFallbackParam < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaFallbackParam,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ # The model that will complete your prompt.
18
+ #
19
+ # See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
20
+ # details and options.
21
+ sig { returns(T.any(Anthropic::Model::OrSymbol, String)) }
22
+ attr_accessor :model
23
+
24
+ sig { returns(T.nilable(Integer)) }
25
+ attr_accessor :max_tokens
26
+
27
+ sig { returns(T.nilable(Anthropic::Beta::BetaOutputConfig)) }
28
+ attr_reader :output_config
29
+
30
+ sig do
31
+ params(
32
+ output_config: T.nilable(Anthropic::Beta::BetaOutputConfig::OrHash)
33
+ ).void
34
+ end
35
+ attr_writer :output_config
36
+
37
+ sig do
38
+ returns(
39
+ T.nilable(Anthropic::Beta::BetaFallbackParam::Speed::OrSymbol)
40
+ )
41
+ end
42
+ attr_accessor :speed
43
+
44
+ sig do
45
+ returns(
46
+ T.nilable(
47
+ T.any(
48
+ Anthropic::Beta::BetaThinkingConfigEnabled,
49
+ Anthropic::Beta::BetaThinkingConfigDisabled,
50
+ Anthropic::Beta::BetaThinkingConfigAdaptive
51
+ )
52
+ )
53
+ )
54
+ end
55
+ attr_accessor :thinking
56
+
57
+ # One entry in the `fallbacks` chain on a `/v1/messages` request.
58
+ #
59
+ # `model` is required. The four override fields (`max_tokens`, `thinking`,
60
+ # `output_config`, and `speed`) replace the corresponding top-level field for this
61
+ # attempt only and are validated as if the request were made to `model`. Any other
62
+ # key is rejected at parse time.
63
+ sig do
64
+ params(
65
+ model: T.any(Anthropic::Model::OrSymbol, String),
66
+ max_tokens: T.nilable(Integer),
67
+ output_config: T.nilable(Anthropic::Beta::BetaOutputConfig::OrHash),
68
+ speed:
69
+ T.nilable(Anthropic::Beta::BetaFallbackParam::Speed::OrSymbol),
70
+ thinking:
71
+ T.nilable(
72
+ T.any(
73
+ Anthropic::Beta::BetaThinkingConfigEnabled::OrHash,
74
+ Anthropic::Beta::BetaThinkingConfigDisabled::OrHash,
75
+ Anthropic::Beta::BetaThinkingConfigAdaptive::OrHash
76
+ )
77
+ )
78
+ ).returns(T.attached_class)
79
+ end
80
+ def self.new(
81
+ # The model that will complete your prompt.
82
+ #
83
+ # See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
84
+ # details and options.
85
+ model:,
86
+ max_tokens: nil,
87
+ output_config: nil,
88
+ speed: nil,
89
+ thinking: nil
90
+ )
91
+ end
92
+
93
+ sig do
94
+ override.returns(
95
+ {
96
+ model: T.any(Anthropic::Model::OrSymbol, String),
97
+ max_tokens: T.nilable(Integer),
98
+ output_config: T.nilable(Anthropic::Beta::BetaOutputConfig),
99
+ speed:
100
+ T.nilable(Anthropic::Beta::BetaFallbackParam::Speed::OrSymbol),
101
+ thinking:
102
+ T.nilable(
103
+ T.any(
104
+ Anthropic::Beta::BetaThinkingConfigEnabled,
105
+ Anthropic::Beta::BetaThinkingConfigDisabled,
106
+ Anthropic::Beta::BetaThinkingConfigAdaptive
107
+ )
108
+ )
109
+ }
110
+ )
111
+ end
112
+ def to_hash
113
+ end
114
+
115
+ module Speed
116
+ extend Anthropic::Internal::Type::Enum
117
+
118
+ TaggedSymbol =
119
+ T.type_alias do
120
+ T.all(Symbol, Anthropic::Beta::BetaFallbackParam::Speed)
121
+ end
122
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
123
+
124
+ STANDARD =
125
+ T.let(
126
+ :standard,
127
+ Anthropic::Beta::BetaFallbackParam::Speed::TaggedSymbol
128
+ )
129
+ FAST =
130
+ T.let(
131
+ :fast,
132
+ Anthropic::Beta::BetaFallbackParam::Speed::TaggedSymbol
133
+ )
134
+
135
+ sig do
136
+ override.returns(
137
+ T::Array[Anthropic::Beta::BetaFallbackParam::Speed::TaggedSymbol]
138
+ )
139
+ end
140
+ def self.values
141
+ end
142
+ end
143
+
144
+ module Thinking
145
+ extend Anthropic::Internal::Type::Union
146
+
147
+ Variants =
148
+ T.type_alias do
149
+ T.any(
150
+ Anthropic::Beta::BetaThinkingConfigEnabled,
151
+ Anthropic::Beta::BetaThinkingConfigDisabled,
152
+ Anthropic::Beta::BetaThinkingConfigAdaptive
153
+ )
154
+ end
155
+
156
+ sig do
157
+ override.returns(
158
+ T::Array[Anthropic::Beta::BetaFallbackParam::Thinking::Variants]
159
+ )
160
+ end
161
+ def self.variants
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
@@ -15,7 +15,8 @@ module Anthropic
15
15
  T.any(
16
16
  Anthropic::Beta::BetaMessageIterationUsage,
17
17
  Anthropic::Beta::BetaCompactionIterationUsage,
18
- Anthropic::Beta::BetaAdvisorMessageIterationUsage
18
+ Anthropic::Beta::BetaAdvisorMessageIterationUsage,
19
+ Anthropic::Beta::BetaFallbackMessageIterationUsage
19
20
  )
20
21
  end
21
22
 
@@ -15,96 +15,37 @@ module Anthropic
15
15
  )
16
16
  end
17
17
 
18
- # JSON Schema properties defining the tool's input parameters.
18
+ sig { returns(Symbol) }
19
+ attr_accessor :type
20
+
19
21
  sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
20
22
  attr_accessor :properties
21
23
 
22
- # List of required property names.
23
24
  sig { returns(T.nilable(T::Array[String])) }
24
- attr_reader :required
25
-
26
- sig { params(required: T::Array[String]).void }
27
- attr_writer :required
28
-
29
- # Must be 'object' for tool input schemas.
30
- sig do
31
- returns(
32
- T.nilable(
33
- Anthropic::Beta::BetaManagedAgentsCustomToolInputSchema::Type::OrSymbol
34
- )
35
- )
36
- end
37
- attr_reader :type
38
-
39
- sig do
40
- params(
41
- type:
42
- Anthropic::Beta::BetaManagedAgentsCustomToolInputSchema::Type::OrSymbol
43
- ).void
44
- end
45
- attr_writer :type
25
+ attr_accessor :required
46
26
 
47
27
  # JSON Schema for custom tool input parameters.
48
28
  sig do
49
29
  params(
50
30
  properties: T.nilable(T::Hash[Symbol, T.anything]),
51
- required: T::Array[String],
52
- type:
53
- Anthropic::Beta::BetaManagedAgentsCustomToolInputSchema::Type::OrSymbol
31
+ required: T.nilable(T::Array[String]),
32
+ type: Symbol
54
33
  ).returns(T.attached_class)
55
34
  end
56
- def self.new(
57
- # JSON Schema properties defining the tool's input parameters.
58
- properties: nil,
59
- # List of required property names.
60
- required: nil,
61
- # Must be 'object' for tool input schemas.
62
- type: nil
63
- )
35
+ def self.new(properties: nil, required: nil, type: :object)
64
36
  end
65
37
 
66
38
  sig do
67
39
  override.returns(
68
40
  {
41
+ type: Symbol,
69
42
  properties: T.nilable(T::Hash[Symbol, T.anything]),
70
- required: T::Array[String],
71
- type:
72
- Anthropic::Beta::BetaManagedAgentsCustomToolInputSchema::Type::OrSymbol
43
+ required: T.nilable(T::Array[String])
73
44
  }
74
45
  )
75
46
  end
76
47
  def to_hash
77
48
  end
78
-
79
- # Must be 'object' for tool input schemas.
80
- module Type
81
- extend Anthropic::Internal::Type::Enum
82
-
83
- TaggedSymbol =
84
- T.type_alias do
85
- T.all(
86
- Symbol,
87
- Anthropic::Beta::BetaManagedAgentsCustomToolInputSchema::Type
88
- )
89
- end
90
- OrSymbol = T.type_alias { T.any(Symbol, String) }
91
-
92
- OBJECT =
93
- T.let(
94
- :object,
95
- Anthropic::Beta::BetaManagedAgentsCustomToolInputSchema::Type::TaggedSymbol
96
- )
97
-
98
- sig do
99
- override.returns(
100
- T::Array[
101
- Anthropic::Beta::BetaManagedAgentsCustomToolInputSchema::Type::TaggedSymbol
102
- ]
103
- )
104
- end
105
- def self.values
106
- end
107
- end
108
49
  end
109
50
  end
110
51
  end
@@ -31,6 +31,13 @@ module Anthropic
31
31
  end
32
32
  OrSymbol = T.type_alias { T.any(Symbol, String) }
33
33
 
34
+ # Next generation of intelligence for the hardest knowledge work and coding problems
35
+ CLAUDE_FABLE_5 =
36
+ T.let(
37
+ :"claude-fable-5",
38
+ Anthropic::Beta::BetaManagedAgentsModel::TaggedSymbol
39
+ )
40
+
34
41
  # Frontier intelligence for long-running agents and coding
35
42
  CLAUDE_OPUS_4_8 =
36
43
  T.let(
@@ -197,7 +197,8 @@ module Anthropic
197
197
  Anthropic::Beta::BetaMCPToolUseBlock::OrHash,
198
198
  Anthropic::Beta::BetaMCPToolResultBlock::OrHash,
199
199
  Anthropic::Beta::BetaContainerUploadBlock::OrHash,
200
- Anthropic::Beta::BetaCompactionBlock::OrHash
200
+ Anthropic::Beta::BetaCompactionBlock::OrHash,
201
+ Anthropic::Beta::BetaFallbackBlock::OrHash
201
202
  )
202
203
  ],
203
204
  context_management:
@@ -87,7 +87,8 @@ module Anthropic
87
87
  T.any(
88
88
  Anthropic::Beta::BetaMessageIterationUsage::OrHash,
89
89
  Anthropic::Beta::BetaCompactionIterationUsage::OrHash,
90
- Anthropic::Beta::BetaAdvisorMessageIterationUsage::OrHash
90
+ Anthropic::Beta::BetaAdvisorMessageIterationUsage::OrHash,
91
+ Anthropic::Beta::BetaFallbackMessageIterationUsage::OrHash
91
92
  )
92
93
  ]
93
94
  ),
@@ -38,6 +38,13 @@ module Anthropic
38
38
  sig { returns(Integer) }
39
39
  attr_accessor :input_tokens
40
40
 
41
+ # The model that will complete your prompt.
42
+ #
43
+ # See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
44
+ # details and options.
45
+ sig { returns(Anthropic::Model::Variants) }
46
+ attr_accessor :model
47
+
41
48
  # The number of output tokens which were used.
42
49
  sig { returns(Integer) }
43
50
  attr_accessor :output_tokens
@@ -54,6 +61,7 @@ module Anthropic
54
61
  cache_creation_input_tokens: Integer,
55
62
  cache_read_input_tokens: Integer,
56
63
  input_tokens: Integer,
64
+ model: T.any(Anthropic::Model::OrSymbol, String),
57
65
  output_tokens: Integer,
58
66
  type: Symbol
59
67
  ).returns(T.attached_class)
@@ -67,6 +75,11 @@ module Anthropic
67
75
  cache_read_input_tokens:,
68
76
  # The number of input tokens which were used.
69
77
  input_tokens:,
78
+ # The model that will complete your prompt.
79
+ #
80
+ # See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
81
+ # details and options.
82
+ model:,
70
83
  # The number of output tokens which were used.
71
84
  output_tokens:,
72
85
  # Usage for a sampling iteration
@@ -81,6 +94,7 @@ module Anthropic
81
94
  cache_creation_input_tokens: Integer,
82
95
  cache_read_input_tokens: Integer,
83
96
  input_tokens: Integer,
97
+ model: Anthropic::Model::Variants,
84
98
  output_tokens: Integer,
85
99
  type: Symbol
86
100
  }
@@ -15,6 +15,12 @@ module Anthropic
15
15
  sig { returns(String) }
16
16
  attr_accessor :id
17
17
 
18
+ # Model IDs this model accepts as `fallbacks[i].model` on the Messages API. An
19
+ # empty list means the `fallbacks` parameter is not supported for this model as
20
+ # primary.
21
+ sig { returns(T.nilable(T::Array[String])) }
22
+ attr_accessor :allowed_fallback_models
23
+
18
24
  # Model capability information.
19
25
  sig { returns(T.nilable(Anthropic::Beta::BetaModelCapabilities)) }
20
26
  attr_reader :capabilities
@@ -53,6 +59,7 @@ module Anthropic
53
59
  sig do
54
60
  params(
55
61
  id: String,
62
+ allowed_fallback_models: T.nilable(T::Array[String]),
56
63
  capabilities:
57
64
  T.nilable(Anthropic::Beta::BetaModelCapabilities::OrHash),
58
65
  created_at: Time,
@@ -65,6 +72,10 @@ module Anthropic
65
72
  def self.new(
66
73
  # Unique model identifier.
67
74
  id:,
75
+ # Model IDs this model accepts as `fallbacks[i].model` on the Messages API. An
76
+ # empty list means the `fallbacks` parameter is not supported for this model as
77
+ # primary.
78
+ allowed_fallback_models:,
68
79
  # Model capability information.
69
80
  capabilities:,
70
81
  # RFC 3339 datetime string representing the time at which the model was released.
@@ -87,6 +98,7 @@ module Anthropic
87
98
  override.returns(
88
99
  {
89
100
  id: String,
101
+ allowed_fallback_models: T.nilable(T::Array[String]),
90
102
  capabilities: T.nilable(Anthropic::Beta::BetaModelCapabilities),
91
103
  created_at: Time,
92
104
  display_name: String,
@@ -47,7 +47,8 @@ module Anthropic
47
47
  Anthropic::Beta::BetaMCPToolUseBlock::OrHash,
48
48
  Anthropic::Beta::BetaMCPToolResultBlock::OrHash,
49
49
  Anthropic::Beta::BetaContainerUploadBlock::OrHash,
50
- Anthropic::Beta::BetaCompactionBlock::OrHash
50
+ Anthropic::Beta::BetaCompactionBlock::OrHash,
51
+ Anthropic::Beta::BetaFallbackBlock::OrHash
51
52
  ),
52
53
  index: Integer,
53
54
  type: Symbol
@@ -96,7 +97,8 @@ module Anthropic
96
97
  Anthropic::Beta::BetaMCPToolUseBlock,
97
98
  Anthropic::Beta::BetaMCPToolResultBlock,
98
99
  Anthropic::Beta::BetaContainerUploadBlock,
99
- Anthropic::Beta::BetaCompactionBlock
100
+ Anthropic::Beta::BetaCompactionBlock,
101
+ Anthropic::Beta::BetaFallbackBlock
100
102
  )
101
103
  end
102
104
 
@@ -33,6 +33,56 @@ module Anthropic
33
33
  sig { returns(T.nilable(String)) }
34
34
  attr_accessor :explanation
35
35
 
36
+ # Opaque code that refunds the cache-miss cost when retrying this refused request
37
+ # on the fallback model. Pass it as `fallback_credit_token` on the retry request.
38
+ # Expires 5 minutes after the refusal.
39
+ #
40
+ # The retry is sent either with the same request body (`system`, `messages`,
41
+ # `tools`, and other render-shaping fields), or with the same body plus one
42
+ # appended `assistant` message whose content is the partial text (with any
43
+ # trailing whitespace stripped from the final text block) and paired server-tool
44
+ # blocks from this refusal — which also authorizes that appended turn as an
45
+ # assistant-prefill continuation on models that otherwise disallow prefill. A
46
+ # token minted mid-server-tool-loop whose partial content was continuable may only
47
+ # be redeemed the second way — if a same-body retry is rejected with a 400 saying
48
+ # the token must be redeemed by continuing the partial response, retry the second
49
+ # way instead. Either way: same workspace, same platform; a mismatch is a 400.
50
+ # Resending a token for an already-warm prefix is permitted but yields no
51
+ # additional credit.
52
+ #
53
+ # `null` when the refused model isn't eligible for a fallback credit.
54
+ sig { returns(T.nilable(String)) }
55
+ attr_accessor :fallback_credit_token
56
+
57
+ # Whether the accompanying `fallback_credit_token` may be redeemed with the
58
+ # appended-assistant retry form. Only set when `fallback_credit_token` is present.
59
+ #
60
+ # `true`: retry by resending the same request body plus one appended `assistant`
61
+ # message whose content is this response's `content` with any trailing whitespace
62
+ # stripped from the final text block and unpaired `tool_use` blocks omitted (the
63
+ # same appended-turn shape described on `fallback_credit_token`), with the token
64
+ # attached. `false`: retry by resending the original request body unchanged, with
65
+ # the token attached — the appended-assistant form is not available for this
66
+ # refusal (no continuable partial content, or the request uses `output_format` or
67
+ # a `tool_choice` that forces tool use). One exception: when the request used
68
+ # `output_format` or a forced `tool_choice` and the refusal arrived after server
69
+ # tools (including MCP connector tools) had already executed, the token may not be
70
+ # redeemable by either retry form; if the exact-body retry is then rejected with a
71
+ # 400 saying the token must be redeemed by continuing the partial response,
72
+ # discard the token and retry without it.
73
+ #
74
+ # Advisory: if an appended-assistant retry is rejected with a 400 despite `true`,
75
+ # fall back to resending the original request body with the token.
76
+ sig { returns(T.nilable(T::Boolean)) }
77
+ attr_accessor :fallback_has_prefill_claim
78
+
79
+ # The server's suggested retry target for this refusal. Populated when a fallback
80
+ # attempt could not be made (the fallback model's rate limit was exhausted, or it
81
+ # was overloaded); names the fallback model the caller can retry directly. Null
82
+ # otherwise.
83
+ sig { returns(T.nilable(String)) }
84
+ attr_accessor :recommended_model
85
+
36
86
  sig { returns(Symbol) }
37
87
  attr_accessor :type
38
88
 
@@ -44,6 +94,9 @@ module Anthropic
44
94
  Anthropic::Beta::BetaRefusalStopDetails::Category::OrSymbol
45
95
  ),
46
96
  explanation: T.nilable(String),
97
+ fallback_credit_token: T.nilable(String),
98
+ fallback_has_prefill_claim: T.nilable(T::Boolean),
99
+ recommended_model: T.nilable(String),
47
100
  type: Symbol
48
101
  ).returns(T.attached_class)
49
102
  end
@@ -57,6 +110,50 @@ module Anthropic
57
110
  # This text is not guaranteed to be stable. `null` when no explanation is
58
111
  # available for the category.
59
112
  explanation:,
113
+ # Opaque code that refunds the cache-miss cost when retrying this refused request
114
+ # on the fallback model. Pass it as `fallback_credit_token` on the retry request.
115
+ # Expires 5 minutes after the refusal.
116
+ #
117
+ # The retry is sent either with the same request body (`system`, `messages`,
118
+ # `tools`, and other render-shaping fields), or with the same body plus one
119
+ # appended `assistant` message whose content is the partial text (with any
120
+ # trailing whitespace stripped from the final text block) and paired server-tool
121
+ # blocks from this refusal — which also authorizes that appended turn as an
122
+ # assistant-prefill continuation on models that otherwise disallow prefill. A
123
+ # token minted mid-server-tool-loop whose partial content was continuable may only
124
+ # be redeemed the second way — if a same-body retry is rejected with a 400 saying
125
+ # the token must be redeemed by continuing the partial response, retry the second
126
+ # way instead. Either way: same workspace, same platform; a mismatch is a 400.
127
+ # Resending a token for an already-warm prefix is permitted but yields no
128
+ # additional credit.
129
+ #
130
+ # `null` when the refused model isn't eligible for a fallback credit.
131
+ fallback_credit_token:,
132
+ # Whether the accompanying `fallback_credit_token` may be redeemed with the
133
+ # appended-assistant retry form. Only set when `fallback_credit_token` is present.
134
+ #
135
+ # `true`: retry by resending the same request body plus one appended `assistant`
136
+ # message whose content is this response's `content` with any trailing whitespace
137
+ # stripped from the final text block and unpaired `tool_use` blocks omitted (the
138
+ # same appended-turn shape described on `fallback_credit_token`), with the token
139
+ # attached. `false`: retry by resending the original request body unchanged, with
140
+ # the token attached — the appended-assistant form is not available for this
141
+ # refusal (no continuable partial content, or the request uses `output_format` or
142
+ # a `tool_choice` that forces tool use). One exception: when the request used
143
+ # `output_format` or a forced `tool_choice` and the refusal arrived after server
144
+ # tools (including MCP connector tools) had already executed, the token may not be
145
+ # redeemable by either retry form; if the exact-body retry is then rejected with a
146
+ # 400 saying the token must be redeemed by continuing the partial response,
147
+ # discard the token and retry without it.
148
+ #
149
+ # Advisory: if an appended-assistant retry is rejected with a 400 despite `true`,
150
+ # fall back to resending the original request body with the token.
151
+ fallback_has_prefill_claim:,
152
+ # The server's suggested retry target for this refusal. Populated when a fallback
153
+ # attempt could not be made (the fallback model's rate limit was exhausted, or it
154
+ # was overloaded); names the fallback model the caller can retry directly. Null
155
+ # otherwise.
156
+ recommended_model:,
60
157
  type: :refusal
61
158
  )
62
159
  end
@@ -69,6 +166,9 @@ module Anthropic
69
166
  Anthropic::Beta::BetaRefusalStopDetails::Category::TaggedSymbol
70
167
  ),
71
168
  explanation: T.nilable(String),
169
+ fallback_credit_token: T.nilable(String),
170
+ fallback_has_prefill_claim: T.nilable(T::Boolean),
171
+ recommended_model: T.nilable(String),
72
172
  type: Symbol
73
173
  }
74
174
  )
@@ -98,6 +198,11 @@ module Anthropic
98
198
  :bio,
99
199
  Anthropic::Beta::BetaRefusalStopDetails::Category::TaggedSymbol
100
200
  )
201
+ REASONING_EXTRACTION =
202
+ T.let(
203
+ :reasoning_extraction,
204
+ Anthropic::Beta::BetaRefusalStopDetails::Category::TaggedSymbol
205
+ )
101
206
 
102
207
  sig do
103
208
  override.returns(
@@ -25,14 +25,22 @@ module Anthropic
25
25
  sig { returns(Symbol) }
26
26
  attr_accessor :type
27
27
 
28
+ sig { returns(T.nilable(String)) }
29
+ attr_accessor :error_message
30
+
28
31
  sig do
29
32
  params(
30
33
  error_code:
31
34
  Anthropic::Beta::BetaToolSearchToolResultErrorParam::ErrorCode::OrSymbol,
35
+ error_message: T.nilable(String),
32
36
  type: Symbol
33
37
  ).returns(T.attached_class)
34
38
  end
35
- def self.new(error_code:, type: :tool_search_tool_result_error)
39
+ def self.new(
40
+ error_code:,
41
+ error_message: nil,
42
+ type: :tool_search_tool_result_error
43
+ )
36
44
  end
37
45
 
38
46
  sig do
@@ -40,7 +48,8 @@ module Anthropic
40
48
  {
41
49
  error_code:
42
50
  Anthropic::Beta::BetaToolSearchToolResultErrorParam::ErrorCode::OrSymbol,
43
- type: Symbol
51
+ type: Symbol,
52
+ error_message: T.nilable(String)
44
53
  }
45
54
  )
46
55
  end
@@ -117,7 +117,8 @@ module Anthropic
117
117
  T.any(
118
118
  Anthropic::Beta::BetaMessageIterationUsage::OrHash,
119
119
  Anthropic::Beta::BetaCompactionIterationUsage::OrHash,
120
- Anthropic::Beta::BetaAdvisorMessageIterationUsage::OrHash
120
+ Anthropic::Beta::BetaAdvisorMessageIterationUsage::OrHash,
121
+ Anthropic::Beta::BetaFallbackMessageIterationUsage::OrHash
121
122
  )
122
123
  ]
123
124
  ),
@@ -15,7 +15,7 @@ module Anthropic
15
15
  )
16
16
  end
17
17
 
18
- # ID of the resource that triggered the event.
18
+ # ID of the session that triggered the event.
19
19
  sig { returns(String) }
20
20
  attr_accessor :id
21
21
 
@@ -37,7 +37,7 @@ module Anthropic
37
37
  ).returns(T.attached_class)
38
38
  end
39
39
  def self.new(
40
- # ID of the resource that triggered the event.
40
+ # ID of the session that triggered the event.
41
41
  id:,
42
42
  organization_id:,
43
43
  workspace_id:,
@@ -15,7 +15,7 @@ module Anthropic
15
15
  )
16
16
  end
17
17
 
18
- # ID of the resource that triggered the event.
18
+ # ID of the session that triggered the event.
19
19
  sig { returns(String) }
20
20
  attr_accessor :id
21
21
 
@@ -37,7 +37,7 @@ module Anthropic
37
37
  ).returns(T.attached_class)
38
38
  end
39
39
  def self.new(
40
- # ID of the resource that triggered the event.
40
+ # ID of the session that triggered the event.
41
41
  id:,
42
42
  organization_id:,
43
43
  workspace_id:,
@@ -15,7 +15,7 @@ module Anthropic
15
15
  )
16
16
  end
17
17
 
18
- # ID of the resource that triggered the event.
18
+ # ID of the session that triggered the event.
19
19
  sig { returns(String) }
20
20
  attr_accessor :id
21
21
 
@@ -37,7 +37,7 @@ module Anthropic
37
37
  ).returns(T.attached_class)
38
38
  end
39
39
  def self.new(
40
- # ID of the resource that triggered the event.
40
+ # ID of the session that triggered the event.
41
41
  id:,
42
42
  organization_id:,
43
43
  workspace_id:,
@@ -14,7 +14,7 @@ module Anthropic
14
14
  )
15
15
  end
16
16
 
17
- # ID of the resource that triggered the event.
17
+ # ID of the session that triggered the event.
18
18
  sig { returns(String) }
19
19
  attr_accessor :id
20
20
 
@@ -36,7 +36,7 @@ module Anthropic
36
36
  ).returns(T.attached_class)
37
37
  end
38
38
  def self.new(
39
- # ID of the resource that triggered the event.
39
+ # ID of the session that triggered the event.
40
40
  id:,
41
41
  organization_id:,
42
42
  workspace_id:,