Skip to content

Fix: update Vertex AI model path handling - #21

Merged
nshkrdotcom merged 7 commits into
mainfrom
fix-vertex-models
Feb 23, 2026
Merged

Fix: update Vertex AI model path handling#21
nshkrdotcom merged 7 commits into
mainfrom
fix-vertex-models

Conversation

@nshkrdotcom

@nshkrdotcom nshkrdotcom commented Feb 22, 2026

Copy link
Copy Markdown
Owner

This PR mirrors the latest maintainer commit from #20 (fork branch) so it can be reviewed/merged without fork-write permissions.

Why: PR #20 has maintainer edits disabled (maintainerCanModify=false) and the branch owner must enable edits to accept direct pushes.

Includes commit: 716f9e4

Supersedes: #20

tgodniak and others added 4 commits February 18, 2026 09:46
- Remove query params from Vertex AI websocket path
- Add model_prefix for Vertex AI models with project/location path
Add support for GOOGLE_APPLICATION_CREDENTIALS_JSON environment variable
which contains the service account JSON content directly. This is useful
for containerized environments (Heroku, Fly.io, etc.) where mounting
credential files is not practical.
Add documentation for the new GOOGLE_APPLICATION_CREDENTIALS_JSON
environment variable option for containerized environments.
This commit introduces support for GOOGLE_APPLICATION_CREDENTIALS_JSON,
allowing service account credentials to be passed directly as JSON
content via environment variables. This serves as a gemini_ex
extension to standard Application Default Credentials (ADC) for
easier deployment in containerized environments.

Key changes:

- Added GOOGLE_APPLICATION_CREDENTIALS_JSON as the highest priority
in the ADC discovery chain.
- Upgraded the Vertex AI Live WebSocket endpoint from v1beta1 to v1.
- Refactored service account JSON parsing to use a map-based atom
key conversion for better reliability.
- Improved model normalization in Gemini.Types.Live.Setup to handle
fully qualified project resource names without duplication.
- Updated documentation regarding auth priority, billing requirements
for Vertex Live, and versioning differences between Gemini and Vertex.
- Refactored test suites to isolate environment variables by setting
async: false and adding cleanup logic.
- Added RUN_BILLED_VERTEX_LIVE_TESTS flag to gate tests that require
active GCP billing.
- Adjusted rate limiter tests to reduce timing flakiness during
backoff assertions.
Introduces Gemini.ModelRegistry as the central source of truth for model
capabilities, modalities, and version aliases. This change improves the
reliability of model selection, especially for the Live API, by moving away
from static lists to a capability-based lookup system.

Core enhancements:
- Introduced Gemini.ModelRegistry to track features like thinking, live_api,
and structured outputs across the model catalog.
- Refactored Gemini.Live.Models.resolve/2 to use registry metadata combined
with runtime API discovery for smarter fallback behavior.
- Updated Gemini.Client.HTTP to allow per-request authentication overrides,
enabling dynamic switching of API keys or GCP projects.
- Improved Vertex AI compatibility by handling publisherModels payloads and
normalizing full resource names in the Coordinator.
- Expanded the configuration to support Gemini 3.1 Pro, updated Live API
defaults, and added specialized models for image/video generation.
- Added helper functions to Gemini.Config for capability checks and metadata
retrieval.
- Fixed model path building for Vertex AI to correctly support location and
publisher prefixes.

This update ensures that as new models are rolled out, the library can
automatically discover and utilize compatible versions based on requested
capabilities.
…ncements

This release introduces a centralized Model Registry, expands authentication
options for containerized environments, and improves Vertex AI integration
consistency across the library.

Model Registry and Configuration:
- Added Gemini.ModelRegistry for tracking model capabilities, modalities,
and support states.
- Implemented capability checks for live API, structured outputs, and
modality-based model selection.
- Added Config functions for model metadata lookup and capability filtering.

Authentication and ADC:
- Added support for GOOGLE_APPLICATION_CREDENTIALS_JSON to allow service
account configuration via environment variables.
- Updated HTTP client to respect per-request authentication overrides,
including API keys, project IDs, and service accounts.
- Improved service account JSON parsing with an explicit key allowlist.

Vertex AI and Live API:
- Upgraded Vertex Live API endpoint to v1.
- Standardized Vertex AI resource paths for model listing and retrieval.
- Normalized response shapes between Gemini and Vertex AI model endpoints.
- Improved Live API model resolution to prioritize registry-backed
candidates based on modality.

Generation API Improvements:
- Updated Video generation request schemas for compatibility with latest
API requirements, including Veo 3.1 support.
- Refactored person generation and resolution parameters in video requests.
- Standardized Vertex AI configuration validation for Image and Video APIs.
- Improved streaming response collection with configurable timeouts.

Cleanup and Maintenance:
- Removed approximately 50,000 lines of internal planning documents and
legacy development artifacts.
- Added integration tests for ADC-authenticated Live API sessions.
- Fixed path handling in the HTTP client to prevent double-prefixing of
absolute URLs.
This update introduces a centralized Model Registry, upgrades the Vertex Live
API to v1, and aligns Video Generation with Veo 3.1 requirements.

Model Registry and Resolution:
- Introduced ModelRegistry to track capabilities and modalities.
- Live API model resolution now uses registry-backed auth-aware selection.
- Separate candidate lists implemented for gemini vs vertex_ai strategies.
- Updated default models to native audio versions for Live sessions.

Vertex AI and Authentication:
- Upgraded Vertex Live API to v1 and corrected resource name formatting.
- Fixed list_models pagination to use query parameters for Vertex AI.
- Automated Vertex AI authentication for all Images API requests.
- Revised ADC discovery order: JSON env -> Path env -> gcloud -> metadata.
- Added RUN_BILLED_VERTEX_LIVE_TESTS gate to prevent accidental GCP costs.

Video and Image Generation:
- Refactored Video API to use flattened request keys for Veo 3.1 compatibility.
- Updated binary encoding from bytesBase64Encoded to inlineData format.
- Changed person_generation default to :dont_allow and moved to snake_case.
- Retained legacy fields in structs for BC but excluded them from API payloads.

Streaming and Reliability:
- Added :stream_timeout option (default 60s) to Gemini.stream_generate/2.
- Implemented automatic cleanup of orphaned streams on timeout via Coordinator.
- UnifiedManager now passes advanced streaming knobs to the HTTP client.

Documentation and Maintenance:
- Relocated guide files to the guides/ directory and updated all internal links.
- Updated README to reflect new v0.10.0 features and configuration options.
- Normalized publisherModels responses to match Gemini API shapes.
@nshkrdotcom
nshkrdotcom merged commit c44bb3b into main Feb 23, 2026
1 check passed
@nshkrdotcom

Copy link
Copy Markdown
Owner Author

Released as https://hex.pm/packages/gemini_ex/0.10.0

@nshkrdotcom
nshkrdotcom deleted the fix-vertex-models branch February 23, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants