Skip to content

OperationUsage

Namespace: Vercel.AI.Operations

public sealed class OperationUsage

Token counts for an image or evaluation call.

Inheritance: object

View source

public OperationUsage(int? inputTokens = null, int? outputTokens = null, int? totalTokens = null, double? tokens = null)

Creates usage. Unset counts stay null.

Parameters

Name Type Description
inputTokens int?
outputTokens int?
totalTokens int?
tokens double?

View source

public int? InputTokens { get; }

Prompt tokens.

Value: int?

View source

public int? OutputTokens { get; }

Generated tokens.

Value: int?

View source

public double? Tokens { get; }

Embedding token count. NaN when the provider omitted usage.

Value: double?

View source

public int? TotalTokens { get; }

Input plus output, when both are known.

Value: int?

View source

public static OperationUsage AddImage(OperationUsage left, OperationUsage right)

Adds two image usage values. A missing count stays missing until one side reports it.

Parameters

Name Type Description
left OperationUsage
right OperationUsage

Returns: OperationUsage

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product