Failed to generate image. {"error":"Forbidden"} on a deployed project that works inside AI Studio (original) (raw)
I recently made a copy of a project to work on a series of updates, whilst preserving the original. I have deployed the new version to Cloud Run, with its API secret, and yet the new copy always returns this message when generating an image.
Failed to generate image. {“error”:“Forbidden”}
The original project (also hosted with Google Cloud Run within the same cloud project) runs fine and works as needed.
I have checked my APIs for any restrictions, I am on a paid billing account also.
The original live project works fine. However I made a copy to update in order to preserve the original due to the ongoing issues with AI Studio.
I tested the appliction inside AI Studio and it worked really well. However now it is live, it always returns this message.
In DEV Mode within Chrome - I get the following message with the error.
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent 403 (Forbidden)
| apiCall | @ | index-BPcFo9ol.js:129 |
|---|---|---|
| unaryApiCall | @ | index-BPcFo9ol.js:125 |
| request | @ | index-BPcFo9ol.js:125 |
| await in request | ||
|---|---|---|
| generateContentInternal | @ | index-BPcFo9ol.js:149 |
| JC.generateContent | @ | index-BPcFo9ol.js:149 |
| await in JC.generateContent | ||
|---|---|---|
| zN | @ | index-BPcFo9ol.js:399 |
| await in zN | ||
|---|---|---|
| Ii | @ | index-BPcFo9ol.js:668 |
| xe | @ | index-BPcFo9ol.js:668 |
| onClick | @ | index-BPcFo9ol.js:668 |
| Mp | @ | index-BPcFo9ol.js:48 |
| (anonymous) | @ | index-BPcFo9ol.js:48 |
| kc | @ | index-BPcFo9ol.js:48 |
| su | @ | index-BPcFo9ol.js:48 |
| Su | @ | index-BPcFo9ol.js:49 |
| wv | @ | index-BPcFo9ol.js:49 |
Error transforming image: ApiError: {“error”:“Forbidden”}
at tg (index-BPcFo9ol.js:129:4200)
at async index-BPcFo9ol.js:125:5849
at async JC.generateContent (index-BPcFo9ol.js:149:807)
at async zN (index-BPcFo9ol.js:399:113)
at async Ii (index-BPcFo9ol.js:668:68274)
| zN | @ | index-BPcFo9ol.js:399 |
|---|
| await in zN | ||
|---|---|---|
| Ii | @ | index-BPcFo9ol.js:668 |
| xe | @ | index-BPcFo9ol.js:668 |
| onClick | @ | index-BPcFo9ol.js:668 |
| Mp | @ | index-BPcFo9ol.js:48 |
| (anonymous) | @ | index-BPcFo9ol.js:48 |
| kc | @ | index-BPcFo9ol.js:48 |
| su | @ | index-BPcFo9ol.js:48 |
| Su | @ | index-BPcFo9ol.js:49 |
| wv | @ | index-BPcFo9ol.js:49 |
Any help?
Can anyone help? I’m really not sure what to do.
Further update, as a baseline test, I made another copy of the original project, but this time made NO changes. Set my API secret and deployed it.
I got the same exact error. There is a problem with my APIs on any newly deployed project.
No matter which I use.
I urgently need assistance,
Question - Should I be adding my Gen AI API under Gemini API, or somehow manually as a standard secret?
From the feedback channels of github or Google Developer, this problem is entirely a server problem, and it is difficult for individuals to solve it. I have been unable to use gemini cli for two weeks!
I have noticed something between the deployed project that is not working, and an earlier project deployed before Google made various changes to the way AI Studio works.
In the project that works, deployed 11th Feb, under Source (in cloud run, services), it shows all the various files.
In the project that doesn’t work, it shows the following message under Source instead - “This service was deployed using a container image. There is no source code available to edit.”
Under “edit and deploy new version”, there are also a different number of variables between the 2. The project that works only has a single variable which is the API Key. The one that doesn’t work has 2 containers and 3 variables, including the key.