Constructor
new VertexAI(init)
Parameters:
Name | Type | Description |
---|---|---|
init |
assign authentication related information, including the project and location strings, to instantiate a Vertex AI client. |
Throws:
Methods
getGenerativeModel(modelParams, requestOptions)
Gets the GenerativeModel class instance.
This method creates a new instance of the GenerativeModel
class with the
platform initialization parameters provided in VertexInit and model
initialization parameters provided in ModelParams. You can
optionally provide RequestOptions to override the default request
options.
Parameters:
Name | Type | Description |
---|---|---|
modelParams |
ModelParams Parameters to specify the generative model. |
|
requestOptions |
RequestOptions Parameters to specify request options |
Returns:
Type | Description |
---|---|
Instance of the GenerativeModel class. |
Example
```
const project = 'your-cloud-project';
const location = 'us-central1';
const textModel = 'gemini-1.0-pro';
const visionModel = 'gemini-1.0-pro-vision';
const vertexAI = new VertexAI({project: project, location: location});
// Instantiate models
const generativeModel = vertexAI.getGenerativeModel({
model: textModel,
// The following parameters are optional
// They can also be passed to individual content generation requests
safetySettings: [{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE
}],
generationConfig: {maxOutputTokens: 256},
});
const generativeVisionModel = vertexAI.getGenerativeModel({
model: visionModel,
});
const generativeModelPreview = vertexAI.preview.getGenerativeModel({
model: textModel,
});
```