Firebase Studio “hits a snag” - constantly

I am developing a project in Firebase Studio. When I talk to Gemini AI, I get an AI error. I don’t know how to solve it?

Sorry, I hit a snag. Please try again shortly or modify your prompt.

[GoogleGenerativeAI Error]: Error fetching from https://monospace-pa.googleapis.com/v1/models/gemini-2.5-pro-preview-03-25:streamGenerateContent?alt=sse: [400 Bad Request] The input token count (10138605) exceeds the maximum number of tokens allowed (1048576).

Processing: image.png…

Hello,

Welcome to the Forum!

It seems that you have reached the maximum number of allowed tokens. I would recommend you to go through Firebase documentation, this will help you gain detailed information.

i got the same problem, when does this limit reset ? isn’t it there any solutions ? can’t i put my own api key and pay for what i use ?

Hello,

Welcome to the Forum!

I would recommend you to go through Firebase documentation.

Your error is due to the total number of tokens that Gemini is trying to process in Firebase Studio exceeding the allowed limit (1,048,576 tokens). This can happen if your request is too long or if the app you’re developing includes a lot of files or embedded data.

It’s not a bug, nor have you hit a daily limit or anything like that. It’s simply that your project (or what you’re sending to the model) is loading more than 1 million tokens, which goes beyond what Gemini can handle in a single request.

The same thing happened to me: in my case, the website had many files (some encoded in base64) directly included in the project, which caused the token count to skyrocket.

:white_check_mark: Quick fix: Try deleting unnecessary files or create a .aiexclude file in the root of the project to prevent Gemini from loading heavy folders like node_modules/, .next/, dist/, etc.

Thank you, the problem is finally solved, thank you for your solution.

TheLucator via Google AI Developers Forum <notifications@discuss.ai.google.dev> 于2025年7月10日周四 11:56写道: