public final CountTokensResponse countTokens(EndpointName endpoint, List<Value> instances) {
    CountTokensRequest request =
        CountTokensRequest.newBuilder()
            .setEndpoint(endpoint == null ? null : endpoint.toString())
            .addAllInstances(instances)
            .build();
    return countTokens(request);
  }
Perform a token counting.

<p>Sample code:

<pre>{@code
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
  EndpointName endpoint =
      EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
  List<Value> instances = new ArrayList<>();
  CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
}
}</pre>

@param endpoint Required. The name of the Endpoint requested to perform token counting. Format:
    `projects/{project}/locations/{location}/endpoints/{endpoint}`
@param instances Optional. The instances that are the input to token counting call. Schema is
    identical to the prediction schema of the underlying model.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceClient.java