Extend Gemini configuration options in order to allow Vertex AI authentication via googleAuthOptions
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 changesetto generate a changeset file - [ ] Added the "release" label to the PR to indicate we're publishing new versions for the affected packages
@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 :)
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 yup, please don't close this!
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 yup, please don't close this!