Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.
Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-20 UTC."],[],[],null,["# GenerativeModel class\n\nClass for generative model APIs.\n\n**Signature:** \n\n export declare class GenerativeModel extends AIModel \n\n**Extends:** [AIModel](./vertexai.aimodel.md#aimodel_class)\n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|------------------------------------------------------------------------------------------------------------|-----------|----------------------------------------------------------|\n| [(constructor)(ai, modelParams, requestOptions)](./vertexai.generativemodel.md#generativemodelconstructor) | | Constructs a new instance of the `GenerativeModel` class |\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|-------------------------------------------------------------------------------------|-----------|-------------------------------------------------------------------------------|-------------|\n| [generationConfig](./vertexai.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | |\n| [requestOptions](./vertexai.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | |\n| [safetySettings](./vertexai.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)\\[\\] | |\n| [systemInstruction](./vertexai.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai.content.md#content_interface) | |\n| [toolConfig](./vertexai.generativemodel.md#generativemodeltoolconfig) | | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | |\n| [tools](./vertexai.generativemodel.md#generativemodeltools) | | [Tool](./vertexai.md#tool)\\[\\] | |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|------------------------------------------------------------------------------------------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [countTokens(request)](./vertexai.generativemodel.md#generativemodelcounttokens) | | Counts the tokens in the provided request. |\n| [generateContent(request)](./vertexai.generativemodel.md#generativemodelgeneratecontent) | | Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). |\n| [generateContentStream(request)](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) | | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. |\n| [startChat(startChatParams)](./vertexai.generativemodel.md#generativemodelstartchat) | | Gets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. |\n\nGenerativeModel.(constructor)\n-----------------------------\n\nConstructs a new instance of the `GenerativeModel` class\n\n**Signature:** \n\n constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions);\n\n#### Parameters\n\n| Parameter | Type | Description |\n|----------------|-------------------------------------------------------------------------|-------------|\n| ai | [AI](./vertexai.ai.md#ai_interface) | |\n| modelParams | [ModelParams](./vertexai.modelparams.md#modelparams_interface) | |\n| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | |\n\nGenerativeModel.generationConfig\n--------------------------------\n\n**Signature:** \n\n generationConfig: GenerationConfig;\n\nGenerativeModel.requestOptions\n------------------------------\n\n**Signature:** \n\n requestOptions?: RequestOptions;\n\nGenerativeModel.safetySettings\n------------------------------\n\n**Signature:** \n\n safetySettings: SafetySetting[];\n\nGenerativeModel.systemInstruction\n---------------------------------\n\n**Signature:** \n\n systemInstruction?: Content;\n\nGenerativeModel.toolConfig\n--------------------------\n\n**Signature:** \n\n toolConfig?: ToolConfig;\n\nGenerativeModel.tools\n---------------------\n\n**Signature:** \n\n tools?: Tool[];\n\nGenerativeModel.countTokens()\n-----------------------------\n\nCounts the tokens in the provided request.\n\n**Signature:** \n\n countTokens(request: CountTokensRequest | string | Array\u003cstring | Part\u003e): Promise\u003cCountTokensResponse\u003e;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| request | [CountTokensRequest](./vertexai.counttokensrequest.md#counttokensrequest_interface) \\| string \\| Array\\\u003cstring \\| [Part](./vertexai.md#part)\\\u003e | |\n\n**Returns:**\n\nPromise\\\u003c[CountTokensResponse](./vertexai.counttokensresponse.md#counttokensresponse_interface)\\\u003e\n\nGenerativeModel.generateContent()\n---------------------------------\n\nMakes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface).\n\n**Signature:** \n\n generateContent(request: GenerateContentRequest | string | Array\u003cstring | Part\u003e): Promise\u003cGenerateContentResult\u003e;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \\| string \\| Array\\\u003cstring \\| [Part](./vertexai.md#part)\\\u003e | |\n\n**Returns:**\n\nPromise\\\u003c[GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface)\\\u003e\n\nGenerativeModel.generateContentStream()\n---------------------------------------\n\nMakes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.\n\n**Signature:** \n\n generateContentStream(request: GenerateContentRequest | string | Array\u003cstring | Part\u003e): Promise\u003cGenerateContentStreamResult\u003e;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \\| string \\| Array\\\u003cstring \\| [Part](./vertexai.md#part)\\\u003e | |\n\n**Returns:**\n\nPromise\\\u003c[GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface)\\\u003e\n\nGenerativeModel.startChat()\n---------------------------\n\nGets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats.\n\n**Signature:** \n\n startChat(startChatParams?: StartChatParams): ChatSession;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------------|----------------------------------------------------------------------------|-------------|\n| startChatParams | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) | |\n\n**Returns:**\n\n[ChatSession](./vertexai.chatsession.md#chatsession_class)"]]