Skip to content

Calculate cumulative token usage and cost across all Aider sessions #259

@stephane-klein

Description

@stephane-klein

Hello,

I searched for a solution to calculate the total cost spent on a whole project created with Aider (not just one session), from the content of the .aider.chat.history.md file present in a project.
I searched in the documentation and in the issues of the Aider repository without finding anything.

Question: Does this feature exist? Did I search badly?

In the meantime, I implemented with Sonnet 4.5 the following script: aider_cost_analyzer.py, which may be useful to some of you.

Installation on Fedora:

$ mkdir -p ~/.local/bin
$ curl -o ~/.local/bin/aider_cost_analyzer.py https://gist.githubusercontent.com/stephane-klein/3b3808c1b03b7e6ddfc4b22b69fdf776/raw/4262faec0cb2f468ea6b6d8751339b8e8497f005/aider_cost_analyzer.py
$ chmod +x ~/.local/bin/aider_cost_analyzer.py

Example of use:

$ aider_cost_analyzer.py .
Analyzing 1 history file(s) in '.':

.aider.chat.history.md:
  Messages: 30
  Tokens sent: 639,200 | received: 65,613
  Cost: $1.86

============================================================
Total tokens sent: 639,200
Total tokens received: 65,613
Total cost: $1.86

Question: Do you think this feature could be added directly in aider?
If yes, I will maybe try to suggest a pull request.

Best regards,
Stéphane

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions