Discussions

Ask a Question
Back to All

Checking Input Token Size Before API Call

I want to verify whether my input token size exceeds the model’s limit. Is there a built-in function to calculate token length without making an API call and incurring costs? If using tiktoken is the only option, which encoding should I use?