public final class Usage

  1. Object
  2. Usage
Token accounting returned by the provider. Any field that the provider didn’t return is -1. Token counts reported for one provider operation. Providers may count tokens differently, so use these values for billing and diagnostics rather than comparing tokenizers across services.

Constructors

public Usage(int promptTokens, int completionTokens, int totalTokens)Creates a usage record from provider counters.

Methods

public int getPromptTokens()
public int getCompletionTokens()
public int getTotalTokens()

Inherited methods

Constructor details

Usage

public Usage(int promptTokens, int completionTokens, int totalTokens)
Creates a usage record from provider counters.

Parameters

promptTokens int
tokens consumed by request input
completionTokens int
tokens generated in the response
totalTokens int
provider-reported total token count

Method details

getPromptTokens

public int getPromptTokens()

Returns

tokens consumed by request input

getCompletionTokens

public int getCompletionTokens()

Returns

tokens generated in the response

getTotalTokens

public int getTotalTokens()

Returns

provider-reported total token count