Skip to content

feat(embeddingModel): Add Backend API selection fields#2592

Merged
duwenxin99 merged 7 commits intomainfrom
embed-fix
Mar 30, 2026
Merged

feat(embeddingModel): Add Backend API selection fields#2592
duwenxin99 merged 7 commits intomainfrom
embed-fix

Conversation

@duwenxin99
Copy link
Copy Markdown
Contributor

@duwenxin99 duwenxin99 commented Mar 2, 2026

Allow users to use both VertexAI and Google AI as gemini embedding model backend.

  • Use ADC for VertexAI authentication (either configure project and location inside the yaml file or as env vars).
  • Use API key for Google AI authentication.

@duwenxin99 duwenxin99 requested a review from a team as a code owner March 2, 2026 01:18
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the flexibility of Gemini embedding model configurations by allowing users to explicitly select their preferred backend API: either Google AI with an API key or Vertex AI with Application Default Credentials. This change provides more robust authentication options and clearer guidance for integrating Gemini models into various environments, from quick testing to production deployments.

Highlights

  • Backend API Selection for Gemini Embedding Models: Introduced a new useVertexAI boolean field in the Gemini embedding model configuration, allowing users to explicitly choose between Google AI and Vertex AI backends.
  • Vertex AI Authentication (ADC): Enabled support for Vertex AI authentication using Application Default Credentials (ADC). This mode requires project and location to be configured, either directly in the YAML or via environment variables (GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION).
  • Google AI Authentication (API Key): Maintained support for Google AI authentication using an API Key, which can be provided in the YAML configuration or through GOOGLE_API_KEY/GEMINI_API_KEY environment variables.
  • Enhanced Credential Handling and Error Messages: Improved the logic for loading credentials and backend configuration, including more informative error messages when required credentials or configuration parameters are missing.
  • Updated Documentation: Updated the Gemini embedding model documentation to clearly explain the new authentication modes, configuration fields, and provide example YAML snippets for both Google AI and Vertex AI setups.
Changelog
  • docs/en/resources/embeddingModels/_index.md
    • Added a description field to the insert_embedding tool example.
    • Added a description field to the search_embedding tool example.
  • docs/en/resources/embeddingModels/gemini.md
    • Updated the description of Gemini embedding models for clarity.
    • Revised the authentication section to detail both Google AI (API Key) and Vertex AI (ADC) modes.
    • Added distinct example configurations for 'Using Google AI' and 'Using Vertex AI'.
    • Expanded the reference table to include useVertexAI, project, and location fields, and updated the model example.
  • internal/embeddingmodels/gemini/gemini.go
    • Imported the os package to support environment variable loading.
    • Added UseVertexAI, Project, and Location fields to the Config struct.
    • Modified the Initialize method to implement conditional backend selection based on useVertexAI.
    • Implemented logic to retrieve API keys, project IDs, and locations from configuration or environment variables.
    • Added validation to ensure project and location are provided when useVertexAI is true.
    • Introduced a default location of 'us-central1' for Vertex AI if not explicitly set.
    • Improved error handling with detailed messages for missing credentials or misconfigurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to select between Google AI and Vertex AI backends for Gemini embedding models, configurable via a useVertexAI flag. The changes include updating the Gemini embedding model configuration, implementing the logic to handle both backends with their respective authentication methods (API key for Google AI, ADC for Vertex AI), and updating the documentation accordingly.

My review identifies a critical issue with the validation of the useVertexAI field that would prevent users from setting it to false. I've also found some dead code and opportunities to improve code readability and documentation clarity.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 2, 2026

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 2, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 2, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2026

@Yuan325 Yuan325 added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Mar 11, 2026
@duwenxin99 duwenxin99 enabled auto-merge (squash) March 26, 2026 21:22
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Cloudflare Preview Ready!

🔎 View Preview: https://pr-2592.toolbox-docs-6xc.pages.dev

(Note: Subsequent pushes to this PR will automatically update the preview at this same URL)

@duwenxin99 duwenxin99 disabled auto-merge March 26, 2026 21:31
@duwenxin99 duwenxin99 enabled auto-merge (squash) March 26, 2026 21:37
@github-actions
Copy link
Copy Markdown
Contributor

@github-actions
Copy link
Copy Markdown
Contributor

@duwenxin99 duwenxin99 merged commit 912aa9e into main Mar 30, 2026
27 checks passed
@duwenxin99 duwenxin99 deleted the embed-fix branch March 30, 2026 03:34
@github-actions
Copy link
Copy Markdown
Contributor

🧨 Preview deployments removed.

Cloudflare Pages environments for pr-2592 have been deleted.

@github-actions
Copy link
Copy Markdown
Contributor

🧨 Preview deployments removed.

github-actions bot pushed a commit that referenced this pull request Mar 30, 2026
Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit that referenced this pull request Mar 30, 2026
Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to renovate-bot/googleapis-_-genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to renovate-bot/googleapis-_-genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to pepe57/genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to pepe57/genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to Jaleel-zhu/genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to Jaleel-zhu/genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to CrazyForks/genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to CrazyForks/genai-toolbox that referenced this pull request Mar 30, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to TheTechOddBug/genai-toolbox that referenced this pull request Mar 31, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
github-actions bot pushed a commit to TheTechOddBug/genai-toolbox that referenced this pull request Mar 31, 2026
…eapis#2592)

Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication. 912aa9e
duwenxin99 added a commit that referenced this pull request Apr 7, 2026
Allow users to use both VertexAI and Google AI as gemini embedding model
backend.
- Use ADC for VertexAI authentication (either configure `project` and
`location` inside the yaml file or as env vars).
- Use API key for Google AI authentication.
Yuan325 added a commit that referenced this pull request Apr 8, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.32.0](v0.31.0...v0.32.0)
(2026-04-08)


### ⚠ BREAKING CHANGES

* update repo name
([#2968](#2968))

### Features

* Add MCP tool annotations to all remaining tools
([#2221](#2221))
([ea09db9](ea09db9))
* **bigquery:** Add conversational analytics tools for Data Agents
([#2517](#2517))
([2490a4b](2490a4b))
* **embeddingModel:** Add Backend API selection fields
([#2592](#2592))
([912aa9e](912aa9e))
* **skills:** Add Claude Code support to generated scripts
([#2966](#2966))
([a1609e1](a1609e1))
* **skills:** Add codex user agent
([#2973](#2973))
([070e939](070e939))
* **skills:** Tool invocation via npx
([#2916](#2916))
([377dc5b](377dc5b))
* **sources/singlestore:** Add ConnectionParams to SingleStore Config
([#2555](#2555))
([73e2a8c](73e2a8c))
* **tool/dataplex-lookup-context:** Relax project constraint and enforce
location
([#2952](#2952))
([7ebfdf1](7ebfdf1))
* **tools/looker:** Looker agent management from MCP
([#2830](#2830))
([649d4ad](649d4ad))
* **ui:** Update to use `/mcp` endpoint
([#2829](#2829))
([c3059c2](c3059c2))


### Bug Fixes

* **bigquery:** Add impersonateServiceAccount to prebuilt config
([#2770](#2770))
([9c3a748](9c3a748))
* **quickstart:** Robust tool lookup and modernize dependencies in
Python samples
([#2863](#2863))
([4c0845d](4c0845d))
* **skills:** Fix skill generation template
([#2914](#2914))
([a01a15e](a01a15e))
* **skills:** Prevent empty strings overriding optional env vars in node
scripts ([#2963](#2963))
([c52adeb](c52adeb))
* **tests/bigquery:** Implement uuid-based isolation and reliable
resource cleanup
([#2547](#2547))
([479d842](479d842))
* **tests/Bigtable:** Implement uuid-based isolation and reliable
resource cleanup
([#2880](#2880))
([a769f15](a769f15))
* Update error for ConvertConfig function
([#2993](#2993))
([62bdabb](62bdabb))


### Code Refactoring

* Update repo name
([#2968](#2968))
([3aae809](3aae809))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Apr 8, 2026
🤖 I have created a release *beep* *boop*
---

##
[0.32.0](v0.31.0...v0.32.0)
(2026-04-08)

### ⚠ BREAKING CHANGES

* update repo name
([#2968](#2968))

### Features

* Add MCP tool annotations to all remaining tools
([#2221](#2221))
([ea09db9](ea09db9))
* **bigquery:** Add conversational analytics tools for Data Agents
([#2517](#2517))
([2490a4b](2490a4b))
* **embeddingModel:** Add Backend API selection fields
([#2592](#2592))
([912aa9e](912aa9e))
* **skills:** Add Claude Code support to generated scripts
([#2966](#2966))
([a1609e1](a1609e1))
* **skills:** Add codex user agent
([#2973](#2973))
([070e939](070e939))
* **skills:** Tool invocation via npx
([#2916](#2916))
([377dc5b](377dc5b))
* **sources/singlestore:** Add ConnectionParams to SingleStore Config
([#2555](#2555))
([73e2a8c](73e2a8c))
* **tool/dataplex-lookup-context:** Relax project constraint and enforce
location
([#2952](#2952))
([7ebfdf1](7ebfdf1))
* **tools/looker:** Looker agent management from MCP
([#2830](#2830))
([649d4ad](649d4ad))
* **ui:** Update to use `/mcp` endpoint
([#2829](#2829))
([c3059c2](c3059c2))

### Bug Fixes

* **bigquery:** Add impersonateServiceAccount to prebuilt config
([#2770](#2770))
([9c3a748](9c3a748))
* **quickstart:** Robust tool lookup and modernize dependencies in
Python samples
([#2863](#2863))
([4c0845d](4c0845d))
* **skills:** Fix skill generation template
([#2914](#2914))
([a01a15e](a01a15e))
* **skills:** Prevent empty strings overriding optional env vars in node
scripts ([#2963](#2963))
([c52adeb](c52adeb))
* **tests/bigquery:** Implement uuid-based isolation and reliable
resource cleanup
([#2547](#2547))
([479d842](479d842))
* **tests/Bigtable:** Implement uuid-based isolation and reliable
resource cleanup
([#2880](#2880))
([a769f15](a769f15))
* Update error for ConvertConfig function
([#2993](#2993))
([62bdabb](62bdabb))

### Code Refactoring

* Update repo name
([#2968](#2968))
([3aae809](3aae809))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com> b9ae1c6
github-actions bot pushed a commit to renovate-bot/googleapis-_-genai-toolbox that referenced this pull request Apr 8, 2026
🤖 I have created a release *beep* *boop*
---

##
[0.32.0](googleapis/mcp-toolbox@v0.31.0...v0.32.0)
(2026-04-08)

### ⚠ BREAKING CHANGES

* update repo name
([googleapis#2968](googleapis#2968))

### Features

* Add MCP tool annotations to all remaining tools
([googleapis#2221](googleapis#2221))
([ea09db9](googleapis@ea09db9))
* **bigquery:** Add conversational analytics tools for Data Agents
([googleapis#2517](googleapis#2517))
([2490a4b](googleapis@2490a4b))
* **embeddingModel:** Add Backend API selection fields
([googleapis#2592](googleapis#2592))
([912aa9e](googleapis@912aa9e))
* **skills:** Add Claude Code support to generated scripts
([googleapis#2966](googleapis#2966))
([a1609e1](googleapis@a1609e1))
* **skills:** Add codex user agent
([googleapis#2973](googleapis#2973))
([070e939](googleapis@070e939))
* **skills:** Tool invocation via npx
([googleapis#2916](googleapis#2916))
([377dc5b](googleapis@377dc5b))
* **sources/singlestore:** Add ConnectionParams to SingleStore Config
([googleapis#2555](googleapis#2555))
([73e2a8c](googleapis@73e2a8c))
* **tool/dataplex-lookup-context:** Relax project constraint and enforce
location
([googleapis#2952](googleapis#2952))
([7ebfdf1](googleapis@7ebfdf1))
* **tools/looker:** Looker agent management from MCP
([googleapis#2830](googleapis#2830))
([649d4ad](googleapis@649d4ad))
* **ui:** Update to use `/mcp` endpoint
([googleapis#2829](googleapis#2829))
([c3059c2](googleapis@c3059c2))

### Bug Fixes

* **bigquery:** Add impersonateServiceAccount to prebuilt config
([googleapis#2770](googleapis#2770))
([9c3a748](googleapis@9c3a748))
* **quickstart:** Robust tool lookup and modernize dependencies in
Python samples
([googleapis#2863](googleapis#2863))
([4c0845d](googleapis@4c0845d))
* **skills:** Fix skill generation template
([googleapis#2914](googleapis#2914))
([a01a15e](googleapis@a01a15e))
* **skills:** Prevent empty strings overriding optional env vars in node
scripts ([googleapis#2963](googleapis#2963))
([c52adeb](googleapis@c52adeb))
* **tests/bigquery:** Implement uuid-based isolation and reliable
resource cleanup
([googleapis#2547](googleapis#2547))
([479d842](googleapis@479d842))
* **tests/Bigtable:** Implement uuid-based isolation and reliable
resource cleanup
([googleapis#2880](googleapis#2880))
([a769f15](googleapis@a769f15))
* Update error for ConvertConfig function
([googleapis#2993](googleapis#2993))
([62bdabb](googleapis@62bdabb))

### Code Refactoring

* Update repo name
([googleapis#2968](googleapis#2968))
([3aae809](googleapis@3aae809))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com> b9ae1c6
github-actions bot pushed a commit to Jaleel-zhu/genai-toolbox that referenced this pull request Apr 8, 2026
🤖 I have created a release *beep* *boop*
---

##
[0.32.0](googleapis/mcp-toolbox@v0.31.0...v0.32.0)
(2026-04-08)

### ⚠ BREAKING CHANGES

* update repo name
([googleapis#2968](googleapis#2968))

### Features

* Add MCP tool annotations to all remaining tools
([googleapis#2221](googleapis#2221))
([ea09db9](googleapis@ea09db9))
* **bigquery:** Add conversational analytics tools for Data Agents
([googleapis#2517](googleapis#2517))
([2490a4b](googleapis@2490a4b))
* **embeddingModel:** Add Backend API selection fields
([googleapis#2592](googleapis#2592))
([912aa9e](googleapis@912aa9e))
* **skills:** Add Claude Code support to generated scripts
([googleapis#2966](googleapis#2966))
([a1609e1](googleapis@a1609e1))
* **skills:** Add codex user agent
([googleapis#2973](googleapis#2973))
([070e939](googleapis@070e939))
* **skills:** Tool invocation via npx
([googleapis#2916](googleapis#2916))
([377dc5b](googleapis@377dc5b))
* **sources/singlestore:** Add ConnectionParams to SingleStore Config
([googleapis#2555](googleapis#2555))
([73e2a8c](googleapis@73e2a8c))
* **tool/dataplex-lookup-context:** Relax project constraint and enforce
location
([googleapis#2952](googleapis#2952))
([7ebfdf1](googleapis@7ebfdf1))
* **tools/looker:** Looker agent management from MCP
([googleapis#2830](googleapis#2830))
([649d4ad](googleapis@649d4ad))
* **ui:** Update to use `/mcp` endpoint
([googleapis#2829](googleapis#2829))
([c3059c2](googleapis@c3059c2))

### Bug Fixes

* **bigquery:** Add impersonateServiceAccount to prebuilt config
([googleapis#2770](googleapis#2770))
([9c3a748](googleapis@9c3a748))
* **quickstart:** Robust tool lookup and modernize dependencies in
Python samples
([googleapis#2863](googleapis#2863))
([4c0845d](googleapis@4c0845d))
* **skills:** Fix skill generation template
([googleapis#2914](googleapis#2914))
([a01a15e](googleapis@a01a15e))
* **skills:** Prevent empty strings overriding optional env vars in node
scripts ([googleapis#2963](googleapis#2963))
([c52adeb](googleapis@c52adeb))
* **tests/bigquery:** Implement uuid-based isolation and reliable
resource cleanup
([googleapis#2547](googleapis#2547))
([479d842](googleapis@479d842))
* **tests/Bigtable:** Implement uuid-based isolation and reliable
resource cleanup
([googleapis#2880](googleapis#2880))
([a769f15](googleapis@a769f15))
* Update error for ConvertConfig function
([googleapis#2993](googleapis#2993))
([62bdabb](googleapis@62bdabb))

### Code Refactoring

* Update repo name
([googleapis#2968](googleapis#2968))
([3aae809](googleapis@3aae809))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com> b9ae1c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants