Gemini 1.5 Pro API time to time suddenly return error 403

We are part of the Google Startups Program and are Building AI Tools and Agents.

One of our tool do some Gemini 1.5 Pro api request but we regularly end up getting and error 403 and not able to query anymore. We don’t really understand why this happen, the issue is mostly when the agent run on the VPS while we don’t see it when we run it locally.

Any idea what can be the issue? How to avoid it or fix it when it happen?

Thank you in advance.

Welcome to the forum.
There is more than just 403, usually. A text message goes with the status code. Since you didn’t post the message, the following is speculation. You are probably using a free account (billing not enabled) and that’s fine from your location.

The VPN endpoint makes it appear that you are in the EU or UK and then the API rejects the request because a billed account is required from these locations.

If the speculation is way off, then please provide additional information so we can help deduce what the actual problem is.

Hope that helps.

Thank you very much for the answer. Since both the VPS and local are in EU, i would believe it’s not about location, here the error we generally gets: 403 Received http2 header with status: 403
Does it help a bit or not at all?

Welcome @crashbdx

403 means forbidden. This can be because of a variety of reasons:

  • Insufficient Permissions
  • IP Blocking
  • User-Agent Blocking
  • Rate Limiting
  • Resource Restriction
  • Domain or Referrer Restrictions

The project has billing enabled? There’s a more descriptive error text that comes with 403 because there are so many different reasons for the server to return it. Try to find a development environment feature that will log more text. There might be a flag, an environment variable, some capability to log the error message. The error text you are seeing is too generic.

Thank you very much, we will try to run an instance locally and see if we can catch more details when this occur again then we’ll share more here.