Class: Anthropic::Models::Beta::BetaMessageDeltaUsage

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/anthropic/models/beta/beta_message_delta_usage.rb,
sig/anthropic/models/beta/beta_message_delta_usage.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initializeObject



35
# File 'sig/anthropic/models/beta/beta_message_delta_usage.rbs', line 35

def initialize: (

Instance Attribute Details

#cache_creation_input_tokensInteger?

The cumulative number of input tokens used to create the cache entry.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


11
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 11

required :cache_creation_input_tokens, Integer, nil?: true

#cache_read_input_tokensInteger?

The cumulative number of input tokens read from the cache.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


17
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 17

required :cache_read_input_tokens, Integer, nil?: true

#fallback_creditAnthropic::Models::Beta::BetaFallbackCreditUsage?

Outcome of the fallback_credit_token presented on this request.

Parameters:

  • value (Anthropic::Beta::BetaFallbackCreditUsage, nil)

Returns:



23
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 23

required :fallback_credit, -> { Anthropic::Beta::BetaFallbackCreditUsage }, nil?: true

#input_tokensInteger?

The cumulative number of input tokens which were used.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


29
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 29

required :input_tokens, Integer, nil?: true

#iterationsArray<Anthropic::Models::Beta::BetaMessageIterationUsage, Anthropic::Models::Beta::BetaCompactionIterationUsage, Anthropic::Models::Beta::BetaAdvisorMessageIterationUsage, Anthropic::Models::Beta::BetaFallbackMessageIterationUsage>?

Per-iteration token usage breakdown.

Each entry represents one sampling iteration, with its own input/output token counts and cache statistics, discriminated by type. For message entries (model sampling iterations, such as the turns of a server-side tool use loop), this allows you to:

  • Determine which iterations exceeded long context thresholds (>=200k tokens)
  • Calculate the context window size from the last message entry
  • Understand token accumulation across server-side tool use loops

A compaction entry reports the token usage of the compaction operation itself — the server-side request that summarizes the context being closed — NOT the size of the context that was compacted away, and its token counts can be much smaller than that closed context (for example, a compaction that closes a ~200k-token context can report only a few thousand tokens). Do not derive the context window size from a compaction entry, even when it is the last entry. A compaction entry's tokens are not included in the top-level usage fields. When an input-token trigger is in effect (the default — 150,000 tokens unless configured otherwise), each compaction entry closes a context that had reached at least that threshold, though the context can exceed it by the final iteration's output and tool results.



56
57
58
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 56

required :iterations,
-> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaIterationsUsageItem] },
nil?: true

#output_tokensInteger

The cumulative number of output tokens which were used.

Parameters:

  • value (Integer)

Returns:

  • (Integer)


64
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 64

required :output_tokens, Integer

#output_tokens_detailsAnthropic::Models::Beta::BetaOutputTokensDetails?

Breakdown of output tokens by category.

output_tokens remains the inclusive, authoritative total used for billing. This object provides a read-only decomposition for observability — for example, how many of the billed output tokens were spent on internal reasoning that may have been summarized before being returned to you.

Parameters:

  • value (Anthropic::Beta::BetaOutputTokensDetails, nil)

Returns:



75
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 75

required :output_tokens_details, -> { Anthropic::Beta::BetaOutputTokensDetails }, nil?: true

#server_tool_useAnthropic::Models::Beta::BetaServerToolUsage?

The number of server tool requests.

Parameters:

  • value (Anthropic::Beta::BetaServerToolUsage, nil)

Returns:



81
# File 'lib/anthropic/models/beta/beta_message_delta_usage.rb', line 81

required :server_tool_use, -> { Anthropic::Beta::BetaServerToolUsage }, nil?: true

Instance Method Details

#to_hash{

Returns:

  • ({)


46
# File 'sig/anthropic/models/beta/beta_message_delta_usage.rbs', line 46

def to_hash: -> {