foundry_usage: Summarise token usage for foundryR results

View source: R/batches.R

foundry_usageR Documentation

Summarise token usage for foundryR results

Description

Sum token columns returned by foundryR chat, Responses, extraction, and batch helpers. Pass your own rates to compute spend; foundryR does not hardcode Azure prices because they change over time.

Usage

foundry_usage(x, rates = NULL)

Arguments

x

Data frame with foundryR token columns.

rates

Optional named numeric vector with any of input, cached_input, and output rates per token.

Value

A one-row tibble with token totals and optional cost.

Examples

responses <- data.frame(
  input_tokens = c(10, 20),
  cached_input_tokens = c(0, 5),
  output_tokens = c(3, 7)
)
foundry_usage(responses)
foundry_usage(
  responses,
  rates = c(input = 0.000001, cached_input = 0.0000001, output = 0.000004)
)

foundryR documentation built on Sept. 25, 2026, 1:10 a.m.