LanguageModelUsage
Namespace: Vercel.AI.Provider
public sealed class LanguageModelUsageToken counts for a model call.
Inheritance: object
Constructors
Section titled “Constructors”LanguageModelUsage(int?, int?, int?, int?, int?, int?, JsonElement?, int?, int?)
Section titled “LanguageModelUsage(int?, int?, int?, int?, int?, int?, JsonElement?, int?, int?)”public LanguageModelUsage(int? inputTokens, int? outputTokens, int? totalTokens, int? cacheReadTokens = null, int? cacheWriteTokens = null, int? reasoningTokens = null, JsonElement? raw = null, int? noCacheInputTokens = null, int? textTokens = null)Creates usage counts.
Parameters
| Name | Type | Description |
|---|---|---|
inputTokens |
int? | |
outputTokens |
int? | |
totalTokens |
int? | |
cacheReadTokens |
int? | |
cacheWriteTokens |
int? | |
reasoningTokens |
int? | |
raw |
JsonElement? | |
noCacheInputTokens |
int? | |
textTokens |
int? |
Properties
Section titled “Properties”CacheReadTokens
Section titled “CacheReadTokens”public int? CacheReadTokens { get; }Input tokens read from cache, when the provider reports them.
Value: int?
CacheWriteTokens
Section titled “CacheWriteTokens”public int? CacheWriteTokens { get; }Input tokens written to cache, when the provider reports them.
Value: int?
public static LanguageModelUsage Empty { get; }Zero usage.
Value: LanguageModelUsage
InputTokens
Section titled “InputTokens”public int? InputTokens { get; }Prompt tokens.
Value: int?
NoCacheInputTokens
Section titled “NoCacheInputTokens”public int? NoCacheInputTokens { get; }Input tokens that were not served from cache, when the provider reports them.
Value: int?
public static LanguageModelUsage Null { get; }Usage with every count and Raw unset. It is the start value for adding steps.
Value: LanguageModelUsage
OutputTokens
Section titled “OutputTokens”public int? OutputTokens { get; }Generated tokens.
Value: int?
public JsonElement? Raw { get; }Provider usage object, unchanged.
Value: JsonElement?
ReasoningTokens
Section titled “ReasoningTokens”public int? ReasoningTokens { get; }Output tokens spent on reasoning, when the provider reports them.
Value: int?
TextTokens
Section titled “TextTokens”public int? TextTokens { get; }Output tokens that were not reasoning tokens, when the provider reports them.
Value: int?
TotalTokens
Section titled “TotalTokens”public int? TotalTokens { get; }Input plus output tokens.
Value: int?
Methods
Section titled “Methods”Add(LanguageModelUsage, LanguageModelUsage)
Section titled “Add(LanguageModelUsage, LanguageModelUsage)”public static LanguageModelUsage Add(LanguageModelUsage left, LanguageModelUsage right)Adds two usage values. Raw survives only when one side is Null.
Parameters
| Name | Type | Description |
|---|---|---|
left |
LanguageModelUsage | |
right |
LanguageModelUsage |
Returns: LanguageModelUsage
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product