Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Search is not working #70

Open
MOzcelik14 opened this issue Feb 18, 2025 · 8 comments
Open

Google Search is not working #70

MOzcelik14 opened this issue Feb 18, 2025 · 8 comments
Labels
invalid This doesn't seem right

Comments

@MOzcelik14
Copy link

MOzcelik14 commented Feb 18, 2025

Whenever I try to access real-time information, I get this error message:

System.Net.Http.HttpRequestException: 'Request failed
Request failed with Status Code: TooManyRequests

{
  "error": {
    "code": 429,
    "message": "Resource has been exhausted (e.g. check quota).",
    "status": "RESOURCE_EXHAUSTED"
  }
}
var model = googleAI.GenerativeModel(model: Model.Gemini20Pro, systemInstruction: systemInstruction);
model.UseGoogleSearch = true;
var response = await model.GenerateContent(prompt);

And this is my code.

@jochenkirstaetter
Copy link
Contributor

Hi @MOzcelik14

Thanks for reaching out. The HTTP status code 429 as well as 503 is returned by the Gemini API when they have capacity issues. That's nothing to be done on the client side and your code is correct.

See test cases

for comparison.

Happens to me and others regularly, as you can see in the Build with Google AI Forum.

Either wait a bit or use another model and try it again. Switching models usually helps on my side.

Cheers.

@jochenkirstaetter jochenkirstaetter added the invalid This doesn't seem right label Feb 18, 2025
@jochenkirstaetter
Copy link
Contributor

Hi @MOzcelik14

Are you still observing this issue?
Or can I consider to close it?

Cheers.

@MOzcelik14
Copy link
Author

hi @jochenkirstaetter

doesn't the 1.5 model have a grounding feature?

@MOzcelik14
Copy link
Author

I am currently trying to develop an artificial intelligence assistant for the faculty I study at. Our dean says he wants to access real-time information. When I use the 2.0 Pro model, I get the 429 error message after 1 or 2 prompts. And I think there is no grounding feature in any model of the 1.5.

@jochenkirstaetter
Copy link
Contributor

Hello @MOzcelik14

Yes, the Gemini 1.5 models also support Google Search and Grounding (using Vertex AI).

Kindly have a look at the tests. There are a few examples. Have you tried the Gemini 2.0 Flash models already?

Cheers, JoKi

@jochenkirstaetter
Copy link
Contributor

Hi @MOzcelik14

You have a choice:

  • Latest: gemini-2.0-flash
    
  • Stable: gemini-2.0-flash-001
    

Check whether the stable model behaves less problematic regarding the quota.
Reference: https://ai.google.dev/gemini-api/docs/models/gemini#gemini-2.0-flash

Or using Vertex AI, as previously suggested. There you have access to Gemini 1.5 models, too.
Reference: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/grounding

This SDK provides you with both options. Hope this helps.

@MOzcelik14
Copy link
Author

MOzcelik14 commented Feb 20, 2025

How do I use the Vertex AI with Mscc.GenerativeAI then? I didn't understand how to set it up. Sorry for bothering you continously by the way.

@jochenkirstaetter
Copy link
Contributor

Hi @MOzcelik14

I read on the Discord server of the Google Developer Community that there might have been update by the Gemini team recently.

Image

Maybe this already improved your scenario.

Vertex AI

You can use this package the same way. It's the first few lines to initialize the model which are slightly different because of the differences between Google AI and Vertex AI.

In case that you've never used Google Cloud before, you can check out the so-called "express mode" which is still based on using an API key, however different to your existing one. Start here: https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/overview - kindly check the Available models and rate limits in express mode.

If that's not enough then you could either graduate from express mode or directly sign up for an account on Google Cloud. Then create a project and use this SDK with your projectId and a location (or region).

using Mscc.GenerativeAI;
// Vertex AI with OAuth. Use `gcloud auth application-default print-access-token` to get the access token.
var vertex = new VertexAI(projectId: projectId, region: region);
var model = vertex.GenerativeModel(model: Model.Gemini15Pro);
model.AccessToken = accessToken;

If you are going to deploy your solution to Google Cloud I suggest using the package Mscc.GenerativeAI.Google to handle implicit authentication using the Google Client Library.

More information also here: https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants