posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

Extend Gemini configuration options in order to allow Vertex AI authentication via googleAuthOptions

Open Tehnix opened this issue 1 month ago • 5 comments

Problem

I ran into an issue instrumenting the Gemini SDK with PostHog since I'm using Vertex AI and that doesn't support authentication via API Key, but instead via googleAuthOptions.

This config option wasn't exposed, so typescript would fail, but since all options are already passed directly into the Gemini client for initialization, it was really just a type issue and not any other code changes required.

I've extended the config options using the client's GoogleGenAIOptions, which should ensure that changes to the Gemini SDK in the future are immediately exposed and available to consumers using the @posthog/ai wrapper.

Relevant thread in the PostHog docs https://posthog.com/questions/vertex-ai-support

NOTE: https://github.com/PostHog/posthog-js/pull/2497 got closed prematurely, so this PR replaces the other one, since I cannot reopen the original one.

Changes

Extended the Gemini wrappers MonitoringGeminiConfig config with GoogleGenAIOptions which ensures all client configuration is available, and unblocks Vertex AI usage.

Release info Sub-libraries affected

Libraries affected

  • [ ] All of them
  • [ ] posthog-js (web)
  • [ ] posthog-js-lite (web lite)
  • [ ] posthog-node
  • [ ] posthog-react-native
  • [ ] @posthog/react
  • [x] @posthog/ai
  • [ ] @posthog/nextjs-config

Checklist

  • [ ] Tests for new code
  • [x] Accounted for the impact of any changes across different platforms
  • [x] Accounted for backwards compatibility of any changes (no breaking changes!)
  • [x] Took care not to unnecessarily increase the bundle size

If releasing new changes

  • [ ] Ran pnpm changeset to generate a changeset file
  • [ ] Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

Tehnix avatar Nov 24 '25 12:11 Tehnix

@PostHog/team-llm-analytics just looping you in here as well. This one is quite minor diff, but let me know if you have any questions. It's unblocked me from using Gemini with Vertex AI locally, and I've been running with it in production with LLM traces for a couple of weeks now :)

Tehnix avatar Nov 24 '25 12:11 Tehnix

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Dec 02 '25 09:12 posthog-bot

@posthog-bot yup, please don't close this!

Tehnix avatar Dec 05 '25 14:12 Tehnix

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Dec 15 '25 09:12 posthog-bot

@posthog-bot yup, please don't close this!

Tehnix avatar Dec 15 '25 12:12 Tehnix