Skip to contents

session_cost() adds up the tokens and estimated cost of the model calls in the prompt history (see inspect_history()), overall and per model.

Usage

session_cost()

Value

A list of class dsprrr_session_cost with n_calls, tokens_in, tokens_out, total_tokens, cost (in US dollars; NA if any call's cost is unknown) and by_model, a tibble with the same totals per model.

Details

The prompt history keeps the most recent 100 calls by default (options(dsprrr.prompt_history_max = )), so older calls drop out of the totals, and clear_prompt_history() resets them. Only calls recorded in the history count: see inspect_history() for which ones are. Costs are ellmer's estimates.

Examples

session_cost()
#> 
#> ── dsprrr Session Cost 
#> No LLM calls recorded in this session
session_cost()$total_tokens
#> [1] 0