CountTokensRequest interface
Stay organized with collections
Save and categorize content based on your preferences.
Params for calling GenerativeModel.countTokens()
Signature:
export interface CountTokensRequest
Properties
CountTokensRequest.contents
Signature:
contents: Content[];
CountTokensRequest.generationConfig
Configuration options that control how the model generates a response.
Signature:
generationConfig?: GenerationConfig;
CountTokensRequest.systemInstruction
Instructions that direct the model to behave a certain way.
Signature:
systemInstruction?: string | Part | Content;
Tool configuration.
Signature:
tools?: Tool[];
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-20 UTC.
[null,null,["Last updated 2025-05-20 UTC."],[],[],null,["# CountTokensRequest interface\n\nParams for calling [GenerativeModel.countTokens()](./ai.generativemodel.md#generativemodelcounttokens)\n\n**Signature:** \n\n export interface CountTokensRequest \n\nProperties\n----------\n\n| Property | Type | Description |\n|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|------------------------------------------------------------------------|\n| [contents](./ai.counttokensrequest.md#counttokensrequestcontents) | [Content](./ai.content.md#content_interface)\\[\\] | |\n| [generationConfig](./ai.counttokensrequest.md#counttokensrequestgenerationconfig) | [GenerationConfig](./ai.generationconfig.md#generationconfig_interface) | Configuration options that control how the model generates a response. |\n| [systemInstruction](./ai.counttokensrequest.md#counttokensrequestsysteminstruction) | string \\| [Part](./ai.md#part) \\| [Content](./ai.content.md#content_interface) | Instructions that direct the model to behave a certain way. |\n| [tools](./ai.counttokensrequest.md#counttokensrequesttools) | [Tool](./ai.md#tool)\\[\\] | [Tool](./ai.md#tool) configuration. |\n\nCountTokensRequest.contents\n---------------------------\n\n**Signature:** \n\n contents: Content[];\n\nCountTokensRequest.generationConfig\n-----------------------------------\n\nConfiguration options that control how the model generates a response.\n\n**Signature:** \n\n generationConfig?: GenerationConfig;\n\nCountTokensRequest.systemInstruction\n------------------------------------\n\nInstructions that direct the model to behave a certain way.\n\n**Signature:** \n\n systemInstruction?: string | Part | Content;\n\nCountTokensRequest.tools\n------------------------\n\n[Tool](./ai.md#tool) configuration.\n\n**Signature:** \n\n tools?: Tool[];"]]