count_token

count_token(input: str | list[str] | dict[str, Any], model: str = 'gpt-3.5-turbo-0613') -> int

Count number of tokens used by an OpenAI model.

Parameters:
NameDescription
input(str, list, dict): Input to the model.

Type: str | list[str] | dict[str, typing.Any]
model(str): Model name.

Type: str

Default: ‘gpt-3.5-turbo-0613’
Returns:
TypeDescription
intint: Number of tokens from the input.