NAME

Langertha::Cost - Immutable value object for the monetary cost of a single LLM call

VERSION

version 0.503

input_usd

Cost of the input tokens. When the pricing rule had a cache rate, only the tokens that were neither read from nor written to the prompt cache; otherwise all of the usage's input_tokens. Default 0.

output_usd

Cost of the output tokens. Default 0.

cache_read_usd

Cost of the prompt-cache reads ("cached_tokens" in Langertha::Usage). 0 unless the pricing rule has a cache rate. Default 0.

cache_write_usd

Cost of the prompt-cache writes ("cache_write_tokens" in Langertha::Usage). 0 unless the pricing rule has a cache rate. Default 0.

total_usd

The sum of the four amounts above, unless passed to new.

currency

Default USD.

to_hash

{ input_cost_usd => ..., output_cost_usd => ..., cache_read_cost_usd => ...,
  cache_write_cost_usd => ..., total_cost_usd => ..., currency => 'USD' }

The canonical hash; TO_JSON returns the same.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.