A poor design in the chat completion API, which causes token waste when using function tools, has been identified in the following article: Fixing the OpenAI Tool Calling API. The same article describes a way to save your money.
Thanks to Gigi Sayfan, the author of the article, for mentioning simple-openai.