Skip to content

Conversation

stefannae
Copy link
Contributor

@stefannae stefannae commented Sep 11, 2025

This PR adds an example of how to use models besides Gemini from the Vertex AI Model Garden.

@DouweM DouweM self-assigned this Sep 15, 2025
)
provider = GoogleProvider(client=client)
model = GoogleModel(
f'projects/{project}/locations/{location}/publishers/meta/models/llama-3.3-70b-instruct-maas',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would just publishers/meta/models/llama-3.3-70b-instruct-maas work as the project and location have already been configured?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. All these patterns should work:

f`{model_id}`,
f`publishers/{publisher}/models/{model_id}`,
f`projects/{project}/locations/{location}/publishers/{publisher}/models/{model_id}`

which is aligned with:
https://googleapis.github.io/python-genai/genai.html#genai.models.AsyncModels.generate_content_stream

Should I use the partial resource name publishers/meta/models/llama-3.3-70b-instruct-maas?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@stefannae Yeah, let's use the simplest option that doesn't require additional variables

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DouweM okay, made the change

Copy link

This PR is stale, and will be closed in 3 days if no reply is received.

@github-actions github-actions bot added the Stale label Sep 23, 2025
@github-actions github-actions bot removed the Stale label Sep 24, 2025
project='your-gcp-project-id',
location='us-central1', # the region where the model is available
)
model = GoogleModel('llama-3.3-70b-instruct-maas', provider=provider)
Copy link
Collaborator

Choose a reason for hiding this comment

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

From googleapis.github.io/python-genai/genai.html#genai.models.AsyncModels.generate_content_stream, it seems like this should be meta/llama-3.3-70b-instruct-maas, so we should fix it here and specify {publisher}/{model_id} in the docs above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed this 4th way of specifying the model. Still, the simplest way, according to the same docs (and tested - I've tested them all), is llama-3.3-70b-instruct-maas.

Should we keep llama-3.3-70b-instruct-maas in the example and add {publisher}/{model_id} to the list of patterns?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@stefannae Hmm, the docs make it sound like excluding the publisher only works with Gemini models, so even though you've verified it works with llama as well, I'd prefer to document and use only {publisher}/{model_id}, or say "{model_id} for Gemini models" like the docs do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DouweM, they have a formatting issue with the docs, which visually reads better from the docstring https://github.com/googleapis/python-genai/blob/538c755e84777e6b76d5152aac18268e4d0c99c6/google/genai/models.py#L6377-L6401

This way, seems Gemini is only used as an example:

For the `model` parameter, supported formats for Vertex AI API include:
- The Gemini model ID, for example: 'gemini-2.0-flash'
- The full resource name starts with 'projects/', for example:
  'projects/my-project-id/locations/us-central1/publishers/google/models/gemini-2.0-flash'
- The partial resource name with 'publishers/', for example:
  'publishers/google/models/gemini-2.0-flash' or
- `/` separated publisher and model name, for example:
  'google/gemini-2.0-flash'

For the `model` parameter, supported formats for Gemini API include:
- The Gemini model ID, for example: 'gemini-2.0-flash'
- The model name starts with 'models/', for example:
  'models/gemini-2.0-flash'
- For tuned models, the model name starts with 'tunedModels/',
  for example:
  'tunedModels/1234567890123456789'

Though given how the endpoints are defined in Vertex AI, it is probably better to switch to {publisher}/{model_id} in the example. Let me know your preference, and I'll make the change.

Screenshot from 2025-09-30 18-42-07

Copy link
Collaborator

Choose a reason for hiding this comment

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

@stefannae Yeah let's do that, I'm interpreting "Gemini model ID" as "this only works for Gemini models"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DouweM ok, pushed the update!

@DouweM DouweM enabled auto-merge (squash) September 30, 2025 21:55
@DouweM
Copy link
Collaborator

DouweM commented Sep 30, 2025

@stefannae Thanks Stefan, should merge shortly!

@DouweM DouweM merged commit 3b7c18e into pydantic:main Sep 30, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vertex Model garden models
2 participants