feat(gemini): refactor Gemini client for ADC/vertex auth and improvements when building with optional LLM provider dependencies#1201
Open
geojaz wants to merge 8 commits intogetzep:mainfrom
Open
Conversation
Member
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
danielchalef
added a commit
that referenced
this pull request
Feb 6, 2026
04a0ddb to
23d5f10
Compare
Contributor
Author
|
Ok, i've validated gemini auth via vertex AI ADC and gemini API key 🚀 |
lehcode
pushed a commit
to lehcode/reactive-graphiti
that referenced
this pull request
Feb 8, 2026
maskshell
pushed a commit
to maskshell/graphiti
that referenced
this pull request
Feb 9, 2026
maskshell
pushed a commit
to maskshell/graphiti
that referenced
this pull request
Feb 9, 2026
maskshell
pushed a commit
to maskshell/graphiti
that referenced
this pull request
Feb 10, 2026
…oring Add support for Gemini 3 preview models, Application Default Credentials (ADC) for Vertex AI authentication, and consolidate client initialization logic across all Gemini components. Features: - Update default model to gemini-3-flash-preview - Add gemini-3-pro-preview and gemini-3-flash-preview to model catalog - Support ADC authentication via GOOGLE_CLOUD_PROJECT environment variable - Create shared gemini_utils.py helper to DRY up ~150 lines of duplicated code - Standardize on Google's GOOGLE_CLOUD_* environment variables Changes: - graphiti_core/llm_client/gemini_client.py: Gemini 3 models, use shared helper - graphiti_core/llm_client/gemini_utils.py: New shared client initialization helper - graphiti_core/embedder/gemini.py: Refactored to use shared helper - graphiti_core/cross_encoder/gemini_reranker_client.py: Refactored to use shared helper - All config files: Use GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION - All docker-compose files: Pass through GOOGLE_CLOUD_* vars - All tests: Updated to use GOOGLE_CLOUD_PROJECT in mocks Authentication modes: 1. API Key (Google AI): Set GOOGLE_API_KEY 2. ADC (Vertex AI): Set GOOGLE_CLOUD_PROJECT + optional GOOGLE_CLOUD_LOCATION All 63 Gemini tests passing.
Enable selective installation of LLM provider dependencies via Docker build arguments to reduce image size and installation time. Features: - Add build arguments for optional provider dependencies (all default to false) - Apply to all Dockerfiles: root, mcp_server/docker/Dockerfile, and Dockerfile.standalone - Restructure mcp_server/pyproject.toml optional dependencies into individual groups - Add comprehensive Docker build documentation with examples Build Arguments: - INSTALL_GOOGLE_GENAI - Install google-genai for Gemini models - INSTALL_ANTHROPIC - Install anthropic for Claude models - INSTALL_GROQ - Install groq for Groq models - INSTALL_VOYAGEAI - Install voyageai for Voyage embeddings - INSTALL_SENTENCE_TRANSFORMERS - Install sentence-transformers for local embeddings Usage: # Build with specific providers docker build --build-arg INSTALL_GOOGLE_GENAI=true -f Dockerfile . docker build --build-arg INSTALL_GOOGLE_GENAI=true -f mcp_server/docker/Dockerfile . Backward compatible: Default behavior unchanged (no optional providers installed).
Update google-genai dependency to 1.62.0 to support Gemini 3 models and update documentation with Gemini authentication guidance. Changes: - Bump google-genai from 1.8.0 to 1.62.0 in pyproject.toml - Add Gemini authentication section to CLAUDE.md - Update MCP server factories to allow optional API key for ADC - Update uv.lock with new dependency versions - Update CLA signature All tests passing with updated dependencies.
- Fix environment variable default syntax (: to :-) for docker-compose compatibility - Add vertexai: true for Neo4j Gemini config to use Application Default Credentials - Update FalkorDB config for ADC (commented out pending API key removal) - Fixes 'invalid interpolation format' error when running docker-compose
- Fix environment variable default syntax (: to :-) for docker-compose compatibility - Add vertexai: true for Neo4j Gemini config to use Application Default Credentials - Update FalkorDB config for ADC (commented out pending API key removal) - Fixes 'invalid interpolation format' error when running docker-compose
- Update factories.py to set GOOGLE_CLOUD_PROJECT/LOCATION in environment when using ADC (no API key provided) - Add google.auth import attempt to ensure credentials are loaded for ADC - Add debug logging to gemini_utils.py to trace ADC initialization - Update config-docker-falkordb-gemini.yaml to document both auth options (Google AI API key and Vertex AI ADC) with clear comments - Create config-docker-neo4j-gemini.yaml for Neo4j backend with ADC support - Create docker-compose-gemini-adc.yml as alternate composition with full ADC setup - Fix docker-compose.yml environment variable passing to properly load .env configuration without trailing '-' defaults interfering with Vertex AI init - Add start.sh helper script to properly handle docker-compose --env-file - Update .env template to clearly document authentication options with both Google AI API key (free tier) and Vertex AI ADC (project-based) The google-genai 1.62.0 library supports Vertex AI initialization via: genai.Client(vertexai=True, project=..., location=...) This change ensures: 1. Environment variables are properly set from config before client init 2. ADC credentials are attempted to be loaded explicitly 3. Docker-compose properly passes env vars from .env file 4. Configuration is clear about both authentication methods 5. Debug logging added to trace initialization flow Tested: genai.Client(vertexai=True, project, location) works correctly when GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION are set in environment
The explicit call to auth.default() was causing test failures in CI because it attempts to load real credentials from the environment. The google-genai library handles ADC (Application Default Credentials) loading internally when genai.Client is initialized with vertexai=True, so the explicit credential loading is unnecessary. This fix: - Removes the google.auth import and HAS_GOOGLE_AUTH flag - Allows genai.Client to handle credential loading internally - Fixes all failing Gemini client, embedder, and reranker tests in CI - All 219 unit tests now pass The ADC authentication path still works correctly - when vertexai=True is passed without an API key, genai.Client will automatically use Application Default Credentials if available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors Gemini client to support both Google AI API (via API key) and Vertex AI (via Application Default Credentials) authentication modes. Also adds conditional
LLM provider dependency installation via Docker build arguments to reduce image size when using specific providers.
Type of Change
Objective
For new features and performance improvements:
Gemini ADC/Vertex AI Authentication:
Enables enterprise users to authenticate Gemini models using Application Default Credentials (ADC) instead of requiring API keys. This supports:
Docker Build Simplifications:
Adds build arguments to make it easier for users of "optional" LLM providers to build container images with the optional dependencies they need without including all.
Breaking Changes
Note: No breaking changes.
Existing API key authentication continues to work unchanged
ADC support is opt-in (triggered when no API key is provided)
Docker defaults remain the same (OpenAI dependencies only)
Checklist
make lintpasses)Documentation updates: