[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/php-ai-client/src/Results/DTO/ -> TokenUsage.php (summary)

(no description)

File Size: 144 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

TokenUsage:: (8 methods):
  __construct()
  getPromptTokens()
  getCompletionTokens()
  getTotalTokens()
  getThoughtTokens()
  getJsonSchema()
  toArray()
  fromArray()


Class: TokenUsage  - X-Ref

Represents token usage statistics for an AI operation.

This DTO tracks the number of tokens used in prompts and completions,
which is important for monitoring usage and costs.

Note that thought tokens are a subset of completion tokens, not additive.
In other words: completionTokens - thoughtTokens = tokens of actual output content.

__construct(int $promptTokens, int $completionTokens, int $totalTokens, ?int $thoughtTokens = null)   X-Ref
Constructor.

param: int $promptTokens Number of tokens in the prompt.
param: int $completionTokens Number of tokens in the completion, including any thought tokens.
param: int $totalTokens Total number of tokens used.
param: int|null $thoughtTokens Number of tokens used for thinking, as a subset of completion tokens.

getPromptTokens()   X-Ref
Gets the number of prompt tokens.

return: int The prompt token count.

getCompletionTokens()   X-Ref
Gets the number of completion tokens, including any thought tokens.

return: int The completion token count.

getTotalTokens()   X-Ref
Gets the total number of tokens.

return: int The total token count.

getThoughtTokens()   X-Ref
Gets the number of thought tokens, which is a subset of the completion token count.

return: int|null The thought token count or null if not available.

getJsonSchema()   X-Ref
{@inheritDoc}


toArray()   X-Ref
{@inheritDoc}

return: TokenUsageArrayShape

fromArray(array $array)   X-Ref
{@inheritDoc}




Generated : Sat Jun 13 09:38:55 2026 Cross-referenced by PHPXref