chatgpt-cli
chatgpt-cli copied to clipboard
Count tokens outside of `--interactive` mode
I am wanting to write a script that will track my total token usage though the chatgpt-cli client, and the total cost of me using the tool through my own API key. Is there any way to do this outside of the --interactive mode?
@stephen010x Not yet, but I can make that configurable. That's a fun idea.
Fixed it in this commit: https://github.com/kardolus/chatgpt-cli/commit/70c808d6a232d71039e4ea71f0d58071da8e2089
Here's a test I just ran:
2024-08-16 11:51:05 ⌚ (☸️ |kind:N/A) Guillermos-MacBook-Pro in ~/workspace/chatgpt-cli
± |main ↑1 {1} ✓| → OPENAI_TRACK_TOKEN_USAGE=true OPENAI_THREAD=new_thread ./bin/chatgpt --query test
I'm here to help! How can I assist you today?
[Token Usage: 31]