It's about how you pass the endpoint to VertexAI node.js API. We need to provide it to the model parameter like this: projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID

It's because how VertexAI node.js API deals with provided parameters. In post_request.js, this is how the final endpoint is generated: let vertexEndpoint = https://${vertexBaseEndpoint}/${apiVersion}/${resourcePath}:${resourceMethod}

Now, resourcePath is generated using the model parameter we pass to .getGenerativeModel method. We generally pass model names such as gemini-1.0-pro. In this case, it appends a prefix to it to create resourcePath which is the full path to Google's original model. When we want to use our fine-tuned models deployed to an endpoint in our Google Cloud project, we need to pass the endpoint(not the model) to the model parameter, as described above. In this case, Vertex node.js Api, checks to see if model parameter starts with 'projects/' and doesn't append any prefix.

Code:

Copyconst vertexAI = new VertexAI({project: GOOGLE_PROJECT_ID, location: 'us-central1', googleAuthOptions: {keyFile: KEY_FILE_PATH}});

    const generativeModel = vertexAI.getGenerativeModel({
      model: 'projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID',
    });

    try {
      const resp = await generativeModel.generateContent(prompt);
      const contentResponse = await resp.response;
      if(!contentResponse || !contentResponse.candidates || contentResponse.candidates.length == 0 || !contentResponse.candidates[0].content 
      || !contentResponse.candidates[0].content.parts || contentResponse.candidates[0].content.parts.length == 0) {
        throw Error("ERROR: NO RESPONSE RETURNED FROM GOOGLE GENAI")
      } else {
        return contentResponse.candidates[0].content.parts[0].text;
      }
    } catch(e) {
      console.error(e)
      throw Error(e)
    }
Answer from cuneyttyler on Stack Overflow
🌐
Google
docs.cloud.google.com › node.js › client libraries › vertex ai api: nodejs client
Vertex AI API: Nodejs Client | Node.js client libraries | Google Cloud Documentation
Skip to main content · Console · English · Deutsch · Español – América Latina · Français · Português – Brasil · 中文 – 简体 · 日本語 · 한국어
🌐
npm
npmjs.com › package › @google-cloud › aiplatform
@google-cloud/aiplatform - npm
June 1, 2026 - Vertex AI client for Node.js. Latest version: 6.8.1, last published: 23 days ago. Start using @google-cloud/aiplatform in your project by running `npm i @google-cloud/aiplatform`. There are 42 other projects in the npm registry using @google-cloud/aiplatform.
      » npm install @google-cloud/aiplatform
    
Published   Jun 01, 2026
Version   6.8.1
🌐
GitHub
github.com › googleapis › nodejs-vertexai
GitHub - googleapis/nodejs-vertexai · GitHub
The Agent Platform SDK for Node.js lets you use the Gemini API to build AI-powered features and applications.
Starred by 175 users
Forked by 68 users
Languages   TypeScript 96.2% | Shell 3.3% | JavaScript 0.5%
🌐
Google
googleapis.dev › nodejs › vertexai › latest › index.html
Home - Documentation
The Vertex AI SDK for Node.js lets you use the Vertex AI Gemini API to build AI-powered features and applications. Both TypeScript and JavaScript are supported.
Top answer
1 of 1
1

It's about how you pass the endpoint to VertexAI node.js API. We need to provide it to the model parameter like this: projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID

It's because how VertexAI node.js API deals with provided parameters. In post_request.js, this is how the final endpoint is generated: let vertexEndpoint = https://${vertexBaseEndpoint}/${apiVersion}/${resourcePath}:${resourceMethod}

Now, resourcePath is generated using the model parameter we pass to .getGenerativeModel method. We generally pass model names such as gemini-1.0-pro. In this case, it appends a prefix to it to create resourcePath which is the full path to Google's original model. When we want to use our fine-tuned models deployed to an endpoint in our Google Cloud project, we need to pass the endpoint(not the model) to the model parameter, as described above. In this case, Vertex node.js Api, checks to see if model parameter starts with 'projects/' and doesn't append any prefix.

Code:

Copyconst vertexAI = new VertexAI({project: GOOGLE_PROJECT_ID, location: 'us-central1', googleAuthOptions: {keyFile: KEY_FILE_PATH}});

    const generativeModel = vertexAI.getGenerativeModel({
      model: 'projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID',
    });

    try {
      const resp = await generativeModel.generateContent(prompt);
      const contentResponse = await resp.response;
      if(!contentResponse || !contentResponse.candidates || contentResponse.candidates.length == 0 || !contentResponse.candidates[0].content 
      || !contentResponse.candidates[0].content.parts || contentResponse.candidates[0].content.parts.length == 0) {
        throw Error("ERROR: NO RESPONSE RETURNED FROM GOOGLE GENAI")
      } else {
        return contentResponse.candidates[0].content.parts[0].text;
      }
    } catch(e) {
      console.error(e)
      throw Error(e)
    }
🌐
Medium
medium.com › @parmarshyamsinh › integrating-vertex-ai-gemini-api-with-node-js-f122dbc067a1
Integrating Vertex AI Gemini API with Node.js | by Parmar shyamsinh | Medium
February 1, 2024 - Original post-https://woycetech.com/ai/vertex-ai-gemini-api-node-js/ This enhanced blog post now provides a clearer path for developers to start using the Vertex AI Node.js SDK, from initial setup to generating AI-powered content.
🌐
npm
npmjs.com › package › @ai-sdk › google-vertex
ai-sdk/google-vertex
3 weeks ago - Get started with AI Gateway. The Google Vertex provider is available in the @ai-sdk/google-vertex module.
      » npm install @ai-sdk/google-vertex
    
Published   Jun 16, 2026
Version   4.0.146
Find elsewhere
🌐
AI SDK
ai-sdk.dev › providers › ai-sdk-providers › google-vertex
AI SDK Providers: Google Vertex AI
The Google Vertex provider is compatible with both Node.js and Edge runtimes. The Edge runtime is supported through the @ai-sdk/google-vertex/edge sub-module.
🌐
Google
googleapis.dev › nodejs › vertexai › latest › VertexAI.html
VertexAI - Documentation
``` 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, }); ```
🌐
Medium
medium.com › @williamwarley › mastering-gcp-vertex-ai-with-javascript-a-comprehensive-guide-for-beginners-and-experts-6ea4e8ef139b
Mastering GCP Vertex AI with JavaScript: A Comprehensive Guide for Beginners and Experts | by Warley's CatOps | Medium
September 16, 2024 - Why Use Vertex AI with JavaScript? While Python has traditionally dominated the machine learning ecosystem, JavaScript (especially with the rise of Node.js) is becoming a popular choice for full-stack developers. By using JavaScript to interact with Vertex AI, you can: Leverage existing skills: If you’re already familiar with JavaScript, you don’t need to learn Python or other ML-specific languages.
🌐
npm
npmjs.com › package › @google-cloud › vertexai
@google-cloud/vertexai - npm
April 15, 2026 - Vertex Generative AI client for Node.js. Latest version: 1.12.0, last published: 2 months ago. Start using @google-cloud/vertexai in your project by running `npm i @google-cloud/vertexai`. There are 121 other projects in the npm registry using @google-cloud/vertexai.
      » npm install @google-cloud/vertexai
    
Published   Apr 15, 2026
Version   1.12.0
🌐
Google
googleapis.dev › nodejs › automl › latest
Cloud AutoML: Node.js Client
🔔 AutoML API NodeJS Client is now available in Vertex AI. Please visit node-js-aiplatform for the new NodeJS Vertex AI client. Vertex AI is our next generation AI Platform, with many new features that are unavailable in the current platform.
🌐
npm
npmjs.com › search
keywords:google vertex ai - npm search
vertex-ai · google-cloud · revenium · middleware · typescript · nodejs · usage-tracking · metering · ai · gabi_sabadin• 0.1.4 • 5 days ago • 0 dependents • MITpublished version 0.1.4, 5 days ago0 dependents licensed under $MIT · 27 · REST API proxy to Vertex AI with the interface of ollama.
🌐
GitHub
github.com › googleapis › nodejs-vertexai › blob › main › package.json
nodejs-vertexai/package.json at main · googleapis/nodejs-vertexai
"description": "Vertex Generative AI client for Node.js", "version": "1.11.0", "license": "Apache-2.0", "author": "Google LLC", "engines": { "node": ">=18.0.0" }, "homepage": "https://github.com/googleapis/nodejs-vertexai", "repository": "googleapis/nodejs-vertexai", "main": "build/src/index.js", "type": "commonjs", "scripts": { "clean": "gts clean", "compile": "tsc -p .", "docs": "jsdoc -c .jsdoc.js", "predocs-test": "npm run docs", "docs-test": "linkinator docs", "compile:oss": "tsc -p tsconfig.json.oss", "fix": "gts fix", "test": "npm
Author   googleapis
🌐
Langchain
js.langchain.com › docs › integrations › llms › google_vertex_ai
LangChain overview - Docs by LangChain
LangChain provides create_agent: a minimal, highly configurable agent harness. Compose exactly the agent your use case needs from model, tools, prompt, and middleware.