https://platform.openai.com/tokenizer
You can use OpenAI official tokenizer library to calculate the actual tokens used and calculate the price according to the price of various models for completion APIs.
For Assistants API, it seems not very clear so far how to calculate the actual costs, especially for run steps.