CountTokensRequest class final

Counts the number of tokens in the prompt sent to a model.

Models may tokenize text differently, so each model may return a different token_count.

Constructors

CountTokensRequest({required String model, List<Content> contents = const [], GenerateContentRequest? generateContentRequest})
CountTokensRequest.fromJson(Object? j)
factory

Properties

contents → List<Content>
Optional. The input given to the model as a prompt. This field is ignored when generate_content_request is set.
final
generateContentRequest → GenerateContentRequest?
Optional. The overall input given to the Model. This includes the prompt as well as other model steering information like system instructions, and/or function declarations for function calling. Models/Contents and generate_content_requests are mutually exclusive. You can either send Model + Contents or a generate_content_request, but never both.
final
hashCode → int
The hash code for this object.
no setterinherited
model → String
Required. The model's resource name. This serves as an ID for the Model to use.
final
qualifiedName → String
The fully qualified name of this message, i.e., google.protobuf.Duration or google.rpc.ErrorInfo.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Object
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

fullyQualifiedName → const String