Skip to content

Prefer Vertex AI Advanced Service for Gemini calls #80

Description

@coderabbitai

Overview

This issue tracks the work introduced in PR #75 to prefer the Google Apps Script Vertex AI Advanced Service for Vertex AI/Gemini requests when available, while keeping the existing UrlFetchApp path as a transparent fallback.

Background

PR: #75
Requested by: @aubrypaul

Motivation

  • Use the native Apps Script Vertex AI Advanced Service for Gemini calls instead of raw UrlFetchApp HTTP calls when the service is available.
  • Retain existing behavior, response shape, and error handling as a fallback.

Changes Introduced

  • Added callVertexAi(endpoint, payload) dispatcher that tries the Advanced Service first and falls back to _callGenAIApi() (UrlFetchApp path).
  • Added Advanced Service helpers: _getVertexAiAdvancedService(), _getVertexAiGenerateContentMethod(), _getVertexAiModelResource(), _buildVertexAiAdvancedServicePayload(), _normalizeVertexAiResponse(), _logVertexAiAdvancedServiceFallback().
  • Routing: Gemini requests using setGeminiAuth() (GCP-authenticated, no API key) are now sent through callVertexAi(). API-key Gemini calls and all other UrlFetchApp calls remain unchanged.
  • Updated README.md to document the Advanced Service preference and required OAuth scopes.

Notes

  • No automated unit tests were added; the fallback preserves existing runtime/retry behavior.
  • A syntax check was performed by running node --check on the source (succeeded).
  • An autofix commit (97a7711) was applied to src/code.gs as part of the review process.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions