If you want to count tokens used for prompts and responses you can use the OpenAI GitHub - openai/tiktoken: tiktoken is a fast BPE tokeniser for use with OpenAI's models. to count them, examples in the read . me and also in the OpenAI API docs.
1 Like