Skip to content

fix: pass Vertex project explicitly to ChatGoogle; drop setup-time ping call#1

Closed
ppsplus-bradh wants to merge 1 commit into
ernani:gemini-supportfrom
ppsplus-bradh:fix/vertex-explicit-project
Closed

fix: pass Vertex project explicitly to ChatGoogle; drop setup-time ping call#1
ppsplus-bradh wants to merge 1 commit into
ernani:gemini-supportfrom
ppsplus-bradh:fix/vertex-explicit-project

Conversation

@ppsplus-bradh

Copy link
Copy Markdown

Hi @ernani — this is a small helper PR targeting your gemini-support branch to address @rajpratham1's review on langchain-ai#36. Merge it into your branch and it will roll into that PR. Feel free to cherry-pick instead if you prefer.

What the review asked

gemini-enterprise uses GOOGLE_CLOUD_PROJECT as its "API key" env var 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… it would be better to pass the project ID explicitly to ChatGoogle and keep the provider configuration aligned with how the SDK expects GCP settings.

Changes

  • Pass the project explicitly. createModel()'s gemini-enterprise branch now reads GOOGLE_CLOUD_PROJECT and passes it as googleAuthOptions: { projectId } to ChatGoogle, rather than relying on ambient process.env resolution.
  • Use the Node auth entrypoint. Import ChatGoogle from @langchain/google/node. The default @langchain/google entrypoint types authOptions as never and is API-key oriented, so googleAuthOptions isn't available there. It's the same package (no new dependency), and the /node client still supports the AI Studio gai/apiKey path used by the gemini provider.
  • Drop the setup-time validation call in credentials.tsx that mutated process.env.GOOGLE_CLOUD_PROJECT and issued a live testModel.invoke([{ role: "user", content: "ping" }], { timeout: 5000 }) during onboarding. That was the source of the flagged process.env mutation, and it also added a network round-trip, cost, and a potential hang that no other provider performs at setup.

Verified: pnpm run build, pnpm run lint:check, and prettier --check on the changed files all pass; runtime construction of ChatGoogle succeeds for the gcp+projectId, gcp (ambient ADC), and gai paths.

Note: this keeps GOOGLE_CLOUD_PROJECT as the provider's credential env key (the credential gate still works), so the diff stays minimal. Fully re-modeling GCP settings as their own credential fields (rather than reusing apiKeyEnvKey) would be a larger change to the shared credential/step machine — happy to follow up on that separately if you and the reviewer want it.

🤖 Generated with Claude Code

Addresses the review on PR langchain-ai#36 (Gemini / Vertex support).

- Pass the GCP project to ChatGoogle explicitly via
  googleAuthOptions.projectId in the gemini-enterprise branch of
  createModel(), instead of relying on ambient process.env resolution.
- Import ChatGoogle from @langchain/google/node, whose params expose
  googleAuthOptions (the default @langchain/google entrypoint types
  authOptions as never and is API-key oriented). Same package, no new
  dependency; the /node client still supports the gai/apiKey path.
- Remove the setup-time credential validation in credentials.tsx that
  mutated process.env.GOOGLE_CLOUD_PROJECT and issued a live
  testModel.invoke(["ping"]) network call during onboarding. It was the
  source of the flagged process.env mutation and added a round-trip,
  cost, and potential hang no other provider performs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ernani

ernani commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Thanks for the suggestion @ppsplus-bradh I unfortunately left for vacation but saw that things got caught up and implemented nonetheless! Glad to see this going through!

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