anthropic 1.42.0 → 1.43.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5babf593055aa56b8e86a7cbf3b2485d7b6e0a73d6c44a89ecf3bfa467c7863a
4
- data.tar.gz: 0a1f49bd358d4bd27ea403115b22da8180af21afbacac24489801074f6815db5
3
+ metadata.gz: 4142618ad3822029520091b516413cf32261636cfeff2ea03f1d33e6342cee42
4
+ data.tar.gz: 86a9ff08d3ee65673f329261c436c7163b471aa0eebb33bb8d36a983bd959f82
5
5
  SHA512:
6
- metadata.gz: 99b5b9414478942809c6b2a5b26441f236e2322fdca0d310b794ebdd0fec20dcea666330514bb5ec1bf580549a60909890eb09e890f054308ecb2a9b0cdcb028
7
- data.tar.gz: 720e57337738ec199b4f6eaddd64584d368db6961ffcf91256a598d2ae2638e06ec5dd126b51d46d065b5abd2e25d45f4dcd1c41c098e98c2d84e76205766578
6
+ metadata.gz: eeba6340d54d9d463d49723772cbb43b142b2835356d7719c53c41b56f73cf63d1784d71ee07337b1b43522609492ef5810ed0e48712b5f4649079d939fdd19b
7
+ data.tar.gz: 2a3bdb6b07367dbbf419d43b867920b7996544f7b7786eb4366913c5654c044ffb79d1e2a40dcd3a7cd69a37fbaea3bcb78aa2f74f701569b14633cc49470ae0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.43.0 (2026-05-21)
4
+
5
+ Full Changelog: [v1.42.0...v1.43.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.42.0...v1.43.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** Add support for thinking-token-count beta for estimated tokens in thinking block deltas when streaming ([9cd8a67](https://github.com/anthropics/anthropic-sdk-ruby/commit/9cd8a67e5a4382a72c2e417de9be587be9237353))
10
+
3
11
  ## 1.42.0 (2026-05-19)
4
12
 
5
13
  Full Changelog: [v1.41.0...v1.42.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.41.0...v1.42.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.42.0"
18
+ gem "anthropic", "~> 1.43.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -57,6 +57,8 @@ module Anthropic
57
57
 
58
58
  variant const: -> { Anthropic::Models::AnthropicBeta::CACHE_DIAGNOSIS_2026_04_07 }
59
59
 
60
+ variant const: -> { Anthropic::Models::AnthropicBeta::THINKING_TOKEN_COUNT_2026_05_13 }
61
+
60
62
  # @!method self.variants
61
63
  # @return [Array(String, Symbol)]
62
64
 
@@ -91,6 +93,7 @@ module Anthropic
91
93
  ADVISOR_TOOL_2026_03_01 = :"advisor-tool-2026-03-01"
92
94
  MANAGED_AGENTS_2026_04_01 = :"managed-agents-2026-04-01"
93
95
  CACHE_DIAGNOSIS_2026_04_07 = :"cache-diagnosis-2026-04-07"
96
+ THINKING_TOKEN_COUNT_2026_05_13 = :"thinking-token-count-2026-05-13"
94
97
 
95
98
  # @!endgroup
96
99
  end
@@ -4,6 +4,19 @@ module Anthropic
4
4
  module Models
5
5
  module Beta
6
6
  class BetaThinkingDelta < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute estimated_tokens
8
+ # Per-frame increment of a coarse, running estimate of the tokens this thinking
9
+ # block has produced so far. Present whenever the
10
+ # `thinking-token-count-2026-05-13` beta is set; `null` unless `thinking.display`
11
+ # resolves to `"omitted"` and a count is due this frame. Sum the increments across
12
+ # `thinking_delta` frames on this block for a progress indicator. Each increment
13
+ # is a non-negative multiple of a fixed quantum and the cadence is rate-limited,
14
+ # so this is a deliberately lossy display hint, not a billable count;
15
+ # `usage.output_tokens` remains authoritative.
16
+ #
17
+ # @return [Integer, nil]
18
+ required :estimated_tokens, Integer, nil?: true
19
+
7
20
  # @!attribute thinking
8
21
  #
9
22
  # @return [String]
@@ -14,8 +27,14 @@ module Anthropic
14
27
  # @return [Symbol, :thinking_delta]
15
28
  required :type, const: :thinking_delta
16
29
 
17
- # @!method initialize(thinking:, type: :thinking_delta)
30
+ # @!method initialize(estimated_tokens:, thinking:, type: :thinking_delta)
31
+ # Some parameter documentations has been truncated, see
32
+ # {Anthropic::Models::Beta::BetaThinkingDelta} for more details.
33
+ #
34
+ # @param estimated_tokens [Integer, nil] Per-frame increment of a coarse, running estimate of the tokens this thinking bl
35
+ #
18
36
  # @param thinking [String]
37
+ #
19
38
  # @param type [Symbol, :thinking_delta]
20
39
  end
21
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anthropic
4
- VERSION = "1.42.0"
4
+ VERSION = "1.43.0"
5
5
  end
@@ -113,6 +113,11 @@ module Anthropic
113
113
  :"cache-diagnosis-2026-04-07",
114
114
  Anthropic::AnthropicBeta::TaggedSymbol
115
115
  )
116
+ THINKING_TOKEN_COUNT_2026_05_13 =
117
+ T.let(
118
+ :"thinking-token-count-2026-05-13",
119
+ Anthropic::AnthropicBeta::TaggedSymbol
120
+ )
116
121
  end
117
122
  end
118
123
  end
@@ -14,17 +14,54 @@ module Anthropic
14
14
  )
15
15
  end
16
16
 
17
+ # Per-frame increment of a coarse, running estimate of the tokens this thinking
18
+ # block has produced so far. Present whenever the
19
+ # `thinking-token-count-2026-05-13` beta is set; `null` unless `thinking.display`
20
+ # resolves to `"omitted"` and a count is due this frame. Sum the increments across
21
+ # `thinking_delta` frames on this block for a progress indicator. Each increment
22
+ # is a non-negative multiple of a fixed quantum and the cadence is rate-limited,
23
+ # so this is a deliberately lossy display hint, not a billable count;
24
+ # `usage.output_tokens` remains authoritative.
25
+ sig { returns(T.nilable(Integer)) }
26
+ attr_accessor :estimated_tokens
27
+
17
28
  sig { returns(String) }
18
29
  attr_accessor :thinking
19
30
 
20
31
  sig { returns(Symbol) }
21
32
  attr_accessor :type
22
33
 
23
- sig { params(thinking: String, type: Symbol).returns(T.attached_class) }
24
- def self.new(thinking:, type: :thinking_delta)
34
+ sig do
35
+ params(
36
+ estimated_tokens: T.nilable(Integer),
37
+ thinking: String,
38
+ type: Symbol
39
+ ).returns(T.attached_class)
40
+ end
41
+ def self.new(
42
+ # Per-frame increment of a coarse, running estimate of the tokens this thinking
43
+ # block has produced so far. Present whenever the
44
+ # `thinking-token-count-2026-05-13` beta is set; `null` unless `thinking.display`
45
+ # resolves to `"omitted"` and a count is due this frame. Sum the increments across
46
+ # `thinking_delta` frames on this block for a progress indicator. Each increment
47
+ # is a non-negative multiple of a fixed quantum and the cadence is rate-limited,
48
+ # so this is a deliberately lossy display hint, not a billable count;
49
+ # `usage.output_tokens` remains authoritative.
50
+ estimated_tokens:,
51
+ thinking:,
52
+ type: :thinking_delta
53
+ )
25
54
  end
26
55
 
27
- sig { override.returns({ thinking: String, type: Symbol }) }
56
+ sig do
57
+ override.returns(
58
+ {
59
+ estimated_tokens: T.nilable(Integer),
60
+ thinking: String,
61
+ type: Symbol
62
+ }
63
+ )
64
+ end
28
65
  def to_hash
29
66
  end
30
67
  end
@@ -27,6 +27,7 @@ module Anthropic
27
27
  | :"advisor-tool-2026-03-01"
28
28
  | :"managed-agents-2026-04-01"
29
29
  | :"cache-diagnosis-2026-04-07"
30
+ | :"thinking-token-count-2026-05-13"
30
31
 
31
32
  module AnthropicBeta
32
33
  extend Anthropic::Internal::Type::Union
@@ -58,6 +59,7 @@ module Anthropic
58
59
  ADVISOR_TOOL_2026_03_01: :"advisor-tool-2026-03-01"
59
60
  MANAGED_AGENTS_2026_04_01: :"managed-agents-2026-04-01"
60
61
  CACHE_DIAGNOSIS_2026_04_07: :"cache-diagnosis-2026-04-07"
62
+ THINKING_TOKEN_COUNT_2026_05_13: :"thinking-token-count-2026-05-13"
61
63
  end
62
64
  end
63
65
  end
@@ -3,16 +3,27 @@ module Anthropic
3
3
  class BetaThinkingDelta = Beta::BetaThinkingDelta
4
4
 
5
5
  module Beta
6
- type beta_thinking_delta = { thinking: String, type: :thinking_delta }
6
+ type beta_thinking_delta =
7
+ { estimated_tokens: Integer?, thinking: String, type: :thinking_delta }
7
8
 
8
9
  class BetaThinkingDelta < Anthropic::Internal::Type::BaseModel
10
+ attr_accessor estimated_tokens: Integer?
11
+
9
12
  attr_accessor thinking: String
10
13
 
11
14
  attr_accessor type: :thinking_delta
12
15
 
13
- def initialize: (thinking: String, ?type: :thinking_delta) -> void
16
+ def initialize: (
17
+ estimated_tokens: Integer?,
18
+ thinking: String,
19
+ ?type: :thinking_delta
20
+ ) -> void
14
21
 
15
- def to_hash: -> { thinking: String, type: :thinking_delta }
22
+ def to_hash: -> {
23
+ estimated_tokens: Integer?,
24
+ thinking: String,
25
+ type: :thinking_delta
26
+ }
16
27
  end
17
28
  end
18
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anthropic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.42.0
4
+ version: 1.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthropic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-19 00:00:00.000000000 Z
11
+ date: 2026-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cgi