googleapis / googleapis/python-genai
client.files methods report "ValueError: This method is only supported in the Gemini Developer client" when used with VertexAI
- Dominant language
- Python
- Stars
- 4k
- Forks
- 1k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 40
Description
Usage of the `Client.files` methods with a VertexAI key raises `ValueError`, due to explicit conditionals, e.g. https://github.com/googleapis/python-genai/blob/99058b6244a1ae1d63511b7bb9130edcea96cd00/google/genai/files.py#L162
The explicit check makes it seem this is intentional, but I'm reporting it as a bug for the following reasons:
* Such a restriction is not mentioned anywhere on any docs page I can find ( e.g. https://ai.google.dev/gemini-api/docs/files )
* The language of the error is confusing. What is the 'Gemini Developer client'? Is that not what I'm using?
# Why this is a bigger deal than it seems
The split between VertexAI and Google AI Studio is already a huge usability problem for Gemini. I'm convinced that the only reason users aren't more vocal about it is that it's so confusing almost nobody understands it well enough to complain.
I know that the product pages are out-of-scope for this repo, but I think the product situation is very relevant to how these Vertex/AI-Studio issues should be prioritised. Consider these two product pages:
* AI Studio: https://ai.google.dev/gemini-api/docs/quickstart
* Vertex AI: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference?_gl=1*14xqblg*_ga*ODAxODkxOTk0LjE3NDQ3NDM2NzE.*_ga_WH2QY8WWF5*czE3NjQ2OTYyMjQkbzE3OCRnMSR0MTc2NDY5NjY1MSRqMjQkbDAkaDA.
These pages **don't mention each other**. They both pretend the other workflow doesn't exist. The Google AI Studio page says "Before you begin, You need a Gemini API key. If you don't already have one, you can get it for free in Google AI Studio". The Vertex AI page says "To start using the Gemini API in Vertex AI, create a Google Cloud account". There's a few VertexAI quickstarts and none of them mention the other flow.
If you're a Google Cloud user, the Quickstart on the AI Studio page is just false. You _don't_ need to create a Gemini API Key, you can just authenticate with your Google Cloud account. And the Vertex AI page is only technically correct: it does specify "in Vertex AI", but nobody can be expected to know what that means. In fact there's multiple Vertex AI quickstarts, all slightly different, but none that I've seen mention AI Studio. Here's two more I ended up on, I believe there's others:
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart?_gl=1*sjii6l*_up*MQ..&gclid=Cj0KCQiAubrJBhCbARIsAHIdxD_xc1AWdkZo1KqUW_1PaWJD5w91yJqqb_AYguf8E14pkWZrnXt5NPYaAop_EALw_wcB&gclsrc=aw.ds
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/start/quickstart?usertype=adc
Presumably Google thinks there's value in having an alternative workflow that lets people sign up for Gemini without a google cloud account. Whatever value there is in that, visitors to these Vertex pages won't be aware of it. They're told to just create a Google Cloud account.
The confusion is even worse because the authentication story for Google Cloud is already complex, with multiple possible workflows. You can use Application Default Credentials, get an API key bound to a project, or an express-mode API key. _Or_, you can get a _Gemini_ API key.
A few months ago I tried to use Gemini Code and I ended up in a state where I'd authenticated with a Gemini API key that was linked to the right Google Cloud project in AI Studio, but I hadn't associated a _billing project_ as well. As a result everything appeared to work, but I actually had no credit, so I immediately got a quota error. I don't know exactly how I ended up in that state or whether the project's fixed, but I see a lot of people complaining about quota errors. I suspect they may be encountering something like this.
Incidentally, I tried to ask Gemini to debug the quota issue, but this didn't work. Gemini doesn't understand Gemini's authentication flows (as of June, anyway), just as Gemini can't generate code to use Gemini (due to the `google-generativeai` vs `google-genai` situation).
The AI Studio and Vertex AI flows both seem to wish the other one didn't exist, so as a user it's very difficult to understand the difference. The only mention of the 'competitor' on each page I can see is a migration guide on VertexAI. But this definitely doesn't mention that you might lose functionality if you switch how you authenticate.
Finally, the conceptual confusion between AI Studio and Vertex AI bleeds out into the terminology. Within the codebase, it seems that the flow I'm referring to as "AI Studio" is referred to as the "Gemini Developer API". If I'm using Gemini via my Google Cloud account, I'd never guess that I'm not using the "Gemini Developer API" is not what I'm using.
# I know the deeper issue's tough to solve
I don't want to come across as though I'm saying "Gee, why can't you just coordinate? How hard can that be". Obviously coordinating efforts can be the hardest thing of all. But we've all seen so many Google projects killed by just this sort of indecision, and I always wonder whether there are internal discussions where someone is saying, "Is the problem really that bad? We don't hear that often from users". For everyone saying there's a usability problem, there might be someone else calling it a [skill issue](https://www.producthunt.com/newsletters/archive/34974-skill-issue) . So I wanted to voice the concern.
#### Environment details
- Programming language: Python
- OS: MacOS
- Language runtime version: 3.12.8
- Package version: 1.52.0
Contributor guide
Assessment
This issue has not been assessed yet.