Skip to content

AnthropicUsage

Namespace: Vercel.AI.Anthropic

public static class AnthropicUsage

Converts an Anthropic usage object into SDK token counts.

Inheritance: object

View source

public static LanguageModelUsage Convert(JsonElement usage, JsonElement? rawUsage = null)

Maps Anthropic usage. Cache creation and cache reads are added to the input total. Compaction and message iterations are summed when present. Advisor iterations are left out because they bill at a different rate. A fallback_message iteration keeps the top-level totals.

Parameters

Name Type Description
usage JsonElement
rawUsage JsonElement?

Returns: LanguageModelUsage

View source

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