Skip to content

feat: add support for Gemini (AI Studio) and Gemini Enterprise (Vertex AI)#36

Closed
Ernani Joppert Pontes Martins (ernani) wants to merge 3 commits into
langchain-ai:mainfrom
ernani:gemini-support
Closed

feat: add support for Gemini (AI Studio) and Gemini Enterprise (Vertex AI)#36
Ernani Joppert Pontes Martins (ernani) wants to merge 3 commits into
langchain-ai:mainfrom
ernani:gemini-support

Conversation

@ernani

Copy link
Copy Markdown

Hello! This PR adds native support for the Google Gemini API providers:

  • gemini (Google AI Studio): For developer-focused setups using GEMINI_API_KEY.
  • gemini-enterprise (Gemini Enterprise Agent Platform / Vertex AI): For enterprise setups using GCP Application Default Credentials (ADC) and Project ID (GOOGLE_CLOUD_PROJECT), encouraging secure credential management.

Key features of this implementation:

  • Unified Dependency: Leverages the official @langchain/google package, resolving both providers under the same SDK.
  • Active Onboarding Validation: Performs real-time validation checks during interactive setup (verifying credentials with a lightweight ping command) before saving them to ~/.openwiki/.env.
  • Updated Models: Features active model listings (gemini-3.5-flash, gemini-3.1-pro-preview, gemini-3.0-flash, gemini-3.0-pro, gemini-2.5-pro) and avoids deprecated versions.

This implementation builds upon the goals discussed in #29, providing a more robust, secure, and production-ready solution that accommodates enterprise cloud environments.

Closes #29

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

gemini-enterprise uses GOOGLE_CLOUD_PROJECT as its "API key" environment variable and even writes the entered value into process.env.GOOGLE_CLOUD_PROJECT before constructing ChatGoogle. However, ChatGoogle is instantiated without explicitly passing the project ID, relying on ambient environment state instead. That makes the configuration less predictable and can fail in environments where credentials/project resolution is handled differently. Since this PR introduces first-class Vertex AI support, it would be better to pass the project ID explicitly to ChatGoogle (instead of treating it as an API key env var) and keep the provider configuration aligned with how the SDK expects GCP settings.

@ppsplus-bradh

Copy link
Copy Markdown
Contributor

Hi Ernani Joppert Pontes Martins (@ernani) — thanks for adding Gemini/Vertex support! I put together a small helper PR against your branch that addresses PRATHAM KUMAR (@rajpratham1)'s review: ernani#1 (base gemini-support). Merging it there will roll the changes into this PR automatically; feel free to cherry-pick instead if you prefer.

It:

  • passes the GCP project explicitly to ChatGoogle via googleAuthOptions: { projectId } (imported from the @langchain/google/node entrypoint, since the default entrypoint types authOptions as never) instead of relying on ambient process.env,
  • drops the setup-time testModel.invoke([{ role: "user", content: "ping" }]) validation in credentials.tsx, which was the source of the flagged process.env.GOOGLE_CLOUD_PROJECT mutation and also added a network round-trip during onboarding that no other provider performs.

Same package (no new dependency), and the /node client still supports the AI Studio gai/apiKey path. Build, lint, and prettier all pass. Happy to adjust to your preferences.

@colifran

Copy link
Copy Markdown
Contributor

HI Ernani Joppert Pontes Martins (@ernani) - sorry for getting to this PR late. would you mind rebasing your changes?

@colifran

Copy link
Copy Markdown
Contributor

Thank you for the PR. Closing to support this via #154.

@ernani

Ernani Joppert Pontes Martins (ernani) commented Jul 16, 2026

Copy link
Copy Markdown
Author

Hi Colin Francis (@colifran) I am glad to see that this evolved in such a rapid pace! I've had some 10 days vacation and I can see how far this went through! Glad to collaborate and benefit all Gemini users with Openwiki! Thanks for catching up this PR!

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.

Add support for gemini

4 participants