# Class Usage

java.lang.Object
com.codename1.ai.Usage

public final class Usage extends Object
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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Usage(int promptTokens, int completionTokens, int totalTokens)`
  Creates a usage record from provider counters.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCompletionTokens()`
  `int`
  `getPromptTokens()`
  `int`
  `getTotalTokens()`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Usage

    public Usage(int promptTokens, int completionTokens, int totalTokens)
    Creates a usage record from provider counters.
    Parameters:
      `promptTokens` - tokens consumed by request input
      `completionTokens` - tokens generated in the response
      `totalTokens` - 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