Class OpenAiTokenCountEstimator

java.lang.Object
dev.langchain4j.model.openai.OpenAiTokenCountEstimator
All Implemented Interfaces:
TokenCountEstimator

public class OpenAiTokenCountEstimator extends Object implements TokenCountEstimator
This class can be used to estimate the cost (in tokens) before calling OpenAI. Magic numbers present in this class were found empirically while testing. There are integration tests in place that are making sure that the calculations here are very close to that of OpenAI.