# Package @google-cloud/vertexai (1.10.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.10.0 (latest)](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/overview)
- [1.9.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.9.0/overview)
- [1.8.1](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.8.1/overview)
- [1.7.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.7.0/overview)
- [1.6.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.6.0/overview)
- [1.5.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.5.0/overview)
- [1.4.1](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.4.1/overview)
- [1.3.1](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.3.1/overview)
- [1.2.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.2.0/overview)
- [1.1.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.1.0/overview)
- [1.0.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/1.0.0/overview)
- [0.5.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/0.5.0/overview)
- [0.4.0](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/0.4.0/overview)
- [0.3.1](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/0.3.1/overview)
- [0.2.1](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/0.2.1/overview)

## Classes

### [ChatSession](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/chatsession)

The `ChatSession` class is used to make multiturn send message requests. You can instantiate this class by using the `startChat` method in the `GenerativeModel` class. The `sendMessage` method makes an async call to get the response of a chat message at at once. The `sendMessageStream` method makes an async call to stream the response of a chat message as it's being generated.

### [ChatSessionPreview](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/chatsessionpreview)

The `ChatSessionPreview` class is used to make multiturn send message requests. You can instantiate this class by using the `startChat` method in the `GenerativeModelPreview` class. The `sendMessage` method makes an async call to get the response of a chat message at at once. The `sendMessageStream` method makes an async call to stream the response of a chat message as it's being generated.

### [ClientError](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/clienterror)

ClientError is thrown when http 4XX status is received. For details please refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses

### [GenerateContentResponseHandler](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generatecontentresponsehandler)

Helper class to render any extra properties out of [GenerateContentResponse](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generatecontentresponse) or properties of [GenerateContentResponse](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generatecontentresponse)

### [GenerativeModel](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generativemodel)

The `GenerativeModel` class is the base class for the generative models on Vertex AI. NOTE: Don't instantiate this class directly. Use `vertexai.getGenerativeModel()` instead.

### [GenerativeModelPreview](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generativemodelpreview)

The `GenerativeModelPreview` class is the base class for the generative models that are in preview. NOTE: Don't instantiate this class directly. Use `vertexai.preview.getGenerativeModel()` instead.

### [GoogleApiError](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/googleapierror)

GoogleApiError is thrown when http 4XX status is received. See <https://cloud.google.com/apis/design/errors>

### [GoogleAuthError](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/googleautherror)

GoogleAuthError is thrown when there is authentication issue with the request

### [GoogleGenerativeAIError](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/googlegenerativeaierror)

GoogleGenerativeAIError is thrown when http response is not ok and status code is not 4XX For details please refer to <https://developer.mozilla.org/en-US/docs/Web/HTTP/Status>

### [IllegalArgumentError](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/illegalargumenterror)

IllegalArgumentError is thrown when the request or operation is invalid

### [VertexAI](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/vertexai)

The `VertexAI` class is the base class for authenticating to Vertex AI. To use Vertex AI's generative AI models, use the `getGenerativeModel` method. To use generative AI features that are in Preview, use the `preview` namespace.

## Interfaces

### [BaseModelParams](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/basemodelparams)

Base params for initializing a model or calling GenerateContent.

### [BasePart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/basepart)

A part of a turn in a conversation with the model with a fixed MIME type. It has one of the following mutually exclusive fields: 1. text 2. inlineData 3. fileData 4. functionResponse 5. functionCall

### [CachedContent](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/cachedcontent)

A resource used in LLM queries for users to explicitly specify what to cache and how to cache.

### [CachedContentUsageMetadata](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/cachedcontentusagemetadata)

Metadata on the usage of the cached content.

### [Citation](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/citation)

Source attributions for content.

### [CitationMetadata](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/citationmetadata)

A collection of source attributions for a piece of content.

### [Content](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/content)

The base structured datatype containing multi-part content of a message.

### [CountTokensRequest](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/counttokensrequest)

Params used to call the countTokens method.

### [CountTokensResponse](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/counttokensresponse)

Response returned from countTokens method.

### [DynamicRetrievalConfig](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/dynamicretrievalconfig)

Describes the options to customize dynamic retrieval.

### [ErrorDetails](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/errordetails)

Google API Error Details object that may be included in an error response. See <https://cloud.google.com/apis/design/errors>

### [FileData](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/filedata)

URI based data.

### [FileDataPart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/filedatapart)

A file data part of a conversation with the model.

### [FunctionCall](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functioncall)

A predicted FunctionCall returned from the model that contains a string representating the FunctionDeclaration.name with the parameters and their values.

### [FunctionCallingConfig](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functioncallingconfig)

### [FunctionCallPart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functioncallpart)

A function call part of a conversation with the model.

### [FunctionDeclaration](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functiondeclaration)

Structured representation of a function declaration as defined by the \[OpenAPI 3.0 specification\](<https://spec.openapis.org/oas/v3.0.3>). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client.

### [FunctionDeclarationSchema](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functiondeclarationschema)

Schema for parameters passed to [FunctionDeclaration.parameters](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functiondeclaration).

### [FunctionDeclarationsTool](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functiondeclarationstool)

A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.

### [FunctionResponse](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functionresponse)

The result output of a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function call. It is used as context to the model.

### [FunctionResponsePart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functionresponsepart)

A function response part of a conversation with the model.

### [GenerateContentCandidate](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generatecontentcandidate)

A response candidate generated from the model.

### [GenerateContentRequest](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generatecontentrequest)

Params used to call the generateContent method.

### [GenerateContentResponse](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generatecontentresponse)

Response from the model supporting multiple candidates.

### [GenerateContentResult](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generatecontentresult)

Wrapper for respones from a generateContent request.

### [GenerationConfig](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generationconfig)

Configuration options for model generation and outputs.

### [GenerativeContentBlob](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/generativecontentblob)

Raw media bytes sent directly in the request. Text should not be sent as raw bytes.

### [GetGenerativeModelParams](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/getgenerativemodelparams)

Params used to call the getGenerativeModel method.

### [GoogleDate](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/googledate)

Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following:

A full date, with non-zero year, month, and day values. A month and day, with a zero year (for example, an anniversary). A year on its own, with a zero month and a zero day. A year and month, with a zero day (for example, a credit card expiration date).

### [GoogleSearchRetrieval](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/googlesearchretrieval)

Tool to retrieve public web data for grounding, powered by Google.

### [GoogleSearchRetrievalTool](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/googlesearchretrievaltool)

Defines a retrieval tool that model can call to access external knowledge.

### [GroundingAttributionRetrievedContext](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingattributionretrievedcontext)

### [GroundingAttributionSegment](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingattributionsegment)

### [GroundingAttributionWeb](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingattributionweb)

### [GroundingChunk](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingchunk)

Grounding chunk.

### [GroundingChunkRetrievedContext](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingchunkretrievedcontext)

Grounding chunk from context retrieved by the retrieval tools.

### [GroundingChunkWeb](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingchunkweb)

Grounding chunk from the web.

### [GroundingMetadata](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingmetadata)

A collection of grounding attributions for a piece of content.

### [GroundingSupport](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingsupport)

Grounding support.

### [GroundingSupportSegment](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/groundingsupportsegment)

Grounding support segment.

### [InlineDataPart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/inlinedatapart)

An inline data part of a conversation with the model.

### [ListCachedContentsResponse](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/listcachedcontentsresponse)

Response with a list of CachedContents.

### [ModelParams](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/modelparams)

Configuration for initializing a model, for example via getGenerativeModel in VertexAI class.

### [PromptFeedback](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/promptfeedback)

Content filter results for a prompt sent in the request.

### [RagResource](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/ragresource)

Config of Vertex RagStore grounding checking.

### [RequestOptions](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/requestoptions)

Request options params passed to getGenerativeModel method in VertexAI class.

### [ResponseSchema](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/responseschema)

Schema passed to `GenerationConfig.responseSchema`

### [Retrieval](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/retrieval)

Defines a retrieval tool that model can call to access external knowledge.

### [RetrievalTool](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/retrievaltool)

Defines a retrieval tool that model can call to access external knowledge.

### [SafetyRating](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/safetyrating)

Safety rating corresponding to the generated content.

### [SafetySetting](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/safetysetting)

Safety feedback for an entire request.

### [Schema](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/schema)

Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed.

### [SearchEntryPoint](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/searchentrypoint)

Google search entry point.

### [StartChatParams](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/startchatparams)

Params to initiate a multiturn chat with the model via startChat.

### [StartChatSessionRequest](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/startchatsessionrequest)

All params passed to initiate multiturn chat via startChat.

### [StreamGenerateContentResult](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/streamgeneratecontentresult)

Wrapper for respones from a generateContentStream method.

### [TextPart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/textpart)

A text part of a conversation with the model.

### [ToolConfig](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/toolconfig)

This config is shared for all tools provided in the request.

### [UsageMetadata](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/usagemetadata)

Usage metadata about response(s).

### [VertexAISearch](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/vertexaisearch)

Retrieve from Vertex AI Search datastore for grounding.

### [VertexInit](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/vertexinit)

Params used to initialize the Vertex SDK.

### [VertexRagStore](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/vertexragstore)

## Enums

### [BlockedReason](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/blockedreason)

The reason why the reponse is blocked.

### [FinishReason](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/finishreason)

The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.

### [FunctionCallingMode](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functioncallingmode)

Function calling mode.

### [HarmBlockThreshold](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/harmblockthreshold)

Probability based thresholds levels for blocking.

### [HarmCategory](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/harmcategory)

Harm categories that will block the content.

### [HarmProbability](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/harmprobability)

Harm probability levels in the content.

### [HarmSeverity](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/harmseverity)

Harm severity levels

### [Mode](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/mode)

### [SchemaType](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/schematype)

The list of OpenAPI data types as defined by <https://swagger.io/docs/specification/data-models/data-types/>

## Variables

### FunctionDeclarationSchemaType

    FunctionDeclarationSchemaType: {
        STRING: SchemaType.STRING;
        NUMBER: SchemaType.NUMBER;
        INTEGER: SchemaType.INTEGER;
        BOOLEAN: SchemaType.BOOLEAN;
        ARRAY: SchemaType.ARRAY;
        OBJECT: SchemaType.OBJECT;
    }

## Type Aliases

### FunctionDeclarationSchemaProperty

    export type FunctionDeclarationSchemaProperty = Schema;

FunctionDeclarationSchemaProperty is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed.

### FunctionDeclarationSchemaType

    export declare type FunctionDeclarationSchemaType = SchemaType;

Contains the list of OpenAPI data types as defined by <https://swagger.io/docs/specification/data-models/data-types/>

### Part

    export declare type Part = TextPart | InlineDataPart | FileDataPart | FunctionResponsePart | FunctionCallPart;

A datatype containing media that is part of a multi-part [Content](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/content) message. A `Part` is a union type of [TextPart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/textpart), [InlineDataPart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/inlinedatapart), [FileDataPart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/filedatapart), and [FunctionResponsePart](https://docs.cloud.google.com/nodejs/docs/reference/vertexai/latest/vertexai/functionresponsepart). A `Part` has one of the following mutually exclusive fields: 1. text 2. inlineData 3. fileData 4. functionResponse

### Tool

    export declare type Tool = FunctionDeclarationsTool | RetrievalTool | GoogleSearchRetrievalTool;

Defines a tool that model can call to access external knowledge.