llm icon indicating copy to clipboard operation
llm copied to clipboard

Add -u usage flag to `llm chat`

Open brilee opened this issue 1 year ago • 1 comments

I really enjoy tossing in -u to my normal LLM prompts to get a good gut sense of cost. But llm chat doesn't support the -u flag. I think the conversation cost should be roughly quadratic in length since each conversation turn requires sending the entire conversation history as input tokens, but it would be cool to have a -u flag actally confirm it.

Implementation could be either a turn-by-turn usage cost or one final tally at the end of the chat.

brilee avatar May 07 '25 10:05 brilee

I would like to work on this. Current main still has no -u/--usage option on llm chat, while llm prompt already formats usage for each response in a tool chain.

I plan to reuse that output format to report token usage to stderr after each chat turn (including each underlying model response when tools are used), leaving the default output unchanged. I will add mock-model tests for multiple turns and both streaming modes, plus update the chat documentation and generated help. This reports provider-supplied token counts, not a dollar-cost estimate.

AI assistance is being used for the implementation and tests.

bianyh avatar Oct 11 '26 13:10 bianyh