Count the number of tokens a string uses for an LLM, using the same BPE encodings the major models use (o200k_base for GPT-4o/o1, cl100k_base for GPT-4/3.5 and embeddings). Optionally pass a USD price per million tokens to get an estimated cost. Lets an agent budget context and spend before a call.