Gemini Canvas app 401 API error: why it broke and the fix
Gemini Canvas app showing a 401 API error? Likely a retired preview model or an unrestricted API key. How to find the cause and fix it, step by step.
The Liite team6 min di lettura
Short answer
A Canvas app that suddenly returns a 401 usually calls a preview model Google has retired, or uses an API key that no longer works. Find the model name in the app's code, switch it to a current model from Google's model list, then check the key's restrictions. Replace the key if it still fails.
An app you built in Gemini Canvas worked for a while, then started failing, most often an image-generation app. People on Google's Gemini help community describe it in a thread titled:
All of my Gemini Canvas built apps stopped working - 401 API error
Another thread on Google's AI developer forum reports the same thing for an image-generation app. Both are short, and neither has a confirmed root cause from Google, so what follows is the most likely explanation, not a guarantee.
Why it happens
We can't see inside your app. Here is what the public reports point to, most likely first.
Cause 1: a preview model was retired
People report that apps built on preview models, such as gemini-2.5-flash-image-preview, broke on January 15 and again on February 17, 2026. Preview models are experimental versions with a limited life. When Google switches one off, every app that names it in code starts failing, even though you changed nothing.
Cause 2: an unrestricted API key stopped working
This is a separate change. The reports give June 19, 2026 as the date after which API keys with no restrictions stop working. As of November 2026 that date has passed. If your app uses a key you created, the key could be the cause instead of, or on top of, the model. We haven't seen details of how Google enforces this, so check Google's current API key documentation.
Cause 3: something else
A 401 normally means "not authenticated", which points at the key. We don't know whether a retired model produces a 401 or a different error in your case. That is why it is worth checking both causes instead of assuming one.
| Cause | Typical symptom | Fix |
|---|---|---|
| Retired preview model | Fails on a feature that names a -preview model | Swap to a current model |
| Unrestricted API key | 401 or an auth error on every call | Add restrictions or make a new key |
| Both | Fixing one changes nothing | Do both |
| Key shared or leaked | Sudden failures after the key was posted publicly | Delete it and make a new one |
Step-by-step fixes
Fix 1: read the exact error
- Open your browser's developer tools on the running app.
- Look at the Console tab and the failed request in the Network tab.
- Read the response text. It often names the model or describes the key problem, which saves guessing.
Fix 2: replace a retired model
- Find the model name in the app's code. Search for
modelorgemini-. It is a plain text string passed to the API call. - Check whether it contains
preview. - Look up the current replacement in Google's Gemini API models and deprecations documentation. Pick a current model that does the same job.
- Replace the string and run the app again.
An image-generation app needs an image-capable model, so don't swap in a text-only one.
Don't guess model names
A name that merely looks right wastes a test cycle and muddies which problem you are fixing. Copy the name from Google's current model list. A chat assistant can suggest a name that doesn't exist, so confirm any suggestion there too.
Fix 3: check the API key
- Find out how the app gets its key. If you pasted your own key into the app, open that key's settings in Google AI Studio or the Google Cloud console.
- Look for the restrictions section. Menu labels change, so look for that section instead of following a fixed click path.
- A key with no restrictions is the case the June 19 change affects. Limit it to the Gemini API (listed as the Generative Language API in Google Cloud).
- If the app is public, add an application restriction as well.
Fix 4: make a new key if the old one still fails
- Create a fresh, restricted key.
- Put it in the app.
- Delete the old key.
If the old key was ever shared or pasted into a public page, replace it anyway.
Fix 5: test the smallest action
Run the simplest thing the app does, such as generating one image, and watch the console again. If that works, the rest should.
You can also describe the problem in the Canvas chat and ask Gemini to update the model. We haven't verified how reliably that works, so check whatever it changes.
Checklist before you try again
- The console error text is copied somewhere.
- The model name in the code has no
previewin it, or you have confirmed it still exists. - The replacement model supports what the app does (images, text, and so on).
- The key has restrictions, or you replaced it with one that does.
- The old key is deleted if it was ever exposed.
- You tested one small action before testing the whole app.
What won't help
- Reloading or re-sharing the app. The failure comes from the model or key the code calls, not from your session.
- Waiting. A retired model name doesn't come back, and preview names in particular are not restored.
- Only making a new key. That fixes a key problem, but a retired model name still errors.
- Rebuilding from scratch. In the reports we found, the repair is a model name and possibly a key, not a rewrite.
If nothing works
Contact Google through the Gemini Apps help center, or the Gemini API support and developer forum if you use your own API key. Include the exact error text, the date it started, the model name in your code, whether you use your own key, and what you already tried. We haven't seen Google confirm a platform-wide fix, so a clear report is the best way to get a useful reply.
My Gemini Canvas app stopped working and now returns a 401 API error.
Error text: [paste the exact message from the console]
First failed on: [date and time, with time zone]
Model name in the code: [for example gemini-2.5-flash-image-preview]
API key: [my own key / no key of my own], restrictions: [none / Gemini API only]
Already tried: switched to a current model, created a restricted key, retested one action.
Can you confirm whether this model or key type is retired, and what I should use instead?Common questions
Why did my app stop working when I didn't change anything?
Because something it depends on changed. A preview model has a limited life, and when it is retired, every app naming it fails at once. A change to API key rules can break an app the same way.
Do I need to rebuild the app?
Probably not. Rebuild only if your app relied on a feature the replacement model lacks.
Should I avoid preview models?
For anything other people use, yes. Preview models are meant for testing, and a stable model name is less likely to vanish. Even stable models get retired eventually, so keep the model name in one place in your code, where it is easy to change.
Has Google fixed it?
We haven't seen Google confirm a platform-wide fix. The replies in the threads we found were generic. Deprecation dates and key rules change, so check Google's current developer documentation before you spend time on it.