Skip to content

feat(go/plugins/googlegenai): Support tuned Gemini endpoint models#5178

Draft
cabljac wants to merge 1 commit into
mainfrom
feat/go-googlegenai-tuned-gemini
Draft

feat(go/plugins/googlegenai): Support tuned Gemini endpoint models#5178
cabljac wants to merge 1 commit into
mainfrom
feat/go-googlegenai-tuned-gemini

Conversation

@cabljac
Copy link
Copy Markdown
Contributor

@cabljac cabljac commented Apr 23, 2026

Accepts Vertex AI tuned Gemini endpoints addressed either by the short form endpoints/ID or the full resource path projects/PROJECT/locations/LOCATION/endpoints/ID.

ClassifyModel now routes these names to ModelTypeGemini, and a new resolveVertexModelName helper expands the short form to the full path before the google.golang.org/genai SDK transforms it — avoiding the SDK's default publishers/google/models/ prefix, which only applies to first-party models. VertexAI.DefineModel also accepts tuned endpoint names with a nil options argument and falls back to the default Gemini capability set.

Mirrors js/plugins/google-genai/src/vertexai/client.ts.

Testing

image

Accept Vertex AI tuned endpoints addressed either by the short form
`endpoints/ID` or the full resource path
`projects/PROJECT/locations/LOCATION/endpoints/ID`. ClassifyModel now
routes these names to ModelTypeGemini, and a new resolveVertexModelName
helper expands the short form to the full path before the
google.golang.org/genai SDK transforms it, avoiding the SDK's default
`publishers/google/models/` prefix that only applies to first-party
models.

VertexAI.DefineModel also accepts tuned endpoint names with a nil
options argument, falling back to the default Gemini capability set.

Adds unit tests for ClassifyModel and isTunedGeminiName, and a live
subtest in vertexai_live_test.go gated by GENKIT_VERTEX_TUNED_ENDPOINT.
Mirrors the JS behaviour in js/plugins/google-genai/src/vertexai/client.ts.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Vertex AI tuned Gemini endpoints, allowing them to be addressed via short-form or full resource paths. Key changes include the addition of a name resolution helper, updates to model classification logic, and modifications to the model definition process to accommodate these dynamic endpoints. A critical feedback point identifies that tuned endpoints, which are not in the static model list, would receive empty model options; a suggestion was provided to use default Gemini options instead to ensure proper capability support.

Comment on lines +223 to +225
if isTunedGeminiName(name) {
defaults := GetModelOptions(name, vertexAIProvider)
opts = &defaults
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Calling GetModelOptions with the tuned endpoint name (e.g., endpoints/ID) will likely return an empty ai.ModelOptions struct because tuned endpoints are not in the static list of known models. This results in a model with nil Supports, which can cause issues with Genkit features that validate model capabilities (like tool calling). Since tuned Gemini models share the same capabilities as base Gemini models, consider using a known Gemini model name to retrieve the default options.

Suggested change
if isTunedGeminiName(name) {
defaults := GetModelOptions(name, vertexAIProvider)
opts = &defaults
if isTunedGeminiName(name) {
// Tuned models are not in the static list, so we use default Gemini options.
defaults := GetModelOptions("gemini-1.5-flash", vertexAIProvider)
opts = &defaults
} else {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Traced this and the flow is fine — tuned endpoints get the full Gemini Supports, not nil. Path:

  1. isTunedGeminiName("endpoints/ID") returns true (model_type.go:52).
  2. ClassifyModel returns ModelTypeGemini via the tuned fall-through at model_type.go:38–42.
  3. GetModelOptions (models.go:275–280) doesn't find the tuned name in supportedGeminiModels, so it falls back to defaultGeminiOpts, which has full Supports (Multimodal).

No nil Supports at the call site. go build / go vet clean and CI is green.

cabljac added a commit that referenced this pull request Apr 23, 2026
Accepts Vertex AI tuned endpoints addressed either by the short form
`endpoints/ID` or the full resource path
`projects/PROJECT/locations/LOCATION/endpoints/ID`.

- gemini.py gains is_tuned_gemini_name() and resolve_vertex_model_name()
  helpers; both generate_content call sites wrap the model name through
  the latter so the SDK receives a fully qualified path and skips its
  default publishers/google/models/ prefixing.
- VertexAI._resolve_model routes tuned endpoint names through GeminiModel
  with the standard Gemini config schema and a sensible label.
- Skip list_actions injection — tuned endpoints are private and not
  publicly listable.
- Mirrors the Go PR #5178 design and the JS behaviour in
  js/plugins/google-genai/src/vertexai/client.ts.
- Adds a unit test file covering both helpers and all dispatch paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant