From e5447f8ef7bee5d9c201f062dc9c3fc110416f5d Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 17 Nov 2026 14:55:30 -0600 Subject: [PATCH 1/6] docs: propose merging VertexAI into GoogleAI(enterprise=...) --- .../proposals/merge-vertexai-into-googleai.md | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 docs/proposals/merge-vertexai-into-googleai.md diff --git a/docs/proposals/merge-vertexai-into-googleai.md b/docs/proposals/merge-vertexai-into-googleai.md new file mode 100644 index 00000000..f04c3cd8 --- /dev/null +++ b/docs/proposals/merge-vertexai-into-googleai.md @@ -0,0 +1,168 @@ +# Proposal: Merge `VertexAI` into `GoogleAI` + +**Author:** Jeff Huang · **Status:** Proposed · **Applies to:** JS, Go, Python + +## Summary + +Genkit has two plugins for Gemini: `GoogleAI` (an AI Studio API key) and `VertexAI` (a Google Cloud project). They call the same models. The only difference is which Google API serves them. + +This proposal folds them into one plugin with a switch: + +```python +GoogleAI() # AI Studio key, as today +GoogleAI(enterprise=True, project='bistro-prod', location='us-central1') # Google Cloud +``` + +Examples use Python, and file references point to the Python plugin. JS (`googleAI()`) and Go (`GoogleAI`) get the same option, spelled the way each language spells it. + +It ships in two steps: + +1. **In any 1.x release, nothing breaks:** add `enterprise=`, `project` and `location` to `GoogleAI`. `VertexAI` keeps working and logs a deprecation warning. Shipping this in Python 1.0 is nice but not required. +2. **At 2.0:** remove `VertexAI`. Old `vertexai/...` model names keep working through an alias. + +Neither step blocks Python 1.0. + +## Why + +**Going to production means rewriting model names.** A team prototypes with `googleai/gemini-2.5-flash` on an AI Studio key. Moving to their Cloud project means changing every ref to `vertexai/gemini-2.5-flash`: in code, in `.prompt` files and in eval datasets. With one plugin, they change one line of setup and the refs stay the same (except for a few model IDs that differ by backend; see below). + +**Google's own SDKs already work this way.** They use one client with a backend switch, not two clients: + +- **Python `google-genai`:** `Client(enterprise=True)`. The old `vertexai=` flag is now documented as legacy. +- **Go `genai`:** a `Backend` setting, with a new `BackendEnterprise` value. +- Both SDKs read the `GOOGLE_GENAI_USE_ENTERPRISE` env var. + +**The name keeps changing.** Vertex AI became Gemini Enterprise Agent Platform in April, then "Gemini platform" in October. A setting on `GoogleAI` holds up better than a plugin class named after the product. + +## Design + +```python +# 1. Prototype on an AI Studio key +ai = Genkit(plugins=[GoogleAI()]) + +# 2. Production on a Cloud project: same refs, same .prompt files +ai = Genkit(plugins=[GoogleAI(enterprise=True, project='bistro-prod', location='us-central1')]) + +response = await ai.generate(model='googleai/gemini-2.5-flash', prompt='Suggest a dish.') +# => runs on whichever backend the plugin was configured for + +# 3. Existing VertexAI code keeps working until 2.0 +ai = Genkit(plugins=[VertexAI(project='bistro-prod')]) +# => DeprecationWarning: VertexAI is deprecated; use GoogleAI(enterprise=True, ...) +``` + +- **`GoogleAI`, not a new class.** Most users already use `GoogleAI()` and `googleai/`, and none of that changes. Only `VertexAI` users migrate, and they have until 2.0. +- **The ref names the model, and the plugin picks the backend.** The same string works in code, `.prompt` frontmatter, the Dev UI and eval datasets. +- **Traces record the backend.** The ref no longer shows which account paid, so the backend goes in span metadata. +- **Features tied to one backend fail loudly on the other.** The plugin already does this today (`_check_backend_fields` and per-backend routing). `GoogleAI` keys those checks on `enterprise`, and the messages say how to fix it. + - **Cloud only:** Virtual Try-On, tuned Gemini endpoints, multimodal embedders, image `output_mime_type`/`output_compression_quality`, `person_generation`, `prominent_people`, `google_search_exclude_domains`/`blocking_confidence`, `safety_settings[].method`, per-request `location`, embedder `mime_type`/`auto_truncate`. + - **Developer API only:** Lyria, Deep Research, Antigravity, `file_search_*`. +- **Internals:** we pass `enterprise=` to `genai.Client`, and internal names move from `vertex` to `enterprise`. The SDK still reports the backend as `client.vertexai`, so we read it in one helper. + +## Constructor settings + +`enterprise=True` uses exactly what `VertexAI` does today, and `enterprise=False` uses exactly what `GoogleAI` does today. The merged signature is `GoogleAI`'s current parameters plus `enterprise`, `project` and `location`. + +```python +# before +VertexAI(project='bistro-prod', location='us-central1') +VertexAI(api_key=key) # Cloud express mode +GoogleAI(api_key=key) + +# after +GoogleAI(enterprise=True, project='bistro-prod', location='us-central1') +GoogleAI(enterprise=True, api_key=key) # Cloud express mode +GoogleAI(api_key=key) # unchanged +``` + +- **`enterprise=True`:** + - `project`: the argument, then `GCLOUD_PROJECT` / `GOOGLE_CLOUD_PROJECT`, then `credentials.project_id`, then the ADC project. + - `location`: the argument, then `GOOGLE_CLOUD_LOCATION` / `GCLOUD_LOCATION`, then `us-central1`. Multi-regions keep their dedicated endpoints. + - Express mode only with an explicit `api_key=`. Environment keys stay ignored, as they are today, so an AI Studio `GEMINI_API_KEY` never quietly becomes a Cloud key. +- **`enterprise=False`:** the key comes from `api_key`, then `GEMINI_API_KEY`, then `GOOGLE_API_KEY`. Passing `project` or `location` raises a `ValueError` at setup. + +## What still differs between backends + +The namespace and refs stay the same, but some model IDs differ by backend: + +- **Veo:** the IDs don't overlap. The Developer API uses `veo-3.1-generate-preview`, and Cloud uses `veo-3.1-generate-001`. +- **Gemini:** most names are shared. The `-latest` aliases (`gemini-flash-latest`, …) exist only on the Developer API. +- **Known-name lists** on `GoogleAI.gemini()` / `.veo()` become the union of both backends. A name the configured backend doesn't serve fails at lookup, and the error names the backend. + +## Interactions API + +**Background.** Gemini can be called through two Google APIs: + +- **`generateContent`:** the older API. Each request sends the full conversation and gets a response back. +- **The Interactions API:** the newer one (`/interactions`). Google's agent-style models are built on it (Deep Research, Antigravity), and it adds things like server-side `store` and background runs. Gemini is moving to it. + +Users don't pick between them. `ai.generate(...)` looks the same either way, and the plugin chooses the API for each model. + +**Where each SDK is:** + +- **JS:** newer Gemini models on both `googleAI` and `vertexAI` already use Interactions (since [genkit#6851](https://github.com/genkit-ai/genkit/pull/6851)). Older Gemini, image models and tuned endpoints stay on `generateContent`. +- **Python:** Gemini, Gemma, Imagen, Veo and embedders still use `generateContent`. Only Deep Research, Antigravity and Lyria use Interactions, and only on the Developer API. The migration is in progress: [genkit-python#78](https://github.com/genkit-ai/genkit-python/pull/78), then [#105](https://github.com/genkit-ai/genkit-python/pull/105), then a follow-up that moves Gemini onto Interactions. It uses the plugin's own HTTP client and wire types rather than the SDK's, matching JS and Dart. + +**Why it matters here.** After the migration, the plugin has two code paths: `genai.Client` for `generateContent` models and its own client for Interactions models. Both APIs exist on both backends: + +- **Interactions, Developer API:** `v1beta/interactions`, authenticated with an API key. +- **Interactions, Cloud:** `v1beta1/projects/{p}/locations/{l}/interactions`, authenticated with OAuth. Express mode uses `locations/global/interactions`. +- **What differs:** the request body is the same, apart from a few field rules (Cloud rejects `top_k`, and Cloud Interactions doesn't serve image models). + +So `enterprise=` has to reach both code paths. Otherwise, `GoogleAI(enterprise=True)` could send Imagen calls to Cloud while Gemini calls still go to the Developer API. Gemini on Interactions works with either value. + +**The ask for the Interactions work:** the Cloud Interactions client should choose its URL and auth from a backend value passed in, not from the plugin class, and the request function should take credentials instead of assuming an API key. That's the same amount of work now. `GoogleAI(enterprise=...)` then just connects the setting; nothing has to be moved out of `VertexAI`. + +## At 2.0: the `vertexai/` alias + +When `VertexAI` is removed, no plugin is named `vertexai`. The registry picks a plugin from the text before the first `/`, so `vertexai/gemini-2.5-flash` would never reach `GoogleAI` and would come back as a generic not-found. The core change is to let a plugin claim older namespace names: + +```python +class GoogleAI(Plugin): + name = 'googleai' + legacy_namespaces = ('vertexai',) # new, in genkit.plugin_api + +await ai.generate(model='vertexai/gemini-2.5-flash', prompt='Suggest a dish.') +# => with enterprise=True: same action as googleai/gemini-2.5-flash +# => otherwise: GenkitError: NOT_FOUND, 'vertexai/gemini-2.5-flash' needs GoogleAI(enterprise=True) +``` + +- **Routing:** `vertexai/...` goes to `GoogleAI.resolve`, and the plugin is told which name was used. The backend check lives in the plugin, not in core. +- **Naming:** the resolved action is stored and traced under `googleai/...`. Today the registry names an action after whatever string was asked for. +- **Dev UI:** the model list doesn't show the alias, so models don't appear twice. +- **Cost:** new API for plugin authors, and JS and Go need the same thing at their own 2.0. + +## What we give up at 2.0 + +- **Both backends in one app.** Until 2.0, `GoogleAI()` plus `VertexAI()` keeps working. After 2.0, two `GoogleAI` plugins collide on `googleai/`, and the registry raises at startup. We'd make that message name the fix. I expect this is rare, but we have no usage data. +- **A possible follow-up that doesn't break anyone:** a per-request backend override, if those apps show up. It's not part of this proposal. Config is merged from the ref, the `.prompt` file and the call, and middleware can rewrite it, so putting billing routing in config needs its own design. Background `Operation`s would also have to record their backend. + +## Cross-SDK risk + +Until JS and Go ship `enterprise=`, `googleai/gemini-2.5-flash` in a `.prompt` file means the Developer API in JS and Go but can mean Cloud in Python. The same file would bill a different account depending on which SDK loads it. In the additive phase, that only affects users who opt in with `enterprise=True`, but JS and Go should follow soon. + +## Plan + +1. **Now:** + - Agree the Cloud Interactions transport shape with the Interactions migration owner. + - Get sign-off on this proposal. + - Merge [genkit-python#137](https://github.com/genkit-ai/genkit-python/pull/137), the Model Garden rename. It doesn't depend on this proposal, but it is breaking, so it needs to land before Python 1.0. +2. **The Python Interactions stack lands:** [#78](https://github.com/genkit-ai/genkit-python/pull/78), then [#105](https://github.com/genkit-ai/genkit-python/pull/105), then Gemini on Interactions with the Cloud transport. +3. **`GoogleAI(enterprise=...)`**, any 1.x release (ideally 1.0), stacked on the Interactions work: + - the `enterprise`, `project` and `location` parameters; + - `enterprise=` passed to the SDK client; + - backend-specific checks keyed on `enterprise`; + - the backend in traces; + - internal renames; + - the `VertexAI` deprecation warning. + + Additive. +4. **JS and Go:** the same additive change whenever they're ready. +5. **At 2.0, in each SDK:** core namespace aliases, then remove `VertexAI` and register the `vertexai/` alias. + +## Open questions + +1. **Is `enterprise` the long-term name?** The flag follows "Gemini Enterprise Agent Platform", a brand developer marketing has already moved away from. Can we confirm with the `google-genai` team, and is JS `@google/genai` moving too? +2. **Flag name in Genkit:** mirror each SDK (`enterprise=` in Python, a backend enum in Go), or use one brand-neutral `backend=` Literal everywhere? +3. **The environment variable:** should `GoogleAI()` honor `GOOGLE_GENAI_USE_ENTERPRISE` when `enterprise=` isn't passed? Honoring it lets deployment config switch the backend without code changes. Ignoring it avoids a switch caused by a variable set for some other tool. An explicit `enterprise=` wins either way. I lean toward honoring it and logging the chosen backend once. +4. **How long the alias lives after 2.0:** one major version, or for good? From be2001fe2e8649c65c10505cd09c12af4c7af414 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 17 Nov 2026 14:58:00 -0600 Subject: [PATCH 2/6] docs: scope the VertexAI proposal to Python --- .../proposals/merge-vertexai-into-googleai.md | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/docs/proposals/merge-vertexai-into-googleai.md b/docs/proposals/merge-vertexai-into-googleai.md index f04c3cd8..216e5a58 100644 --- a/docs/proposals/merge-vertexai-into-googleai.md +++ b/docs/proposals/merge-vertexai-into-googleai.md @@ -1,10 +1,10 @@ # Proposal: Merge `VertexAI` into `GoogleAI` -**Author:** Jeff Huang · **Status:** Proposed · **Applies to:** JS, Go, Python +**Author:** Jeff Huang · **Status:** Proposed · **Applies to:** `genkit-google-genai` (Python) ## Summary -Genkit has two plugins for Gemini: `GoogleAI` (an AI Studio API key) and `VertexAI` (a Google Cloud project). They call the same models. The only difference is which Google API serves them. +`genkit-google-genai` has two plugins for Gemini: `GoogleAI` (an AI Studio API key) and `VertexAI` (a Google Cloud project). They call the same models. The only difference is which Google API serves them. This proposal folds them into one plugin with a switch: @@ -13,8 +13,6 @@ GoogleAI() # AI Studio k GoogleAI(enterprise=True, project='bistro-prod', location='us-central1') # Google Cloud ``` -Examples use Python, and file references point to the Python plugin. JS (`googleAI()`) and Go (`GoogleAI`) get the same option, spelled the way each language spells it. - It ships in two steps: 1. **In any 1.x release, nothing breaks:** add `enterprise=`, `project` and `location` to `GoogleAI`. `VertexAI` keeps working and logs a deprecation warning. Shipping this in Python 1.0 is nice but not required. @@ -26,11 +24,7 @@ Neither step blocks Python 1.0. **Going to production means rewriting model names.** A team prototypes with `googleai/gemini-2.5-flash` on an AI Studio key. Moving to their Cloud project means changing every ref to `vertexai/gemini-2.5-flash`: in code, in `.prompt` files and in eval datasets. With one plugin, they change one line of setup and the refs stay the same (except for a few model IDs that differ by backend; see below). -**Google's own SDKs already work this way.** They use one client with a backend switch, not two clients: - -- **Python `google-genai`:** `Client(enterprise=True)`. The old `vertexai=` flag is now documented as legacy. -- **Go `genai`:** a `Backend` setting, with a new `BackendEnterprise` value. -- Both SDKs read the `GOOGLE_GENAI_USE_ENTERPRISE` env var. +**The SDK underneath already works this way.** `google-genai` uses one client with a backend switch, not two clients: `Client(enterprise=True)`, with the old `vertexai=` flag documented as legacy and a `GOOGLE_GENAI_USE_ENTERPRISE` env var. (Go's `genai` SDK made the same change, with a `BackendEnterprise` value.) **The name keeps changing.** Vertex AI became Gemini Enterprise Agent Platform in April, then "Gemini platform" in October. A setting on `GoogleAI` holds up better than a plugin class named after the product. @@ -98,10 +92,7 @@ The namespace and refs stay the same, but some model IDs differ by backend: Users don't pick between them. `ai.generate(...)` looks the same either way, and the plugin chooses the API for each model. -**Where each SDK is:** - -- **JS:** newer Gemini models on both `googleAI` and `vertexAI` already use Interactions (since [genkit#6851](https://github.com/genkit-ai/genkit/pull/6851)). Older Gemini, image models and tuned endpoints stay on `generateContent`. -- **Python:** Gemini, Gemma, Imagen, Veo and embedders still use `generateContent`. Only Deep Research, Antigravity and Lyria use Interactions, and only on the Developer API. The migration is in progress: [genkit-python#78](https://github.com/genkit-ai/genkit-python/pull/78), then [#105](https://github.com/genkit-ai/genkit-python/pull/105), then a follow-up that moves Gemini onto Interactions. It uses the plugin's own HTTP client and wire types rather than the SDK's, matching JS and Dart. +**Where the plugin is today:** Gemini, Gemma, Imagen, Veo and embedders still use `generateContent`. Only Deep Research, Antigravity and Lyria use Interactions, and only on the Developer API. The migration is in progress: [genkit-python#78](https://github.com/genkit-ai/genkit-python/pull/78), then [#105](https://github.com/genkit-ai/genkit-python/pull/105), then a follow-up that moves Gemini onto Interactions, the same split the JS plugin already uses ([genkit#6851](https://github.com/genkit-ai/genkit/pull/6851)). It uses the plugin's own HTTP client and wire types rather than the SDK's. **Why it matters here.** After the migration, the plugin has two code paths: `genai.Client` for `generateContent` models and its own client for Interactions models. Both APIs exist on both backends: @@ -130,16 +121,16 @@ await ai.generate(model='vertexai/gemini-2.5-flash', prompt='Suggest a dish.') - **Routing:** `vertexai/...` goes to `GoogleAI.resolve`, and the plugin is told which name was used. The backend check lives in the plugin, not in core. - **Naming:** the resolved action is stored and traced under `googleai/...`. Today the registry names an action after whatever string was asked for. - **Dev UI:** the model list doesn't show the alias, so models don't appear twice. -- **Cost:** new API for plugin authors, and JS and Go need the same thing at their own 2.0. +- **Cost:** new public API in `genkit.plugin_api` for plugin authors. ## What we give up at 2.0 - **Both backends in one app.** Until 2.0, `GoogleAI()` plus `VertexAI()` keeps working. After 2.0, two `GoogleAI` plugins collide on `googleai/`, and the registry raises at startup. We'd make that message name the fix. I expect this is rare, but we have no usage data. - **A possible follow-up that doesn't break anyone:** a per-request backend override, if those apps show up. It's not part of this proposal. Config is merged from the ref, the `.prompt` file and the call, and middleware can rewrite it, so putting billing routing in config needs its own design. Background `Operation`s would also have to record their backend. -## Cross-SDK risk +## Other SDKs -Until JS and Go ship `enterprise=`, `googleai/gemini-2.5-flash` in a `.prompt` file means the Developer API in JS and Go but can mean Cloud in Python. The same file would bill a different account depending on which SDK loads it. In the additive phase, that only affects users who opt in with `enterprise=True`, but JS and Go should follow soon. +This proposal covers Python only. One thing to flag for JS and Go: `.prompt` files are shared across SDKs, so with `GoogleAI(enterprise=True)` in Python, `googleai/gemini-2.5-flash` runs on Cloud in Python but on the Developer API in JS and Go. It only affects users who opt in, but JS and Go may want the same option eventually. ## Plan @@ -157,12 +148,11 @@ Until JS and Go ship `enterprise=`, `googleai/gemini-2.5-flash` in a `.prompt` f - the `VertexAI` deprecation warning. Additive. -4. **JS and Go:** the same additive change whenever they're ready. -5. **At 2.0, in each SDK:** core namespace aliases, then remove `VertexAI` and register the `vertexai/` alias. +4. **At 2.0:** core namespace aliases, then remove `VertexAI` and register the `vertexai/` alias. ## Open questions -1. **Is `enterprise` the long-term name?** The flag follows "Gemini Enterprise Agent Platform", a brand developer marketing has already moved away from. Can we confirm with the `google-genai` team, and is JS `@google/genai` moving too? -2. **Flag name in Genkit:** mirror each SDK (`enterprise=` in Python, a backend enum in Go), or use one brand-neutral `backend=` Literal everywhere? +1. **Is `enterprise` the long-term name?** The flag follows "Gemini Enterprise Agent Platform", a brand developer marketing has already moved away from. Can we confirm with the `google-genai` team? +2. **Flag name:** mirror the SDK's `enterprise=`, or use a brand-neutral `backend=` Literal? 3. **The environment variable:** should `GoogleAI()` honor `GOOGLE_GENAI_USE_ENTERPRISE` when `enterprise=` isn't passed? Honoring it lets deployment config switch the backend without code changes. Ignoring it avoids a switch caused by a variable set for some other tool. An explicit `enterprise=` wins either way. I lean toward honoring it and logging the chosen backend once. 4. **How long the alias lives after 2.0:** one major version, or for good? From 2c52e5f0fed1fcd90e3cd0ec4e5b77c60a500df2 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 17 Nov 2026 15:43:02 -0600 Subject: [PATCH 3/6] docs: narrow the VertexAI proposal's open questions The SDK backend env vars stay ignored, as today, since the plugin always passes the flag; that is now stated under constructor settings. Alias lifetime moves to the 2.0 step. The open questions are the direction, the flag name, losing both backends in one app, and sequencing with the Interactions stack. --- docs/proposals/merge-vertexai-into-googleai.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/proposals/merge-vertexai-into-googleai.md b/docs/proposals/merge-vertexai-into-googleai.md index 216e5a58..ee923779 100644 --- a/docs/proposals/merge-vertexai-into-googleai.md +++ b/docs/proposals/merge-vertexai-into-googleai.md @@ -74,6 +74,7 @@ GoogleAI(api_key=key) # unchanged - `location`: the argument, then `GOOGLE_CLOUD_LOCATION` / `GCLOUD_LOCATION`, then `us-central1`. Multi-regions keep their dedicated endpoints. - Express mode only with an explicit `api_key=`. Environment keys stay ignored, as they are today, so an AI Studio `GEMINI_API_KEY` never quietly becomes a Cloud key. - **`enterprise=False`:** the key comes from `api_key`, then `GEMINI_API_KEY`, then `GOOGLE_API_KEY`. Passing `project` or `location` raises a `ValueError` at setup. +- **Only `enterprise=` picks the backend.** The SDK reads `GOOGLE_GENAI_USE_ENTERPRISE` and `GOOGLE_GENAI_USE_VERTEXAI` only when no flag is passed. The plugin always passes one, so both variables stay ignored, as they are today. A variable set for some other tool can't move an app to a different billing account. ## What still differs between backends @@ -148,11 +149,11 @@ This proposal covers Python only. One thing to flag for JS and Go: `.prompt` fil - the `VertexAI` deprecation warning. Additive. -4. **At 2.0:** core namespace aliases, then remove `VertexAI` and register the `vertexai/` alias. +4. **At 2.0:** core namespace aliases, then remove `VertexAI` and register the `vertexai/` alias. How long the alias lives is decided then. ## Open questions -1. **Is `enterprise` the long-term name?** The flag follows "Gemini Enterprise Agent Platform", a brand developer marketing has already moved away from. Can we confirm with the `google-genai` team? -2. **Flag name:** mirror the SDK's `enterprise=`, or use a brand-neutral `backend=` Literal? -3. **The environment variable:** should `GoogleAI()` honor `GOOGLE_GENAI_USE_ENTERPRISE` when `enterprise=` isn't passed? Honoring it lets deployment config switch the backend without code changes. Ignoring it avoids a switch caused by a variable set for some other tool. An explicit `enterprise=` wins either way. I lean toward honoring it and logging the chosen backend once. -4. **How long the alias lives after 2.0:** one major version, or for good? +1. **The direction:** one `GoogleAI` plugin with a backend switch, `VertexAI` deprecated in 1.x and removed at 2.0. +2. **The flag name:** mirror the SDK's `enterprise=`, or use a brand-neutral `backend=` Literal. `enterprise=` matches `genai.Client`. `backend=` survives the next rename, and the product has already moved past "Gemini Enterprise Agent Platform". Worth checking with the `google-genai` team which way their flag is headed. +3. **Dropping both backends in one app at 2.0:** is losing `GoogleAI()` plus `VertexAI()` side by side acceptable without usage data? If not, the per-request override under [What we give up at 2.0](#what-we-give-up-at-20) needs a design before 2.0. +4. **Sequencing with the Interactions stack:** `enterprise=` is stacked on #78, then #105, then Gemini on Interactions, and needs the Cloud Interactions client to take the backend as a value. Shipping it in 1.0 depends on the Interactions owner agreeing to that shape and landing in time. Otherwise it ships in a later 1.x. From 7c15511001b9e0345456ef7a6c8bf2c49ea53fe4 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 17 Nov 2026 15:44:10 -0600 Subject: [PATCH 4/6] docs: drop the both-backends open question from the VertexAI proposal --- docs/proposals/merge-vertexai-into-googleai.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/proposals/merge-vertexai-into-googleai.md b/docs/proposals/merge-vertexai-into-googleai.md index ee923779..d82fe4fb 100644 --- a/docs/proposals/merge-vertexai-into-googleai.md +++ b/docs/proposals/merge-vertexai-into-googleai.md @@ -155,5 +155,4 @@ This proposal covers Python only. One thing to flag for JS and Go: `.prompt` fil 1. **The direction:** one `GoogleAI` plugin with a backend switch, `VertexAI` deprecated in 1.x and removed at 2.0. 2. **The flag name:** mirror the SDK's `enterprise=`, or use a brand-neutral `backend=` Literal. `enterprise=` matches `genai.Client`. `backend=` survives the next rename, and the product has already moved past "Gemini Enterprise Agent Platform". Worth checking with the `google-genai` team which way their flag is headed. -3. **Dropping both backends in one app at 2.0:** is losing `GoogleAI()` plus `VertexAI()` side by side acceptable without usage data? If not, the per-request override under [What we give up at 2.0](#what-we-give-up-at-20) needs a design before 2.0. -4. **Sequencing with the Interactions stack:** `enterprise=` is stacked on #78, then #105, then Gemini on Interactions, and needs the Cloud Interactions client to take the backend as a value. Shipping it in 1.0 depends on the Interactions owner agreeing to that shape and landing in time. Otherwise it ships in a later 1.x. +3. **Sequencing with the Interactions stack:** `enterprise=` is stacked on #78, then #105, then Gemini on Interactions, and needs the Cloud Interactions client to take the backend as a value. Shipping it in 1.0 depends on the Interactions owner agreeing to that shape and landing in time. Otherwise it ships in a later 1.x. From 6fb07ce28a419b78c213322be6074843049597b2 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 17 Nov 2026 16:28:02 -0600 Subject: [PATCH 5/6] docs: propose one GoogleGenAI plugin with a required enterprise flag before 1.0 Replaces the merge-into-GoogleAI proposal with the shape agreed with the JS owner: one GoogleGenAI plugin named after the package, enterprise= required and set on the plugin only, models under googlegenai/. GoogleAI and VertexAI are removed before Python 1.0 instead of deprecated, so no 2.0 alias work is needed. One open question remains: whether googleai/ and vertexai/ refs in shared .prompt files resolve as aliases. --- docs/proposals/googlegenai-plugin.md | 149 +++++++++++++++++ .../proposals/merge-vertexai-into-googleai.md | 158 ------------------ 2 files changed, 149 insertions(+), 158 deletions(-) create mode 100644 docs/proposals/googlegenai-plugin.md delete mode 100644 docs/proposals/merge-vertexai-into-googleai.md diff --git a/docs/proposals/googlegenai-plugin.md b/docs/proposals/googlegenai-plugin.md new file mode 100644 index 00000000..3ff734fd --- /dev/null +++ b/docs/proposals/googlegenai-plugin.md @@ -0,0 +1,149 @@ +# Proposal: One `GoogleGenAI` plugin with a required `enterprise=` flag + +**Author:** Jeff Huang · **Status:** Proposed · **Applies to:** `genkit-google-genai` (Python), before 1.0 + +## Summary + +`genkit-google-genai` has two plugins for Gemini: `GoogleAI` (an AI Studio API key) and `VertexAI` (a Google Cloud project). They call the same models. The only difference is which Google API serves them. + +This proposal replaces both with one plugin, named after the package, before Python 1.0: + +```python +GoogleGenAI(enterprise=False) # AI Studio key +GoogleGenAI(enterprise=True, project='bistro-prod', location='us-central1') # Google Cloud +GoogleGenAI() +# => TypeError: missing required keyword argument 'enterprise' +``` + +`GoogleAI` and `VertexAI` are removed, not deprecated. Python 1.0 ships with `GoogleGenAI` only, so there's no deprecation path to carry and no alias machinery to build. + +## Why + +**Going to production shouldn't mean rewriting model names.** Today a team prototypes with `googleai/gemini-2.5-flash` on an AI Studio key. Moving to their Cloud project means changing every ref to `vertexai/gemini-2.5-flash`: in code, in `.prompt` files and in eval datasets. With one plugin, they flip one flag at setup and the refs stay the same. + +**The package name outlives the product name.** Vertex AI became Gemini Enterprise Agent Platform in April, then "Gemini platform" in October. `google-genai` is the package name on PyPI and npm, and the name of the SDK underneath. A plugin named after it doesn't move when marketing does. + +**The SDK underneath already works this way.** `google-genai` uses one client with a backend switch: `Client(enterprise=True)`, with `vertexai=` documented as legacy. + +**Before 1.0 is the cheap time to do it.** After 1.0, removing `GoogleAI` and `VertexAI` needs a deprecation cycle, a `vertexai/` alias in core, and a 2.0. Before 1.0 it's a rename. + +## Design + +```python +# 1. Prototype on an AI Studio key +ai = Genkit(plugins=[GoogleGenAI(enterprise=False)]) + +# 2. Production on a Cloud project: same refs, same .prompt files +ai = Genkit(plugins=[GoogleGenAI(enterprise=True, project='bistro-prod', location='us-central1')]) + +# 3. One ref helper; the plugin decides the backend +response = await ai.generate(model=GoogleGenAI.gemini('gemini-2.5-flash'), prompt='Suggest a dish.') +# => runs on whichever backend the plugin was configured for + +# 4. A model the configured backend doesn't serve fails at lookup +await ai.generate(model=GoogleGenAI.virtual_try_on('virtual-try-on-001'), ...) # with enterprise=False +# => GenkitError: NOT_FOUND, 'googlegenai/virtual-try-on-001' needs GoogleGenAI(enterprise=True) +``` + +- **`enterprise=` is required, keyword-only, with no default.** Picking a billing account is a deliberate choice. Leaving it out is a `TypeError` on the user's own line. +- **The backend is set on the plugin only.** It isn't in `GeminiConfig` or any model config. Config is merged from the ref, the `.prompt` file and the call, and middleware can rewrite it, so a config field would let any of those move an app to a different billing account. It also couldn't work: `resolve()` and the Dev UI model list run before any request exists, and need to know the backend to know which models exist. +- **One namespace: `googlegenai/`.** Typed refs are classmethods (`GoogleGenAI.gemini('x')`). They run without a plugin instance, so they can't know the backend and need one fixed prefix. The ref names the model; the plugin picks the backend. +- **Traces record the backend.** The ref no longer shows which account paid, so the backend goes in span metadata. +- **One app, one backend.** Two `GoogleGenAI` plugins collide on `googlegenai/`, and the registry raises at startup, with a message that says so. Running `GoogleAI()` and `VertexAI()` side by side, as you can today, is no longer supported. We accept that. + +## How it's built + +The request code is already shared. `GoogleAI` and `VertexAI` build the same Gemini, Veo and embedder model classes, and those read the backend off the `genai.Client` they're handed (`_is_vertex()` returns `client.vertexai`). That one flag already picks the endpoint and auth, and `_check_backend_fields` already rejects the other backend's config fields before anything is sent. + +What's split today is the two plugin classes (~500 lines each): setup and auth, which models `resolve()` and `list_actions()` offer, and the typed ref classmethods. `GoogleGenAI` folds those into one class, keyed on `enterprise`: + +- **Setup and auth** pick the `GoogleAI` or `VertexAI` path from the flag. +- **`resolve()` and `list_actions()`** serve the catalog for the configured backend. A backend-only model on the wrong backend gets a `NOT_FOUND` that names the backend, instead of today's generic not-found. +- **Typed refs** all live on `GoogleGenAI`: `.gemini()`, `.gemini_tts()`, `.gemini_image()`, `.gemma()`, `.veo()`, `.embedder()`, `.deep_research()`, `.antigravity()`, `.lyria()`, `.virtual_try_on()`. Known-name lists become the union of both backends. +- **Internals:** we pass `enterprise=` to `genai.Client`, and internal names move from `vertex` to `enterprise`. + +## Constructor settings + +`enterprise=True` uses exactly what `VertexAI` does today, and `enterprise=False` uses exactly what `GoogleAI` does today. + +```python +# before +GoogleAI(api_key=key) +VertexAI(project='bistro-prod', location='us-central1') +VertexAI(api_key=key) # Cloud express mode + +# after +GoogleGenAI(enterprise=False, api_key=key) +GoogleGenAI(enterprise=True, project='bistro-prod', location='us-central1') +GoogleGenAI(enterprise=True, api_key=key) # Cloud express mode +``` + +- **`enterprise=True`:** + - `project`: the argument, then `GCLOUD_PROJECT` / `GOOGLE_CLOUD_PROJECT`, then `credentials.project_id`, then the ADC project. + - `location`: the argument, then `GOOGLE_CLOUD_LOCATION` / `GCLOUD_LOCATION`, then `us-central1`. Multi-regions keep their dedicated endpoints. + - Express mode only with an explicit `api_key=`. Environment keys stay ignored, as they are today, so an AI Studio `GEMINI_API_KEY` never quietly becomes a Cloud key. +- **`enterprise=False`:** the key comes from `api_key`, then `GEMINI_API_KEY`, then `GOOGLE_API_KEY`. Passing `project` or `location` raises a `ValueError` at setup. +- **Only `enterprise=` picks the backend.** The SDK reads `GOOGLE_GENAI_USE_ENTERPRISE` and `GOOGLE_GENAI_USE_VERTEXAI` only when no flag is passed. The plugin always passes one, so both variables stay ignored, as they are today. + +## What differs between backends + +The refs stay the same, but what each backend serves doesn't: + +- **Developer API only:** Lyria, Deep Research, Antigravity, `file_search_*`. +- **Cloud only:** Virtual Try-On, tuned Gemini endpoints, multimodal embedders, image `output_mime_type`/`output_compression_quality`, `person_generation`, `prominent_people`, `google_search_exclude_domains`/`blocking_confidence`, `safety_settings[].method`, per-request `location`, embedder `mime_type`/`auto_truncate`. +- **Veo:** the IDs don't overlap. The Developer API uses `veo-3.1-generate-preview`, and Cloud uses `veo-3.1-generate-001`. +- **Gemini:** most names are shared. The `-latest` aliases (`gemini-flash-latest`, …) exist only on the Developer API. + +A backend-only model fails at lookup, and a backend-only config field fails before the request is sent. Both errors name the backend and the fix. + +## Interactions API + +Gemini can be called through `generateContent` (each request sends the full conversation) or the newer Interactions API (`/interactions`, with server-side `store` and background runs). Users don't pick between them; the plugin chooses per model. + +Today only Deep Research, Antigravity and Lyria use Interactions, through the plugin's own client, and only on the Developer API. That doesn't block this proposal: with `enterprise=True`, those models simply aren't offered, the same as on `VertexAI` today. + +It matters when Gemini itself moves onto Interactions, after [#78](https://github.com/genkit-ai/genkit-python/pull/78) and [#105](https://github.com/genkit-ai/genkit-python/pull/105). Cloud serves Interactions at `v1beta1/projects/{p}/locations/{l}/interactions` with OAuth (express mode: `locations/global/interactions`), and rejects `top_k` and image models there. So the ask for that work: the Interactions client takes the backend and credentials as values passed in, not inferred from the plugin class. Then `GoogleGenAI` wires `enterprise=` into both code paths, and the two code paths can't end up on different backends. + +## Migration + +Python is pre-1.0, so this is a breaking rename with a release note: + +```python +# before +from genkit_google_genai import GoogleAI, VertexAI +ai = Genkit(plugins=[GoogleAI()]) +await ai.generate(model=GoogleAI.gemini('gemini-2.5-flash'), prompt='...') +await ai.generate(model='googleai/gemini-2.5-flash', prompt='...') + +# after +from genkit_google_genai import GoogleGenAI +ai = Genkit(plugins=[GoogleGenAI(enterprise=False)]) +await ai.generate(model=GoogleGenAI.gemini('gemini-2.5-flash'), prompt='...') +await ai.generate(model='googlegenai/gemini-2.5-flash', prompt='...') +``` + +In this repo, that's about 100 references to `GoogleAI`/`VertexAI` outside the plugin, 83 `googleai/` or `vertexai/` ref strings, and 3 `.prompt` files, mostly samples. It's mechanical. + +## Other SDKs + +This proposal covers Python. JS agreed on the same shape for JS 2.0: one `googleGenAI` plugin with a required `enterprise` flag. In JS, the parent can hold the existing `googleAI` or `vertexAI` plugin internally and delegate to it, so the change there is a layer on top rather than a rewrite. + +One thing to keep in step: `.prompt` files are shared across SDKs, so the namespace string has to match. If Python registers `googlegenai/`, JS 2.0 and Go should too. A JS parent that delegates to its inner plugin should still register its models under `googlegenai/`, not `googleai/` or `vertexai/`. + +## Plan + +1. **Now:** sign-off on this proposal from Python and JS owners. +2. **Before Python 1.0, one PR:** + - `GoogleGenAI` with required `enterprise`, `project` and `location`; + - catalog and `resolve()` keyed on `enterprise`, with backend-named `NOT_FOUND`; + - the backend in span metadata; + - remove `GoogleAI` and `VertexAI` exports; + - update samples, READMEs and `.prompt` files. +3. **Independent:** [genkit-python#137](https://github.com/genkit-ai/genkit-python/pull/137), the Model Garden rename. It's also breaking, so it lands before 1.0 too. +4. **After #78 and #105:** Gemini on Interactions, with the Cloud transport taking the backend as a value. + +## Open question + +1. **`.prompt` files that still say `googleai/` or `vertexai/`.** Until JS and Go ship their major versions, a `.prompt` file written for them won't resolve in Python 1.0. + - **No aliases:** these refs return `NOT_FOUND`. Clean, and the release note covers it, but shared `.prompt` files break until the other SDKs catch up. + - **Aliases:** Python resolves `googleai/` when `enterprise=False` and `vertexai/` when `enterprise=True`, to the same `googlegenai/` action. Shared files keep working, at the cost of a small core hook (plugins claiming extra namespace names) before 1.0. diff --git a/docs/proposals/merge-vertexai-into-googleai.md b/docs/proposals/merge-vertexai-into-googleai.md deleted file mode 100644 index d82fe4fb..00000000 --- a/docs/proposals/merge-vertexai-into-googleai.md +++ /dev/null @@ -1,158 +0,0 @@ -# Proposal: Merge `VertexAI` into `GoogleAI` - -**Author:** Jeff Huang · **Status:** Proposed · **Applies to:** `genkit-google-genai` (Python) - -## Summary - -`genkit-google-genai` has two plugins for Gemini: `GoogleAI` (an AI Studio API key) and `VertexAI` (a Google Cloud project). They call the same models. The only difference is which Google API serves them. - -This proposal folds them into one plugin with a switch: - -```python -GoogleAI() # AI Studio key, as today -GoogleAI(enterprise=True, project='bistro-prod', location='us-central1') # Google Cloud -``` - -It ships in two steps: - -1. **In any 1.x release, nothing breaks:** add `enterprise=`, `project` and `location` to `GoogleAI`. `VertexAI` keeps working and logs a deprecation warning. Shipping this in Python 1.0 is nice but not required. -2. **At 2.0:** remove `VertexAI`. Old `vertexai/...` model names keep working through an alias. - -Neither step blocks Python 1.0. - -## Why - -**Going to production means rewriting model names.** A team prototypes with `googleai/gemini-2.5-flash` on an AI Studio key. Moving to their Cloud project means changing every ref to `vertexai/gemini-2.5-flash`: in code, in `.prompt` files and in eval datasets. With one plugin, they change one line of setup and the refs stay the same (except for a few model IDs that differ by backend; see below). - -**The SDK underneath already works this way.** `google-genai` uses one client with a backend switch, not two clients: `Client(enterprise=True)`, with the old `vertexai=` flag documented as legacy and a `GOOGLE_GENAI_USE_ENTERPRISE` env var. (Go's `genai` SDK made the same change, with a `BackendEnterprise` value.) - -**The name keeps changing.** Vertex AI became Gemini Enterprise Agent Platform in April, then "Gemini platform" in October. A setting on `GoogleAI` holds up better than a plugin class named after the product. - -## Design - -```python -# 1. Prototype on an AI Studio key -ai = Genkit(plugins=[GoogleAI()]) - -# 2. Production on a Cloud project: same refs, same .prompt files -ai = Genkit(plugins=[GoogleAI(enterprise=True, project='bistro-prod', location='us-central1')]) - -response = await ai.generate(model='googleai/gemini-2.5-flash', prompt='Suggest a dish.') -# => runs on whichever backend the plugin was configured for - -# 3. Existing VertexAI code keeps working until 2.0 -ai = Genkit(plugins=[VertexAI(project='bistro-prod')]) -# => DeprecationWarning: VertexAI is deprecated; use GoogleAI(enterprise=True, ...) -``` - -- **`GoogleAI`, not a new class.** Most users already use `GoogleAI()` and `googleai/`, and none of that changes. Only `VertexAI` users migrate, and they have until 2.0. -- **The ref names the model, and the plugin picks the backend.** The same string works in code, `.prompt` frontmatter, the Dev UI and eval datasets. -- **Traces record the backend.** The ref no longer shows which account paid, so the backend goes in span metadata. -- **Features tied to one backend fail loudly on the other.** The plugin already does this today (`_check_backend_fields` and per-backend routing). `GoogleAI` keys those checks on `enterprise`, and the messages say how to fix it. - - **Cloud only:** Virtual Try-On, tuned Gemini endpoints, multimodal embedders, image `output_mime_type`/`output_compression_quality`, `person_generation`, `prominent_people`, `google_search_exclude_domains`/`blocking_confidence`, `safety_settings[].method`, per-request `location`, embedder `mime_type`/`auto_truncate`. - - **Developer API only:** Lyria, Deep Research, Antigravity, `file_search_*`. -- **Internals:** we pass `enterprise=` to `genai.Client`, and internal names move from `vertex` to `enterprise`. The SDK still reports the backend as `client.vertexai`, so we read it in one helper. - -## Constructor settings - -`enterprise=True` uses exactly what `VertexAI` does today, and `enterprise=False` uses exactly what `GoogleAI` does today. The merged signature is `GoogleAI`'s current parameters plus `enterprise`, `project` and `location`. - -```python -# before -VertexAI(project='bistro-prod', location='us-central1') -VertexAI(api_key=key) # Cloud express mode -GoogleAI(api_key=key) - -# after -GoogleAI(enterprise=True, project='bistro-prod', location='us-central1') -GoogleAI(enterprise=True, api_key=key) # Cloud express mode -GoogleAI(api_key=key) # unchanged -``` - -- **`enterprise=True`:** - - `project`: the argument, then `GCLOUD_PROJECT` / `GOOGLE_CLOUD_PROJECT`, then `credentials.project_id`, then the ADC project. - - `location`: the argument, then `GOOGLE_CLOUD_LOCATION` / `GCLOUD_LOCATION`, then `us-central1`. Multi-regions keep their dedicated endpoints. - - Express mode only with an explicit `api_key=`. Environment keys stay ignored, as they are today, so an AI Studio `GEMINI_API_KEY` never quietly becomes a Cloud key. -- **`enterprise=False`:** the key comes from `api_key`, then `GEMINI_API_KEY`, then `GOOGLE_API_KEY`. Passing `project` or `location` raises a `ValueError` at setup. -- **Only `enterprise=` picks the backend.** The SDK reads `GOOGLE_GENAI_USE_ENTERPRISE` and `GOOGLE_GENAI_USE_VERTEXAI` only when no flag is passed. The plugin always passes one, so both variables stay ignored, as they are today. A variable set for some other tool can't move an app to a different billing account. - -## What still differs between backends - -The namespace and refs stay the same, but some model IDs differ by backend: - -- **Veo:** the IDs don't overlap. The Developer API uses `veo-3.1-generate-preview`, and Cloud uses `veo-3.1-generate-001`. -- **Gemini:** most names are shared. The `-latest` aliases (`gemini-flash-latest`, …) exist only on the Developer API. -- **Known-name lists** on `GoogleAI.gemini()` / `.veo()` become the union of both backends. A name the configured backend doesn't serve fails at lookup, and the error names the backend. - -## Interactions API - -**Background.** Gemini can be called through two Google APIs: - -- **`generateContent`:** the older API. Each request sends the full conversation and gets a response back. -- **The Interactions API:** the newer one (`/interactions`). Google's agent-style models are built on it (Deep Research, Antigravity), and it adds things like server-side `store` and background runs. Gemini is moving to it. - -Users don't pick between them. `ai.generate(...)` looks the same either way, and the plugin chooses the API for each model. - -**Where the plugin is today:** Gemini, Gemma, Imagen, Veo and embedders still use `generateContent`. Only Deep Research, Antigravity and Lyria use Interactions, and only on the Developer API. The migration is in progress: [genkit-python#78](https://github.com/genkit-ai/genkit-python/pull/78), then [#105](https://github.com/genkit-ai/genkit-python/pull/105), then a follow-up that moves Gemini onto Interactions, the same split the JS plugin already uses ([genkit#6851](https://github.com/genkit-ai/genkit/pull/6851)). It uses the plugin's own HTTP client and wire types rather than the SDK's. - -**Why it matters here.** After the migration, the plugin has two code paths: `genai.Client` for `generateContent` models and its own client for Interactions models. Both APIs exist on both backends: - -- **Interactions, Developer API:** `v1beta/interactions`, authenticated with an API key. -- **Interactions, Cloud:** `v1beta1/projects/{p}/locations/{l}/interactions`, authenticated with OAuth. Express mode uses `locations/global/interactions`. -- **What differs:** the request body is the same, apart from a few field rules (Cloud rejects `top_k`, and Cloud Interactions doesn't serve image models). - -So `enterprise=` has to reach both code paths. Otherwise, `GoogleAI(enterprise=True)` could send Imagen calls to Cloud while Gemini calls still go to the Developer API. Gemini on Interactions works with either value. - -**The ask for the Interactions work:** the Cloud Interactions client should choose its URL and auth from a backend value passed in, not from the plugin class, and the request function should take credentials instead of assuming an API key. That's the same amount of work now. `GoogleAI(enterprise=...)` then just connects the setting; nothing has to be moved out of `VertexAI`. - -## At 2.0: the `vertexai/` alias - -When `VertexAI` is removed, no plugin is named `vertexai`. The registry picks a plugin from the text before the first `/`, so `vertexai/gemini-2.5-flash` would never reach `GoogleAI` and would come back as a generic not-found. The core change is to let a plugin claim older namespace names: - -```python -class GoogleAI(Plugin): - name = 'googleai' - legacy_namespaces = ('vertexai',) # new, in genkit.plugin_api - -await ai.generate(model='vertexai/gemini-2.5-flash', prompt='Suggest a dish.') -# => with enterprise=True: same action as googleai/gemini-2.5-flash -# => otherwise: GenkitError: NOT_FOUND, 'vertexai/gemini-2.5-flash' needs GoogleAI(enterprise=True) -``` - -- **Routing:** `vertexai/...` goes to `GoogleAI.resolve`, and the plugin is told which name was used. The backend check lives in the plugin, not in core. -- **Naming:** the resolved action is stored and traced under `googleai/...`. Today the registry names an action after whatever string was asked for. -- **Dev UI:** the model list doesn't show the alias, so models don't appear twice. -- **Cost:** new public API in `genkit.plugin_api` for plugin authors. - -## What we give up at 2.0 - -- **Both backends in one app.** Until 2.0, `GoogleAI()` plus `VertexAI()` keeps working. After 2.0, two `GoogleAI` plugins collide on `googleai/`, and the registry raises at startup. We'd make that message name the fix. I expect this is rare, but we have no usage data. -- **A possible follow-up that doesn't break anyone:** a per-request backend override, if those apps show up. It's not part of this proposal. Config is merged from the ref, the `.prompt` file and the call, and middleware can rewrite it, so putting billing routing in config needs its own design. Background `Operation`s would also have to record their backend. - -## Other SDKs - -This proposal covers Python only. One thing to flag for JS and Go: `.prompt` files are shared across SDKs, so with `GoogleAI(enterprise=True)` in Python, `googleai/gemini-2.5-flash` runs on Cloud in Python but on the Developer API in JS and Go. It only affects users who opt in, but JS and Go may want the same option eventually. - -## Plan - -1. **Now:** - - Agree the Cloud Interactions transport shape with the Interactions migration owner. - - Get sign-off on this proposal. - - Merge [genkit-python#137](https://github.com/genkit-ai/genkit-python/pull/137), the Model Garden rename. It doesn't depend on this proposal, but it is breaking, so it needs to land before Python 1.0. -2. **The Python Interactions stack lands:** [#78](https://github.com/genkit-ai/genkit-python/pull/78), then [#105](https://github.com/genkit-ai/genkit-python/pull/105), then Gemini on Interactions with the Cloud transport. -3. **`GoogleAI(enterprise=...)`**, any 1.x release (ideally 1.0), stacked on the Interactions work: - - the `enterprise`, `project` and `location` parameters; - - `enterprise=` passed to the SDK client; - - backend-specific checks keyed on `enterprise`; - - the backend in traces; - - internal renames; - - the `VertexAI` deprecation warning. - - Additive. -4. **At 2.0:** core namespace aliases, then remove `VertexAI` and register the `vertexai/` alias. How long the alias lives is decided then. - -## Open questions - -1. **The direction:** one `GoogleAI` plugin with a backend switch, `VertexAI` deprecated in 1.x and removed at 2.0. -2. **The flag name:** mirror the SDK's `enterprise=`, or use a brand-neutral `backend=` Literal. `enterprise=` matches `genai.Client`. `backend=` survives the next rename, and the product has already moved past "Gemini Enterprise Agent Platform". Worth checking with the `google-genai` team which way their flag is headed. -3. **Sequencing with the Interactions stack:** `enterprise=` is stacked on #78, then #105, then Gemini on Interactions, and needs the Cloud Interactions client to take the backend as a value. Shipping it in 1.0 depends on the Interactions owner agreeing to that shape and landing in time. Otherwise it ships in a later 1.x. From 4e494ca440e210c795e618cdc2160ecd7763654e Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 17 Nov 2026 17:28:49 -0600 Subject: [PATCH 6/6] docs: default enterprise to False in the GoogleGenAI proposal --- docs/proposals/googlegenai-plugin.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/proposals/googlegenai-plugin.md b/docs/proposals/googlegenai-plugin.md index 3ff734fd..319aa986 100644 --- a/docs/proposals/googlegenai-plugin.md +++ b/docs/proposals/googlegenai-plugin.md @@ -1,4 +1,4 @@ -# Proposal: One `GoogleGenAI` plugin with a required `enterprise=` flag +# Proposal: One `GoogleGenAI` plugin with an `enterprise=` flag **Author:** Jeff Huang · **Status:** Proposed · **Applies to:** `genkit-google-genai` (Python), before 1.0 @@ -9,10 +9,8 @@ This proposal replaces both with one plugin, named after the package, before Python 1.0: ```python -GoogleGenAI(enterprise=False) # AI Studio key +GoogleGenAI() # AI Studio key GoogleGenAI(enterprise=True, project='bistro-prod', location='us-central1') # Google Cloud -GoogleGenAI() -# => TypeError: missing required keyword argument 'enterprise' ``` `GoogleAI` and `VertexAI` are removed, not deprecated. Python 1.0 ships with `GoogleGenAI` only, so there's no deprecation path to carry and no alias machinery to build. @@ -31,7 +29,7 @@ GoogleGenAI() ```python # 1. Prototype on an AI Studio key -ai = Genkit(plugins=[GoogleGenAI(enterprise=False)]) +ai = Genkit(plugins=[GoogleGenAI()]) # 2. Production on a Cloud project: same refs, same .prompt files ai = Genkit(plugins=[GoogleGenAI(enterprise=True, project='bistro-prod', location='us-central1')]) @@ -41,11 +39,11 @@ response = await ai.generate(model=GoogleGenAI.gemini('gemini-2.5-flash'), promp # => runs on whichever backend the plugin was configured for # 4. A model the configured backend doesn't serve fails at lookup -await ai.generate(model=GoogleGenAI.virtual_try_on('virtual-try-on-001'), ...) # with enterprise=False +await ai.generate(model=GoogleGenAI.virtual_try_on('virtual-try-on-001'), ...) # on the default backend # => GenkitError: NOT_FOUND, 'googlegenai/virtual-try-on-001' needs GoogleGenAI(enterprise=True) ``` -- **`enterprise=` is required, keyword-only, with no default.** Picking a billing account is a deliberate choice. Leaving it out is a `TypeError` on the user's own line. +- **`enterprise=` is keyword-only and defaults to `False`.** `GoogleGenAI()` behaves like `GoogleAI()` today, and matches `genai.Client()`, which also defaults to the Developer API. The default can't bill a Cloud project by accident: Cloud needs an explicit `enterprise=True`, and without a Gemini API key the default fails at setup with an error naming the key. - **The backend is set on the plugin only.** It isn't in `GeminiConfig` or any model config. Config is merged from the ref, the `.prompt` file and the call, and middleware can rewrite it, so a config field would let any of those move an app to a different billing account. It also couldn't work: `resolve()` and the Dev UI model list run before any request exists, and need to know the backend to know which models exist. - **One namespace: `googlegenai/`.** Typed refs are classmethods (`GoogleGenAI.gemini('x')`). They run without a plugin instance, so they can't know the backend and need one fixed prefix. The ref names the model; the plugin picks the backend. - **Traces record the backend.** The ref no longer shows which account paid, so the backend goes in span metadata. @@ -73,7 +71,7 @@ VertexAI(project='bistro-prod', location='us-central1') VertexAI(api_key=key) # Cloud express mode # after -GoogleGenAI(enterprise=False, api_key=key) +GoogleGenAI(api_key=key) GoogleGenAI(enterprise=True, project='bistro-prod', location='us-central1') GoogleGenAI(enterprise=True, api_key=key) # Cloud express mode ``` @@ -82,7 +80,7 @@ GoogleGenAI(enterprise=True, api_key=key) # Cloud express mode - `project`: the argument, then `GCLOUD_PROJECT` / `GOOGLE_CLOUD_PROJECT`, then `credentials.project_id`, then the ADC project. - `location`: the argument, then `GOOGLE_CLOUD_LOCATION` / `GCLOUD_LOCATION`, then `us-central1`. Multi-regions keep their dedicated endpoints. - Express mode only with an explicit `api_key=`. Environment keys stay ignored, as they are today, so an AI Studio `GEMINI_API_KEY` never quietly becomes a Cloud key. -- **`enterprise=False`:** the key comes from `api_key`, then `GEMINI_API_KEY`, then `GOOGLE_API_KEY`. Passing `project` or `location` raises a `ValueError` at setup. +- **`enterprise=False` (default):** the key comes from `api_key`, then `GEMINI_API_KEY`, then `GOOGLE_API_KEY`. Passing `project` or `location` raises a `ValueError` at setup. - **Only `enterprise=` picks the backend.** The SDK reads `GOOGLE_GENAI_USE_ENTERPRISE` and `GOOGLE_GENAI_USE_VERTEXAI` only when no flag is passed. The plugin always passes one, so both variables stay ignored, as they are today. ## What differs between backends @@ -117,7 +115,7 @@ await ai.generate(model='googleai/gemini-2.5-flash', prompt='...') # after from genkit_google_genai import GoogleGenAI -ai = Genkit(plugins=[GoogleGenAI(enterprise=False)]) +ai = Genkit(plugins=[GoogleGenAI()]) await ai.generate(model=GoogleGenAI.gemini('gemini-2.5-flash'), prompt='...') await ai.generate(model='googlegenai/gemini-2.5-flash', prompt='...') ``` @@ -126,7 +124,7 @@ In this repo, that's about 100 references to `GoogleAI`/`VertexAI` outside the p ## Other SDKs -This proposal covers Python. JS agreed on the same shape for JS 2.0: one `googleGenAI` plugin with a required `enterprise` flag. In JS, the parent can hold the existing `googleAI` or `vertexAI` plugin internally and delegate to it, so the change there is a layer on top rather than a rewrite. +This proposal covers Python. JS agreed on the same shape for JS 2.0: one `googleGenAI` plugin with an `enterprise` flag. JS discussed making the flag required; Python defaults it to `False`, and the two SDKs should land on the same answer. In JS, the parent can hold the existing `googleAI` or `vertexAI` plugin internally and delegate to it, so the change there is a layer on top rather than a rewrite. One thing to keep in step: `.prompt` files are shared across SDKs, so the namespace string has to match. If Python registers `googlegenai/`, JS 2.0 and Go should too. A JS parent that delegates to its inner plugin should still register its models under `googlegenai/`, not `googleai/` or `vertexai/`. @@ -134,7 +132,7 @@ One thing to keep in step: `.prompt` files are shared across SDKs, so the namesp 1. **Now:** sign-off on this proposal from Python and JS owners. 2. **Before Python 1.0, one PR:** - - `GoogleGenAI` with required `enterprise`, `project` and `location`; + - `GoogleGenAI` with `enterprise` (default `False`), `project` and `location`; - catalog and `resolve()` keyed on `enterprise`, with backend-named `NOT_FOUND`; - the backend in span metadata; - remove `GoogleAI` and `VertexAI` exports;