countTextTokens method

  1. @override
Future<CountTextTokensResponse> countTextTokens(
  1. CountTextTokensRequest request
)
override

Runs a model's tokenizer on a text and returns the token count.

Throws a http.ClientException if there were problems communicating with the API service. Throws a ServiceException if the API method failed for any reason.

Implementation

@override
Future<CountTextTokensResponse> countTextTokens(
  CountTextTokensRequest request,
) async {
  if (isClosed) throw StateError('Service is closed');

  if (_countTextTokens case final countTextTokens?) {
    return countTextTokens(request);
  }
  throw UnsupportedError('countTextTokens');
}