Class: Anthropic::Models::Beta::BetaUsage

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

Defined Under Namespace

Modules: ServiceTier, Speed

Instance Attribute Summary collapse

Class Method 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

#initialize(cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, fallback_credit:, inference_geo:, input_tokens:, iterations:, output_tokens:, output_tokens_details:, server_tool_use:, service_tier:, speed:) ⇒ Object

Some parameter documentations has been truncated, see Anthropic::Models::Beta::BetaUsage for more details.

Parameters:



# File 'lib/anthropic/models/beta/beta_usage.rb', line 109

Instance Attribute Details

#cache_creationAnthropic::Models::Beta::BetaCacheCreation?

Breakdown of cached tokens by TTL

Parameters:

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

Returns:



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

required :cache_creation, -> { Anthropic::Beta::BetaCacheCreation }, nil?: true

#cache_creation_input_tokensInteger?

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

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


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

required :cache_creation_input_tokens, Integer, nil?: true

#cache_read_input_tokensInteger?

The number of input tokens read from the cache.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


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

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:



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

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

#inference_geoString?

The geographic region where inference was performed for this request.

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


35
# File 'lib/anthropic/models/beta/beta_usage.rb', line 35

required :inference_geo, String, nil?: true

#input_tokensInteger

The number of input tokens which were used.

Parameters:

  • value (Integer)

Returns:

  • (Integer)


41
# File 'lib/anthropic/models/beta/beta_usage.rb', line 41

required :input_tokens, Integer

#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.



68
69
70
# File 'lib/anthropic/models/beta/beta_usage.rb', line 68

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

#output_tokensInteger

The number of output tokens which were used.

Parameters:

  • value (Integer)

Returns:

  • (Integer)


76
# File 'lib/anthropic/models/beta/beta_usage.rb', line 76

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:



87
# File 'lib/anthropic/models/beta/beta_usage.rb', line 87

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:



93
# File 'lib/anthropic/models/beta/beta_usage.rb', line 93

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

#service_tierSymbol, ...

If the request used the priority, standard, or batch tier.

Parameters:

  • value (Anthropic::Models::Beta::BetaUsage::service_tier, nil)

Returns:



99
# File 'lib/anthropic/models/beta/beta_usage.rb', line 99

required :service_tier, enum: -> { Anthropic::Beta::BetaUsage::ServiceTier }, nil?: true

#speedSymbol, ...

Inference speed mode. fast provides significantly faster output token generation at premium pricing. Not all models support fast; invalid combinations are rejected at create time.

Parameters:

  • value (Anthropic::Models::Beta::BetaUsage::speed, nil)

Returns:



107
# File 'lib/anthropic/models/beta/beta_usage.rb', line 107

required :speed, enum: -> { Anthropic::Beta::BetaUsage::Speed }, nil?: true

Class Method Details

.valuesArray<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/anthropic/models/beta/beta_usage.rb', line 147

Instance Method Details

#to_hash{

Returns:

  • ({)


62
# File 'sig/anthropic/models/beta/beta_usage.rbs', line 62

def to_hash: -> {