anthropic 1.49.0 → 1.51.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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/README.md +1 -1
  4. data/lib/anthropic/helpers/stainless_helper_header.rb +43 -0
  5. data/lib/anthropic/helpers/tools/runner.rb +8 -4
  6. data/lib/anthropic/internal/stream.rb +1 -1
  7. data/lib/anthropic/internal/util.rb +18 -9
  8. data/lib/anthropic/models/beta/agent_create_params.rb +3 -1
  9. data/lib/anthropic/models/beta/agent_update_params.rb +6 -3
  10. data/lib/anthropic/models/beta/beta_cache_control_ephemeral.rb +6 -2
  11. data/lib/anthropic/models/beta/beta_fallback_refusal_trigger.rb +1 -0
  12. data/lib/anthropic/models/beta/beta_refusal_stop_details.rb +1 -0
  13. data/lib/anthropic/models/beta/beta_thinking_config_enabled.rb +1 -1
  14. data/lib/anthropic/models/beta/beta_thinking_config_param.rb +1 -1
  15. data/lib/anthropic/models/beta/beta_tool_union.rb +5 -1
  16. data/lib/anthropic/models/beta/beta_web_fetch_tool_20260318.rb +167 -0
  17. data/lib/anthropic/models/beta/beta_web_search_tool_20260318.rb +150 -0
  18. data/lib/anthropic/models/beta/message_count_tokens_params.rb +30 -14
  19. data/lib/anthropic/models/beta/message_create_params.rb +32 -26
  20. data/lib/anthropic/models/beta/messages/batch_create_params.rb +41 -30
  21. data/lib/anthropic/models/cache_control_ephemeral.rb +6 -2
  22. data/lib/anthropic/models/completion_create_params.rb +4 -2
  23. data/lib/anthropic/models/message_count_tokens_params.rb +25 -13
  24. data/lib/anthropic/models/message_count_tokens_tool.rb +5 -1
  25. data/lib/anthropic/models/message_create_params.rb +32 -17
  26. data/lib/anthropic/models/messages/batch_create_params.rb +40 -20
  27. data/lib/anthropic/models/refusal_stop_details.rb +1 -0
  28. data/lib/anthropic/models/thinking_config_enabled.rb +1 -1
  29. data/lib/anthropic/models/thinking_config_param.rb +1 -1
  30. data/lib/anthropic/models/tool_union.rb +5 -1
  31. data/lib/anthropic/models/web_fetch_tool_20260318.rb +163 -0
  32. data/lib/anthropic/models/web_search_tool_20260318.rb +146 -0
  33. data/lib/anthropic/models.rb +4 -0
  34. data/lib/anthropic/resources/beta/messages/batches.rb +10 -8
  35. data/lib/anthropic/resources/beta/messages.rb +19 -17
  36. data/lib/anthropic/resources/completions.rb +4 -4
  37. data/lib/anthropic/resources/messages/batches.rb +13 -9
  38. data/lib/anthropic/resources/messages.rb +74 -54
  39. data/lib/anthropic/version.rb +1 -1
  40. data/lib/anthropic.rb +5 -0
  41. data/rbi/anthropic/models/beta/agent_create_params.rbi +6 -2
  42. data/rbi/anthropic/models/beta/agent_update_params.rbi +10 -4
  43. data/rbi/anthropic/models/beta/beta_cache_control_ephemeral.rbi +9 -3
  44. data/rbi/anthropic/models/beta/beta_fallback_refusal_trigger.rbi +5 -0
  45. data/rbi/anthropic/models/beta/beta_refusal_stop_details.rbi +5 -0
  46. data/rbi/anthropic/models/beta/beta_thinking_config_enabled.rbi +2 -2
  47. data/rbi/anthropic/models/beta/beta_thinking_config_param.rbi +1 -1
  48. data/rbi/anthropic/models/beta/beta_tool_union.rbi +2 -0
  49. data/rbi/anthropic/models/beta/beta_web_fetch_tool_20260318.rbi +319 -0
  50. data/rbi/anthropic/models/beta/beta_web_search_tool_20260318.rbi +296 -0
  51. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +48 -19
  52. data/rbi/anthropic/models/beta/message_create_params.rbi +58 -36
  53. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +75 -44
  54. data/rbi/anthropic/models/cache_control_ephemeral.rbi +9 -3
  55. data/rbi/anthropic/models/completion_create_params.rbi +8 -4
  56. data/rbi/anthropic/models/message_count_tokens_params.rbi +46 -19
  57. data/rbi/anthropic/models/message_count_tokens_tool.rbi +2 -0
  58. data/rbi/anthropic/models/message_create_params.rbi +58 -26
  59. data/rbi/anthropic/models/messages/batch_create_params.rbi +72 -31
  60. data/rbi/anthropic/models/refusal_stop_details.rbi +5 -0
  61. data/rbi/anthropic/models/thinking_config_enabled.rbi +2 -2
  62. data/rbi/anthropic/models/thinking_config_param.rbi +1 -1
  63. data/rbi/anthropic/models/tool_union.rbi +2 -0
  64. data/rbi/anthropic/models/web_fetch_tool_20260318.rbi +295 -0
  65. data/rbi/anthropic/models/web_search_tool_20260318.rbi +272 -0
  66. data/rbi/anthropic/models.rbi +4 -0
  67. data/rbi/anthropic/resources/beta/agents.rbi +7 -2
  68. data/rbi/anthropic/resources/beta/messages/batches.rbi +13 -6
  69. data/rbi/anthropic/resources/beta/messages.rbi +70 -44
  70. data/rbi/anthropic/resources/completions.rbi +12 -8
  71. data/rbi/anthropic/resources/messages/batches.rbi +15 -8
  72. data/rbi/anthropic/resources/messages.rbi +125 -88
  73. data/rbi/lib/anthropic/helpers/stainless_helper_header.rbi +17 -0
  74. data/sig/anthropic/models/beta/beta_fallback_refusal_trigger.rbs +7 -1
  75. data/sig/anthropic/models/beta/beta_refusal_stop_details.rbs +7 -1
  76. data/sig/anthropic/models/beta/beta_tool_union.rbs +2 -0
  77. data/sig/anthropic/models/beta/beta_web_fetch_tool_20260318.rbs +126 -0
  78. data/sig/anthropic/models/beta/beta_web_search_tool_20260318.rbs +114 -0
  79. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +10 -1
  80. data/sig/anthropic/models/beta/message_create_params.rbs +8 -6
  81. data/sig/anthropic/models/beta/messages/batch_create_params.rbs +11 -9
  82. data/sig/anthropic/models/message_count_tokens_params.rbs +8 -1
  83. data/sig/anthropic/models/message_count_tokens_tool.rbs +2 -0
  84. data/sig/anthropic/models/message_create_params.rbs +8 -1
  85. data/sig/anthropic/models/messages/batch_create_params.rbs +10 -1
  86. data/sig/anthropic/models/refusal_stop_details.rbs +7 -1
  87. data/sig/anthropic/models/tool_union.rbs +2 -0
  88. data/sig/anthropic/models/web_fetch_tool_20260318.rbs +122 -0
  89. data/sig/anthropic/models/web_search_tool_20260318.rbs +110 -0
  90. data/sig/anthropic/models.rbs +4 -0
  91. data/sig/anthropic/resources/beta/messages/batches.rbs +1 -0
  92. data/sig/anthropic/resources/beta/messages.rbs +3 -2
  93. data/sig/anthropic/resources/messages/batches.rbs +1 -0
  94. data/sig/anthropic/resources/messages.rbs +3 -0
  95. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45df9830dd4224180e2702068ad79b01ad5f045a6499969bbddfc5a49f29cec9
4
- data.tar.gz: f501463bdb25da9354140ada09b8c638064fcf1c57ae751e9156c526b5281acb
3
+ metadata.gz: 8a4c0796098c3ebac37542205f404f39263436276c044cd39be1662a1ded8678
4
+ data.tar.gz: 7ca2ad565fec49876126eb5fbe9844d4b6bafb17e458affe3bd55dd886fb3d08
5
5
  SHA512:
6
- metadata.gz: d4521d3d6191009cd99cd92898d6cfdca44ae99908d06ddaafee22665f21ba4751c6c02c5fb705ddea04827251769b69c53e62734e9edb04f60f9aa7dffe6802
7
- data.tar.gz: 7d917f565b12839a5755d0e9638d2d57a05a489bd022d3284f2ba4bd812d488f5b2b635e38f8a3ad12fb24f8c305a7dcb16aed77d9c7ca17f66386183e607c39
6
+ metadata.gz: 6c20d2fda644c967e8a35b355af2507e077e974799b9ff74c52a2541bf713aee633f5bf9a1a15313d9bed76bb17659c5c5bf7ebb423284aefa785548a9a53a2d
7
+ data.tar.gz: 85c59aa18c96f05734279721f01cba261791f4196e1fde65a4e6ee939ca5a8adc9ba11efae83fde00aff36e4f41cd55e8d5596c8142359343655c9d88bb7d3c7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.51.0 (2026-06-29)
4
+
5
+ Full Changelog: [v1.50.0...v1.51.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.50.0...v1.51.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** add support for 20260318 web fetch and support tools ([bb82831](https://github.com/anthropics/anthropic-sdk-ruby/commit/bb828319b6d9b5965f45c1988c6a182c234abba7))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **client:** merge anthropic-beta header across sources instead of overwriting ([#60](https://github.com/anthropics/anthropic-sdk-ruby/issues/60)) ([fe31ce8](https://github.com/anthropics/anthropic-sdk-ruby/commit/fe31ce853146173fcd00872b1d6dc4db50bbe23c))
15
+
16
+
17
+ ### Chores
18
+
19
+ * **api:** accept user profile ID's when counting tokens ([b5f48bb](https://github.com/anthropics/anthropic-sdk-ruby/commit/b5f48bb2236f17f0c8bca19b2722c78e40acc671))
20
+ * **docs:** updates to descriptions and example values ([e8c63fe](https://github.com/anthropics/anthropic-sdk-ruby/commit/e8c63fee97b136259b6f193fbe856886266096a6))
21
+
22
+ ## 1.50.0 (2026-06-24)
23
+
24
+ Full Changelog: [v1.49.0...v1.50.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.49.0...v1.50.0)
25
+
26
+ ### Features
27
+
28
+ * **client:** add support for system.message streaming events ([2333173](https://github.com/anthropics/anthropic-sdk-ruby/commit/23331737588b1942dfda599a04ccb23109824f80))
29
+ * **helpers:** single source for x-stainless-helper + tag the BetaToolRunner ([#36](https://github.com/anthropics/anthropic-sdk-ruby/issues/36)) ([95124e5](https://github.com/anthropics/anthropic-sdk-ruby/commit/95124e582c1f413b5dd05f4cc5dafecfe87b6666))
30
+
31
+
32
+ ### Chores
33
+
34
+ * **api:** add support for new refusal category ([9b5050f](https://github.com/anthropics/anthropic-sdk-ruby/commit/9b5050f677532d60ee8b47e08c62b3e59aacdc7b))
35
+ * **api:** add support for sending User Profile ID in request headers ([4a263e8](https://github.com/anthropics/anthropic-sdk-ruby/commit/4a263e8b43096c92533701eb4423c2abc21e3408))
36
+
3
37
  ## 1.49.0 (2026-06-18)
4
38
 
5
39
  Full Changelog: [v1.48.2...v1.49.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.48.2...v1.49.0)
data/README.md CHANGED
@@ -15,7 +15,7 @@ Add to your application's Gemfile:
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "anthropic", "~> 1.49.0"
18
+ gem "anthropic", "~> 1.51.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ # Single source of truth for the `x-stainless-helper` telemetry header — the
6
+ # key, the closed value vocabulary shared across SDKs, and the comma-append
7
+ # merge.
8
+ #
9
+ # @api private
10
+ module StainlessHelperHeader
11
+ # Telemetry header naming the SDK helper(s) a request came from. Always
12
+ # this lowercase form; header lookups are case-insensitive but a single
13
+ # canonical casing keeps every call site greppable.
14
+ HEADER = "x-stainless-helper"
15
+
16
+ # Closed value vocabulary. Existing values keep their original spellings —
17
+ # telemetry consumers match on them, so renames lose history. New tags are
18
+ # hyphenated lowercase.
19
+ BETA_TOOL_RUNNER = "BetaToolRunner"
20
+
21
+ class << self
22
+ # The {HEADER} value to set after appending `value` to whatever is
23
+ # already present in `headers` — existing tags keep their position, the
24
+ # new tag goes at the end, duplicates are dropped, joined as one
25
+ # comma-separated string. The backend logs the header as one opaque
26
+ # string, so a second header line or a clobbered value loses data.
27
+ #
28
+ # @param headers [Hash{String => String}]
29
+ # @param value [String]
30
+ # @return [String]
31
+ def merged_value(headers, value)
32
+ existing =
33
+ headers
34
+ .filter_map { |k, v| v if k.to_s.casecmp?(HEADER) }
35
+ .flat_map { _1.to_s.split(",") }
36
+ .map(&:strip)
37
+ .reject(&:empty?)
38
+ (existing + [value]).uniq.join(", ")
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -25,7 +25,7 @@ module Anthropic
25
25
  message = nil
26
26
  unless finished?
27
27
  fold do
28
- message = @client.beta.messages.create(with_helper_header(_1, "runner"))
28
+ message = @client.beta.messages.create(with_helper_header(_1, StainlessHelperHeader::BETA_TOOL_RUNNER))
29
29
  [true, message]
30
30
  end
31
31
  end
@@ -46,7 +46,7 @@ module Anthropic
46
46
  end
47
47
 
48
48
  fold do
49
- message = @client.beta.messages.create(with_helper_header(_1, "runner"))
49
+ message = @client.beta.messages.create(with_helper_header(_1, StainlessHelperHeader::BETA_TOOL_RUNNER))
50
50
  blk.call(message)
51
51
  [false, message]
52
52
  end
@@ -59,7 +59,7 @@ module Anthropic
59
59
  end
60
60
 
61
61
  fold do
62
- stream = @client.beta.messages.stream(with_helper_header(_1, "runner"))
62
+ stream = @client.beta.messages.stream(with_helper_header(_1, StainlessHelperHeader::BETA_TOOL_RUNNER))
63
63
  blk.call(stream)
64
64
  [false, stream.accumulated_message]
65
65
  ensure
@@ -260,8 +260,12 @@ module Anthropic
260
260
  private def with_helper_header(params, helper)
261
261
  options = params[:request_options] || {}
262
262
  headers = options[:extra_headers] || {}
263
+ merged = StainlessHelperHeader.merged_value(headers, helper)
263
264
 
264
- {**params, request_options: {**options, extra_headers: {**headers, "x-stainless-helper" => helper}}}
265
+ {
266
+ **params,
267
+ request_options: {**options, extra_headers: {**headers, StainlessHelperHeader::HEADER => merged}}
268
+ }
265
269
  end
266
270
  end
267
271
  end
@@ -26,7 +26,7 @@ module Anthropic
26
26
  unwrapped = Anthropic::Internal::Util.dig(decoded, @unwrap)
27
27
  y << Anthropic::Internal::Type::Converter.coerce(@model, unwrapped)
28
28
  in {
29
- event: "message_start" | "message_delta" | "message_stop" | "content_block_start" | "content_block_delta" | "content_block_stop" | "message" | "user.message" | "user.interrupt" | "user.tool_confirmation" | "user.custom_tool_result" | "user.tool_result" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "agent.mcp_tool_use" | "agent.mcp_tool_result" | "agent.custom_tool_use" | "agent.thread_context_compacted" | "session.status_running" | "session.status_idle" | "session.status_rescheduled" | "session.status_terminated" | "session.error" | "session.deleted" | "session.updated" | "span.model_request_start" | "span.model_request_end" | "span.outcome_evaluation_start" | "span.outcome_evaluation_ongoing" | "span.outcome_evaluation_end" | "user.define_outcome" | "agent.thread_message_received" | "agent.thread_message_sent" | "agent.session_thread_message_received" | "agent.session_thread_message_sent" | "session.thread_created" | "session.thread_status_created" | "session.thread_status_running" | "session.thread_status_idle" | "session.thread_status_rescheduled" | "session.thread_status_terminated",
29
+ event: "message_start" | "message_delta" | "message_stop" | "content_block_start" | "content_block_delta" | "content_block_stop" | "message" | "user.message" | "user.interrupt" | "user.tool_confirmation" | "user.custom_tool_result" | "user.tool_result" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "agent.mcp_tool_use" | "agent.mcp_tool_result" | "agent.custom_tool_use" | "agent.thread_context_compacted" | "session.status_running" | "session.status_idle" | "session.status_rescheduled" | "session.status_terminated" | "session.error" | "session.deleted" | "session.updated" | "span.model_request_start" | "span.model_request_end" | "span.outcome_evaluation_start" | "span.outcome_evaluation_ongoing" | "span.outcome_evaluation_end" | "user.define_outcome" | "agent.thread_message_received" | "agent.thread_message_sent" | "agent.session_thread_message_received" | "agent.session_thread_message_sent" | "session.thread_created" | "session.thread_status_created" | "session.thread_status_running" | "session.thread_status_idle" | "session.thread_status_rescheduled" | "session.thread_status_terminated" | "system.message",
30
30
  data: String => data
31
31
  }
32
32
  decoded = JSON.parse(data, symbolize_names: true)
@@ -412,19 +412,28 @@ module Anthropic
412
412
  class << self
413
413
  # @api private
414
414
  #
415
+ # Later hashes take precedence on key collision, except `anthropic-beta`
416
+ # which is additive: values from every input are collected so endpoint
417
+ # defaults don't drop the caller's `betas:` or the client OAuth beta.
418
+ #
415
419
  # @param headers [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}]
416
420
  #
417
421
  # @return [Hash{String=>String}]
418
422
  def normalized_headers(*headers)
419
- {}.merge(*headers.compact).to_h do |key, val|
420
- value =
421
- case val
422
- in Array
423
- val.filter_map { _1&.to_s&.strip }.join(", ")
424
- else
425
- val&.to_s&.strip
426
- end
427
- [key.downcase, value]
423
+ merged = {}
424
+ headers.each do |hdrs|
425
+ hdrs.to_h.each do |key, val|
426
+ k = key.to_s.downcase
427
+ merged[k] = k == "anthropic-beta" && merged.key?(k) ? [*merged[k], *val] : val
428
+ end
429
+ end
430
+ merged.transform_values do |val|
431
+ case val
432
+ in Array
433
+ val.filter_map { _1&.to_s&.strip }.join(", ")
434
+ else
435
+ val&.to_s&.strip
436
+ end
428
437
  end
429
438
  end
430
439
  end
@@ -31,7 +31,9 @@ module Anthropic
31
31
 
32
32
  # @!attribute mcp_servers
33
33
  # MCP servers this agent connects to. Maximum 20. Names must be unique within the
34
- # array.
34
+ # array. Every server must be referenced by an `mcp_toolset` in `tools`;
35
+ # unreferenced servers are rejected. See the
36
+ # [MCP connector guide](https://platform.claude.com/docs/en/managed-agents/mcp-connector).
35
37
  #
36
38
  # @return [Array<Anthropic::Models::Beta::BetaManagedAgentsURLMCPServerParams>, nil]
37
39
  optional :mcp_servers,
@@ -28,8 +28,11 @@ module Anthropic
28
28
  optional :description, String, nil?: true
29
29
 
30
30
  # @!attribute mcp_servers
31
- # MCP servers. Full replacement. Omit to preserve; send empty array or null to
32
- # clear. Names must be unique. Maximum 20.
31
+ # MCP servers. Full replacement. Omit to preserve; send empty array or `null` to
32
+ # clear. Names must be unique. Maximum 20. Every server must be referenced by an
33
+ # `mcp_toolset` in the agent's resulting `tools`; unreferenced servers are
34
+ # rejected. See the
35
+ # [MCP connector guide](https://platform.claude.com/docs/en/managed-agents/mcp-connector).
33
36
  #
34
37
  # @return [Array<Anthropic::Models::Beta::BetaManagedAgentsURLMCPServerParams>, nil]
35
38
  optional :mcp_servers,
@@ -110,7 +113,7 @@ module Anthropic
110
113
  #
111
114
  # @param description [String, nil] Description. Omit to preserve; send empty string or null to clear.
112
115
  #
113
- # @param mcp_servers [Array<Anthropic::Models::Beta::BetaManagedAgentsURLMCPServerParams>, nil] MCP servers. Full replacement. Omit to preserve; send empty array or null to cle
116
+ # @param mcp_servers [Array<Anthropic::Models::Beta::BetaManagedAgentsURLMCPServerParams>, nil] MCP servers. Full replacement. Omit to preserve; send empty array or `null` to c
114
117
  #
115
118
  # @param metadata [Hash{Symbol=>String, nil}, nil] Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omi
116
119
  #
@@ -17,7 +17,9 @@ module Anthropic
17
17
  # - `5m`: 5 minutes
18
18
  # - `1h`: 1 hour
19
19
  #
20
- # Defaults to `5m`.
20
+ # Defaults to `5m`. See
21
+ # [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)
22
+ # for details.
21
23
  #
22
24
  # @return [Symbol, Anthropic::Models::Beta::BetaCacheControlEphemeral::TTL, nil]
23
25
  optional :ttl, enum: -> { Anthropic::Beta::BetaCacheControlEphemeral::TTL }
@@ -37,7 +39,9 @@ module Anthropic
37
39
  # - `5m`: 5 minutes
38
40
  # - `1h`: 1 hour
39
41
  #
40
- # Defaults to `5m`.
42
+ # Defaults to `5m`. See
43
+ # [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)
44
+ # for details.
41
45
  #
42
46
  # @see Anthropic::Models::Beta::BetaCacheControlEphemeral#ttl
43
47
  module TTL
@@ -32,6 +32,7 @@ module Anthropic
32
32
  BIO = :bio
33
33
  FRONTIER_LLM = :frontier_llm
34
34
  REASONING_EXTRACTION = :reasoning_extraction
35
+ MILITARY_WEAPONS = :military_weapons
35
36
 
36
37
  # @!method self.values
37
38
  # @return [Array<Symbol>]
@@ -108,6 +108,7 @@ module Anthropic
108
108
  BIO = :bio
109
109
  FRONTIER_LLM = :frontier_llm
110
110
  REASONING_EXTRACTION = :reasoning_extraction
111
+ MILITARY_WEAPONS = :military_weapons
111
112
 
112
113
  # @!method self.values
113
114
  # @return [Array<Symbol>]
@@ -12,7 +12,7 @@ module Anthropic
12
12
  # Must be ≥1024 and less than `max_tokens`.
13
13
  #
14
14
  # See
15
- # [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
15
+ # [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking)
16
16
  # for details.
17
17
  #
18
18
  # @return [Integer]
@@ -10,7 +10,7 @@ module Anthropic
10
10
  # tokens and counts towards your `max_tokens` limit.
11
11
  #
12
12
  # See
13
- # [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
13
+ # [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking)
14
14
  # for details.
15
15
  module BetaThinkingConfigParam
16
16
  extend Anthropic::Internal::Type::Union
@@ -51,6 +51,10 @@ module Anthropic
51
51
  # Web fetch tool with use_cache parameter for bypassing cached content.
52
52
  variant -> { Anthropic::Beta::BetaWebFetchTool20260309 }
53
53
 
54
+ variant -> { Anthropic::Beta::BetaWebSearchTool20260318 }
55
+
56
+ variant -> { Anthropic::Beta::BetaWebFetchTool20260318 }
57
+
54
58
  variant -> { Anthropic::Beta::BetaAdvisorTool20260301 }
55
59
 
56
60
  variant -> { Anthropic::Beta::BetaToolSearchToolBm25_20251119 }
@@ -64,7 +68,7 @@ module Anthropic
64
68
  variant -> { Anthropic::Beta::BetaMCPToolset }
65
69
 
66
70
  # @!method self.variants
67
- # @return [Array(Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaCodeExecutionTool20260120, Anthropic::Models::Beta::BetaCodeExecutionTool20260521, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaMemoryTool20250818, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolComputerUse20251124, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910, Anthropic::Models::Beta::BetaWebSearchTool20260209, Anthropic::Models::Beta::BetaWebFetchTool20260209, Anthropic::Models::Beta::BetaWebFetchTool20260309, Anthropic::Models::Beta::BetaAdvisorTool20260301, Anthropic::Models::Beta::BetaToolSearchToolBm25_20251119, Anthropic::Models::Beta::BetaToolSearchToolRegex20251119, Anthropic::Models::Beta::BetaMCPToolset)]
71
+ # @return [Array(Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaCodeExecutionTool20260120, Anthropic::Models::Beta::BetaCodeExecutionTool20260521, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaMemoryTool20250818, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolComputerUse20251124, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910, Anthropic::Models::Beta::BetaWebSearchTool20260209, Anthropic::Models::Beta::BetaWebFetchTool20260209, Anthropic::Models::Beta::BetaWebFetchTool20260309, Anthropic::Models::Beta::BetaWebSearchTool20260318, Anthropic::Models::Beta::BetaWebFetchTool20260318, Anthropic::Models::Beta::BetaAdvisorTool20260301, Anthropic::Models::Beta::BetaToolSearchToolBm25_20251119, Anthropic::Models::Beta::BetaToolSearchToolRegex20251119, Anthropic::Models::Beta::BetaMCPToolset)]
68
72
  end
69
73
  end
70
74
 
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaWebFetchTool20260318 < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute name
8
+ # Name of the tool.
9
+ #
10
+ # This is how the tool will be called by the model and in `tool_use` blocks.
11
+ #
12
+ # @return [Symbol, :web_fetch]
13
+ required :name, const: :web_fetch
14
+
15
+ # @!attribute type
16
+ #
17
+ # @return [Symbol, :web_fetch_20260318]
18
+ required :type, const: :web_fetch_20260318
19
+
20
+ # @!attribute allowed_callers
21
+ #
22
+ # @return [Array<Symbol, Anthropic::Models::Beta::BetaWebFetchTool20260318::AllowedCaller>, nil]
23
+ optional :allowed_callers,
24
+ -> { Anthropic::Internal::Type::ArrayOf[enum: Anthropic::Beta::BetaWebFetchTool20260318::AllowedCaller] }
25
+
26
+ # @!attribute allowed_domains
27
+ # List of domains to allow fetching from
28
+ #
29
+ # @return [Array<String>, nil]
30
+ optional :allowed_domains, Anthropic::Internal::Type::ArrayOf[String], nil?: true
31
+
32
+ # @!attribute blocked_domains
33
+ # List of domains to block fetching from
34
+ #
35
+ # @return [Array<String>, nil]
36
+ optional :blocked_domains, Anthropic::Internal::Type::ArrayOf[String], nil?: true
37
+
38
+ # @!attribute cache_control
39
+ # Create a cache control breakpoint at this content block.
40
+ #
41
+ # @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
42
+ optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
43
+
44
+ # @!attribute citations
45
+ # Citations configuration for fetched documents. Citations are disabled by
46
+ # default.
47
+ #
48
+ # @return [Anthropic::Models::Beta::BetaCitationsConfigParam, nil]
49
+ optional :citations, -> { Anthropic::Beta::BetaCitationsConfigParam }, nil?: true
50
+
51
+ # @!attribute defer_loading
52
+ # If true, tool will not be included in initial system prompt. Only loaded when
53
+ # returned via tool_reference from tool search.
54
+ #
55
+ # @return [Boolean, nil]
56
+ optional :defer_loading, Anthropic::Internal::Type::Boolean
57
+
58
+ # @!attribute max_content_tokens
59
+ # Maximum number of tokens used by including web page text content in the context.
60
+ # The limit is approximate and does not apply to binary content such as PDFs.
61
+ #
62
+ # @return [Integer, nil]
63
+ optional :max_content_tokens, Integer, nil?: true
64
+
65
+ # @!attribute max_uses
66
+ # Maximum number of times the tool can be used in the API request.
67
+ #
68
+ # @return [Integer, nil]
69
+ optional :max_uses, Integer, nil?: true
70
+
71
+ # @!attribute response_inclusion
72
+ # How this tool's result blocks appear in the API response when the result was
73
+ # consumed by a completed code_execution call in the same turn. 'full' returns the
74
+ # complete content (default). 'excluded' drops the nested server_tool_use and
75
+ # result block pair entirely. Results from direct calls, or from code_execution
76
+ # calls that paused before completing, are always returned in full so they can be
77
+ # sent back on the next turn.
78
+ #
79
+ # @return [Symbol, Anthropic::Models::Beta::BetaWebFetchTool20260318::ResponseInclusion, nil]
80
+ optional :response_inclusion, enum: -> { Anthropic::Beta::BetaWebFetchTool20260318::ResponseInclusion }
81
+
82
+ # @!attribute strict
83
+ # When true, guarantees schema validation on tool names and inputs
84
+ #
85
+ # @return [Boolean, nil]
86
+ optional :strict, Anthropic::Internal::Type::Boolean
87
+
88
+ # @!attribute use_cache
89
+ # Whether to use cached content. Set to false to bypass the cache and fetch fresh
90
+ # content. Only set to false when the user explicitly requests fresh content or
91
+ # when fetching rapidly-changing sources.
92
+ #
93
+ # @return [Boolean, nil]
94
+ optional :use_cache, Anthropic::Internal::Type::Boolean
95
+
96
+ # @!method initialize(allowed_callers: nil, allowed_domains: nil, blocked_domains: nil, cache_control: nil, citations: nil, defer_loading: nil, max_content_tokens: nil, max_uses: nil, response_inclusion: nil, strict: nil, use_cache: nil, name: :web_fetch, type: :web_fetch_20260318)
97
+ # Some parameter documentations has been truncated, see
98
+ # {Anthropic::Models::Beta::BetaWebFetchTool20260318} for more details.
99
+ #
100
+ # @param allowed_callers [Array<Symbol, Anthropic::Models::Beta::BetaWebFetchTool20260318::AllowedCaller>]
101
+ #
102
+ # @param allowed_domains [Array<String>, nil] List of domains to allow fetching from
103
+ #
104
+ # @param blocked_domains [Array<String>, nil] List of domains to block fetching from
105
+ #
106
+ # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
107
+ #
108
+ # @param citations [Anthropic::Models::Beta::BetaCitationsConfigParam, nil] Citations configuration for fetched documents. Citations are disabled by default
109
+ #
110
+ # @param defer_loading [Boolean] If true, tool will not be included in initial system prompt. Only loaded when re
111
+ #
112
+ # @param max_content_tokens [Integer, nil] Maximum number of tokens used by including web page text content in the context.
113
+ #
114
+ # @param max_uses [Integer, nil] Maximum number of times the tool can be used in the API request.
115
+ #
116
+ # @param response_inclusion [Symbol, Anthropic::Models::Beta::BetaWebFetchTool20260318::ResponseInclusion] How this tool's result blocks appear in the API response when the result was con
117
+ #
118
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
119
+ #
120
+ # @param use_cache [Boolean] Whether to use cached content. Set to false to bypass the cache and fetch fresh
121
+ #
122
+ # @param name [Symbol, :web_fetch] Name of the tool.
123
+ #
124
+ # @param type [Symbol, :web_fetch_20260318]
125
+
126
+ # Specifies who can invoke a tool.
127
+ #
128
+ # Values: direct: The model can call this tool directly. code_execution_20250825:
129
+ # The tool can be called from the code execution environment (v1).
130
+ # code_execution_20260120: The tool can be called from the code execution
131
+ # environment (v2 with persistence). code_execution_20260521: The tool can be
132
+ # called from the code execution environment (v2 with persistence).
133
+ module AllowedCaller
134
+ extend Anthropic::Internal::Type::Enum
135
+
136
+ DIRECT = :direct
137
+ CODE_EXECUTION_20250825 = :code_execution_20250825
138
+ CODE_EXECUTION_20260120 = :code_execution_20260120
139
+ CODE_EXECUTION_20260521 = :code_execution_20260521
140
+
141
+ # @!method self.values
142
+ # @return [Array<Symbol>]
143
+ end
144
+
145
+ # How this tool's result blocks appear in the API response when the result was
146
+ # consumed by a completed code_execution call in the same turn. 'full' returns the
147
+ # complete content (default). 'excluded' drops the nested server_tool_use and
148
+ # result block pair entirely. Results from direct calls, or from code_execution
149
+ # calls that paused before completing, are always returned in full so they can be
150
+ # sent back on the next turn.
151
+ #
152
+ # @see Anthropic::Models::Beta::BetaWebFetchTool20260318#response_inclusion
153
+ module ResponseInclusion
154
+ extend Anthropic::Internal::Type::Enum
155
+
156
+ FULL = :full
157
+ EXCLUDED = :excluded
158
+
159
+ # @!method self.values
160
+ # @return [Array<Symbol>]
161
+ end
162
+ end
163
+ end
164
+
165
+ BetaWebFetchTool20260318 = Beta::BetaWebFetchTool20260318
166
+ end
167
+ end
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaWebSearchTool20260318 < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute name
8
+ # Name of the tool.
9
+ #
10
+ # This is how the tool will be called by the model and in `tool_use` blocks.
11
+ #
12
+ # @return [Symbol, :web_search]
13
+ required :name, const: :web_search
14
+
15
+ # @!attribute type
16
+ #
17
+ # @return [Symbol, :web_search_20260318]
18
+ required :type, const: :web_search_20260318
19
+
20
+ # @!attribute allowed_callers
21
+ #
22
+ # @return [Array<Symbol, Anthropic::Models::Beta::BetaWebSearchTool20260318::AllowedCaller>, nil]
23
+ optional :allowed_callers,
24
+ -> { Anthropic::Internal::Type::ArrayOf[enum: Anthropic::Beta::BetaWebSearchTool20260318::AllowedCaller] }
25
+
26
+ # @!attribute allowed_domains
27
+ # If provided, only these domains will be included in results. Cannot be used
28
+ # alongside `blocked_domains`.
29
+ #
30
+ # @return [Array<String>, nil]
31
+ optional :allowed_domains, Anthropic::Internal::Type::ArrayOf[String], nil?: true
32
+
33
+ # @!attribute blocked_domains
34
+ # If provided, these domains will never appear in results. Cannot be used
35
+ # alongside `allowed_domains`.
36
+ #
37
+ # @return [Array<String>, nil]
38
+ optional :blocked_domains, Anthropic::Internal::Type::ArrayOf[String], nil?: true
39
+
40
+ # @!attribute cache_control
41
+ # Create a cache control breakpoint at this content block.
42
+ #
43
+ # @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
44
+ optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
45
+
46
+ # @!attribute defer_loading
47
+ # If true, tool will not be included in initial system prompt. Only loaded when
48
+ # returned via tool_reference from tool search.
49
+ #
50
+ # @return [Boolean, nil]
51
+ optional :defer_loading, Anthropic::Internal::Type::Boolean
52
+
53
+ # @!attribute max_uses
54
+ # Maximum number of times the tool can be used in the API request.
55
+ #
56
+ # @return [Integer, nil]
57
+ optional :max_uses, Integer, nil?: true
58
+
59
+ # @!attribute response_inclusion
60
+ # How this tool's result blocks appear in the API response when the result was
61
+ # consumed by a completed code_execution call in the same turn. 'full' returns the
62
+ # complete content (default). 'excluded' drops the nested server_tool_use and
63
+ # result block pair entirely. Results from direct calls, or from code_execution
64
+ # calls that paused before completing, are always returned in full so they can be
65
+ # sent back on the next turn.
66
+ #
67
+ # @return [Symbol, Anthropic::Models::Beta::BetaWebSearchTool20260318::ResponseInclusion, nil]
68
+ optional :response_inclusion, enum: -> { Anthropic::Beta::BetaWebSearchTool20260318::ResponseInclusion }
69
+
70
+ # @!attribute strict
71
+ # When true, guarantees schema validation on tool names and inputs
72
+ #
73
+ # @return [Boolean, nil]
74
+ optional :strict, Anthropic::Internal::Type::Boolean
75
+
76
+ # @!attribute user_location
77
+ # Parameters for the user's location. Used to provide more relevant search
78
+ # results.
79
+ #
80
+ # @return [Anthropic::Models::Beta::BetaUserLocation, nil]
81
+ optional :user_location, -> { Anthropic::Beta::BetaUserLocation }, nil?: true
82
+
83
+ # @!method initialize(allowed_callers: nil, allowed_domains: nil, blocked_domains: nil, cache_control: nil, defer_loading: nil, max_uses: nil, response_inclusion: nil, strict: nil, user_location: nil, name: :web_search, type: :web_search_20260318)
84
+ # Some parameter documentations has been truncated, see
85
+ # {Anthropic::Models::Beta::BetaWebSearchTool20260318} for more details.
86
+ #
87
+ # @param allowed_callers [Array<Symbol, Anthropic::Models::Beta::BetaWebSearchTool20260318::AllowedCaller>]
88
+ #
89
+ # @param allowed_domains [Array<String>, nil] If provided, only these domains will be included in results. Cannot be used alon
90
+ #
91
+ # @param blocked_domains [Array<String>, nil] If provided, these domains will never appear in results. Cannot be used alongsid
92
+ #
93
+ # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
94
+ #
95
+ # @param defer_loading [Boolean] If true, tool will not be included in initial system prompt. Only loaded when re
96
+ #
97
+ # @param max_uses [Integer, nil] Maximum number of times the tool can be used in the API request.
98
+ #
99
+ # @param response_inclusion [Symbol, Anthropic::Models::Beta::BetaWebSearchTool20260318::ResponseInclusion] How this tool's result blocks appear in the API response when the result was con
100
+ #
101
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
102
+ #
103
+ # @param user_location [Anthropic::Models::Beta::BetaUserLocation, nil] Parameters for the user's location. Used to provide more relevant search results
104
+ #
105
+ # @param name [Symbol, :web_search] Name of the tool.
106
+ #
107
+ # @param type [Symbol, :web_search_20260318]
108
+
109
+ # Specifies who can invoke a tool.
110
+ #
111
+ # Values: direct: The model can call this tool directly. code_execution_20250825:
112
+ # The tool can be called from the code execution environment (v1).
113
+ # code_execution_20260120: The tool can be called from the code execution
114
+ # environment (v2 with persistence). code_execution_20260521: The tool can be
115
+ # called from the code execution environment (v2 with persistence).
116
+ module AllowedCaller
117
+ extend Anthropic::Internal::Type::Enum
118
+
119
+ DIRECT = :direct
120
+ CODE_EXECUTION_20250825 = :code_execution_20250825
121
+ CODE_EXECUTION_20260120 = :code_execution_20260120
122
+ CODE_EXECUTION_20260521 = :code_execution_20260521
123
+
124
+ # @!method self.values
125
+ # @return [Array<Symbol>]
126
+ end
127
+
128
+ # How this tool's result blocks appear in the API response when the result was
129
+ # consumed by a completed code_execution call in the same turn. 'full' returns the
130
+ # complete content (default). 'excluded' drops the nested server_tool_use and
131
+ # result block pair entirely. Results from direct calls, or from code_execution
132
+ # calls that paused before completing, are always returned in full so they can be
133
+ # sent back on the next turn.
134
+ #
135
+ # @see Anthropic::Models::Beta::BetaWebSearchTool20260318#response_inclusion
136
+ module ResponseInclusion
137
+ extend Anthropic::Internal::Type::Enum
138
+
139
+ FULL = :full
140
+ EXCLUDED = :excluded
141
+
142
+ # @!method self.values
143
+ # @return [Array<Symbol>]
144
+ end
145
+ end
146
+ end
147
+
148
+ BetaWebSearchTool20260318 = Beta::BetaWebSearchTool20260318
149
+ end
150
+ end