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.
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
UrlFetchApppath as a transparent fallback.Background
PR: #75
Requested by: @aubrypaul
Motivation
UrlFetchAppHTTP calls when the service is available.Changes Introduced
callVertexAi(endpoint, payload)dispatcher that tries the Advanced Service first and falls back to_callGenAIApi()(UrlFetchApp path)._getVertexAiAdvancedService(),_getVertexAiGenerateContentMethod(),_getVertexAiModelResource(),_buildVertexAiAdvancedServicePayload(),_normalizeVertexAiResponse(),_logVertexAiAdvancedServiceFallback().setGeminiAuth()(GCP-authenticated, no API key) are now sent throughcallVertexAi(). API-key Gemini calls and all other UrlFetchApp calls remain unchanged.README.mdto document the Advanced Service preference and required OAuth scopes.Notes
node --checkon the source (succeeded).97a7711) was applied tosrc/code.gsas part of the review process.